* [PATCH] btrfs: unlock i_mutex after attempting to delete subvolume during send
@ 2015-03-28 11:02 Omar Sandoval
2015-03-28 11:37 ` Filipe David Manana
2015-03-30 12:59 ` David Sterba
0 siblings, 2 replies; 4+ messages in thread
From: Omar Sandoval @ 2015-03-28 11:02 UTC (permalink / raw)
To: Chris Mason, Josef Bacik, David Sterba
Cc: Filipe Manana, linux-btrfs, linux-kernel, Omar Sandoval
Whenever the check for a send in progress introduced in commit
521e0546c970 (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 #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.
Signed-off-by: Omar Sandoval <osandov@osandov.com>
---
fs/btrfs/ioctl.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 74609b9..9fde01f 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2403,7 +2403,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
"Attempt to delete subvolume %llu during send",
dest->root_key.objectid);
err = -EPERM;
- goto out_dput;
+ goto out_unlock_inode;
}
d_invalidate(dentry);
@@ -2498,6 +2498,7 @@ out_up_write:
root_flags & ~BTRFS_ROOT_SUBVOL_DEAD);
spin_unlock(&dest->root_item_lock);
}
+out_unlock_inode:
mutex_unlock(&inode->i_mutex);
if (!err) {
shrink_dcache_sb(root->fs_info->sb);
--
2.3.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] btrfs: unlock i_mutex after attempting to delete subvolume during send
2015-03-28 11:02 [PATCH] btrfs: unlock i_mutex after attempting to delete subvolume during send Omar Sandoval
@ 2015-03-28 11:37 ` Filipe David Manana
2015-03-30 13:00 ` David Sterba
2015-03-30 12:59 ` David Sterba
1 sibling, 1 reply; 4+ messages in thread
From: Filipe David Manana @ 2015-03-28 11:37 UTC (permalink / raw)
To: Omar Sandoval
Cc: Chris Mason, Josef Bacik, David Sterba, Filipe Manana,
linux-btrfs, linux-kernel
On Sat, Mar 28, 2015 at 11:02 AM, Omar Sandoval <osandov@osandov.com> wrote:
> Whenever the check for a send in progress introduced in commit
> 521e0546c970 (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 #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.
>
> Signed-off-by: Omar Sandoval <osandov@osandov.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Thanks, should go to stable in my opinion.
> ---
> fs/btrfs/ioctl.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index 74609b9..9fde01f 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -2403,7 +2403,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
> "Attempt to delete subvolume %llu during send",
> dest->root_key.objectid);
> err = -EPERM;
> - goto out_dput;
> + goto out_unlock_inode;
> }
>
> d_invalidate(dentry);
> @@ -2498,6 +2498,7 @@ out_up_write:
> root_flags & ~BTRFS_ROOT_SUBVOL_DEAD);
> spin_unlock(&dest->root_item_lock);
> }
> +out_unlock_inode:
> mutex_unlock(&inode->i_mutex);
> if (!err) {
> shrink_dcache_sb(root->fs_info->sb);
> --
> 2.3.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Filipe David Manana,
"Reasonable men adapt themselves to the world.
Unreasonable men adapt the world to themselves.
That's why all progress depends on unreasonable men."
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] btrfs: unlock i_mutex after attempting to delete subvolume during send
2015-03-28 11:02 [PATCH] btrfs: unlock i_mutex after attempting to delete subvolume during send Omar Sandoval
2015-03-28 11:37 ` Filipe David Manana
@ 2015-03-30 12:59 ` David Sterba
1 sibling, 0 replies; 4+ messages in thread
From: David Sterba @ 2015-03-30 12:59 UTC (permalink / raw)
To: Omar Sandoval
Cc: Chris Mason, Josef Bacik, David Sterba, Filipe Manana,
linux-btrfs, linux-kernel
On Sat, Mar 28, 2015 at 04:02:06AM -0700, Omar Sandoval wrote:
> Whenever the check for a send in progress introduced in commit
> 521e0546c970 (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 #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.
>
> Signed-off-by: Omar Sandoval <osandov@osandov.com>
Reviewed-by: David Sterba <dsterba@suse.cz>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] btrfs: unlock i_mutex after attempting to delete subvolume during send
2015-03-28 11:37 ` Filipe David Manana
@ 2015-03-30 13:00 ` David Sterba
0 siblings, 0 replies; 4+ messages in thread
From: David Sterba @ 2015-03-30 13:00 UTC (permalink / raw)
To: Filipe David Manana
Cc: Omar Sandoval, Chris Mason, Josef Bacik, David Sterba,
Filipe Manana, linux-btrfs, linux-kernel
On Sat, Mar 28, 2015 at 11:37:43AM +0000, Filipe David Manana wrote:
> On Sat, Mar 28, 2015 at 11:02 AM, Omar Sandoval <osandov@osandov.com> wrote:
> > Whenever the check for a send in progress introduced in commit
> > 521e0546c970 (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 #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.
> >
> > Signed-off-by: Omar Sandoval <osandov@osandov.com>
> Reviewed-by: Filipe Manana <fdmanana@suse.com>
>
> Thanks, should go to stable in my opinion.
Agreed.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-03-30 13:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-28 11:02 [PATCH] btrfs: unlock i_mutex after attempting to delete subvolume during send Omar Sandoval
2015-03-28 11:37 ` Filipe David Manana
2015-03-30 13:00 ` David Sterba
2015-03-30 12:59 ` David Sterba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®