OSDN Git Service

Btrfs: fix btrfs_evict_inode to handle abnormal inodes correctly
authorLiu Bo <bo.li.liu@oracle.com>
Thu, 25 Jan 2018 18:02:53 +0000 (11:02 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 22 Feb 2018 14:43:50 +0000 (15:43 +0100)
commitb48edd6d7658a9fdb05c162f1f099245e7cd22e5
treef8122af1576712eb598e0b518ecee2f8761cf9ee
parentbc0d431e74adb5967fe39bc07aad68a6a865612d
Btrfs: fix btrfs_evict_inode to handle abnormal inodes correctly

commit e8f1bc1493855e32b7a2a019decc3c353d94daf6 upstream.

This regression is introduced in
commit 3d48d9810de4 ("btrfs: Handle uninitialised inode eviction").

There are two problems,

a) it is ->destroy_inode() that does the final free on inode, not
   ->evict_inode(),
b) clear_inode() must be called before ->evict_inode() returns.

This could end up hitting BUG_ON(inode->i_state != (I_FREEING | I_CLEAR));
in evict() because I_CLEAR is set in clear_inode().

Fixes: commit 3d48d9810de4 ("btrfs: Handle uninitialised inode eviction")
Cc: <stable@vger.kernel.org> # v4.7-rc6+
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/inode.c