diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index fce61991213c..b009fb52bd8a 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -7315,8 +7315,9 @@ int btrfs_drop_inode(struct inode *inode) { struct btrfs_root *root = BTRFS_I(inode)->root; + /* the snap/subvol tree is on deleting */ if (btrfs_root_refs(&root->root_item) == 0 && - !btrfs_is_free_space_inode(inode)) + root != root->fs_info->tree_root) return 1; else return generic_drop_inode(inode); diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index e0893036da08..2bbbed506f5b 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -2174,6 +2174,12 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file, shrink_dcache_sb(root->fs_info->sb); btrfs_invalidate_inodes(dest); d_delete(dentry); + + /* the last ref */ + if (dest->cache_inode) { + iput(dest->cache_inode); + dest->cache_inode = NULL; + } } out_dput: dput(dentry);