Skip to content

Commit 909e26d

Browse files
osandovmasoncl
authored andcommitted
btrfs: unlock i_mutex after attempting to delete subvolume during send
Whenever the check for a send in progress introduced in commit 521e054 (btrfs: protect snapshots from deleting during send) is hit, we return without unlocking inode->i_mutex. This is easy to see with lockdep enabled: [ +0.000059] ================================================ [ +0.000028] [ BUG: lock held when returning to user space! ] [ +0.000029] 4.0.0-rc5-00096-g3c435c1 torvalds#93 Not tainted [ +0.000026] ------------------------------------------------ [ +0.000029] btrfs/211 is leaving the kernel with locks still held! [ +0.000029] 1 lock held by btrfs/211: [ +0.000023] #0: (&type->i_mutex_dir_key){+.+.+.}, at: [<ffffffff8135b8df>] btrfs_ioctl_snap_destroy+0x2df/0x7a0 Make sure we unlock it in the error path. Reviewed-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.cz> Cc: stable@vger.kernel.org Signed-off-by: Omar Sandoval <osandov@osandov.com> Signed-off-by: Chris Mason <clm@fb.com>
1 parent b860545 commit 909e26d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fs/btrfs/ioctl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2410,7 +2410,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
24102410
"Attempt to delete subvolume %llu during send",
24112411
dest->root_key.objectid);
24122412
err = -EPERM;
2413-
goto out_dput;
2413+
goto out_unlock_inode;
24142414
}
24152415

24162416
d_invalidate(dentry);
@@ -2505,6 +2505,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
25052505
root_flags & ~BTRFS_ROOT_SUBVOL_DEAD);
25062506
spin_unlock(&dest->root_item_lock);
25072507
}
2508+
out_unlock_inode:
25082509
mutex_unlock(&inode->i_mutex);
25092510
if (!err) {
25102511
shrink_dcache_sb(root->fs_info->sb);

0 commit comments

Comments
 (0)