Skip to content

Commit

Permalink
Btrfs: fix btrfs_evict_inode to handle abnormal inodes correctly
Browse files Browse the repository at this point in the history
This regression is introduced in
commit 3d48d98 ("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 3d48d98 ("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>
  • Loading branch information
Liu Bo authored and David Sterba committed Feb 2, 2018
1 parent 55237a5 commit e8f1bc1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -5281,7 +5281,7 @@ void btrfs_evict_inode(struct inode *inode)
trace_btrfs_inode_evict(inode);

if (!root) {
kmem_cache_free(btrfs_inode_cachep, BTRFS_I(inode));
clear_inode(inode);
return;
}

Expand Down

0 comments on commit e8f1bc1

Please sign in to comment.