gfs2: Fix and clean up create / evict interaction
authorAndreas Gruenbacher <agruenba@redhat.com>
Wed, 2 Nov 2022 16:06:58 +0000 (17:06 +0100)
committerAndreas Gruenbacher <agruenba@redhat.com>
Fri, 2 Dec 2022 14:58:00 +0000 (15:58 +0100)
commit38552ff676f072e7d15c5e0a877fda613e57ed2d
tree3bf3437ad5d143178b2348dbbabdc0cd6f3f486c
parent3d0258bc11185ccb21f922332eca731e1928c5a4
gfs2: Fix and clean up create / evict interaction

When gfs2_create_inode() fails after creating a new inode, it uses the
GIF_FREE_VFS_INODE and GIF_ALLOC_FAILED inode flags to communicate to
gfs2_evict_inode() which parts of the inode need to be deallocated and
destroyed.  In some error cases, the inode ends up being allocated on
disk and then accidentally left behind.  In others, the inode is
partially constructed and then not properly destroyed.  Clean this up by
completely handling the inode deallocation and destruction in
gfs2_evict_inode().

This means that gfs2_evict_inode() may now be faced with partially
constructed inodes, so add the necessary checks to cope with that.  In
particular, make sure that for incompletely constructed inodes, we're
not accessing the buffers backing the on-disk blocks; the contents may
be undefined.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
fs/gfs2/inode.c
fs/gfs2/meta_io.c
fs/gfs2/super.c
fs/gfs2/xattr.c