Btrfs: fix btrfs_evict_inode to handle abnormal inodes correctly
authorLiu Bo <[email protected]>
Thu, 25 Jan 2018 18:02:53 +0000 (11:02 -0700)
committerDavid Sterba <[email protected]>
Fri, 2 Feb 2018 15:24:35 +0000 (16:24 +0100)
commite8f1bc1493855e32b7a2a019decc3c353d94daf6
tree34e4b92f80613658a760de63937af6e498566de1
parent55237a5f2431a72435e3ed39e4306e973c0446b7
Btrfs: fix btrfs_evict_inode to handle abnormal inodes correctly

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: <[email protected]> # v4.7-rc6+
Signed-off-by: Liu Bo <[email protected]>
Reviewed-by: Nikolay Borisov <[email protected]>
Reviewed-by: Josef Bacik <[email protected]>
Signed-off-by: David Sterba <[email protected]>
fs/btrfs/inode.c