[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <551917A3.3080203@offcode.fi>
Date: Mon, 30 Mar 2015 12:30:11 +0300
From: Timo Kokkonen <timo.kokkonen@...code.fi>
To: Omar Sandoval <osandov@...ndov.com>, Chris Mason <clm@...com>,
Josef Bacik <jbacik@...com>, David Sterba <dsterba@...e.cz>
CC: "Eric W. Biederman" <ebiederm@...ssion.com>,
linux-btrfs@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] Btrfs: prevent deletion of mounted subvolumes
On 30.03.2015 12:02, Omar Sandoval wrote:
> Before commit bafc9b754f75 ("vfs: More precise tests in d_invalidate"),
> d_invalidate() could return -EBUSY when a dentry for a directory had
> more than one reference to it. This is what prevented a mounted
> subvolume from being deleted, as struct vfsmount holds a reference to
> the subvolume dentry. However, that commit removed that case, and later
> commits in that patch series removed the return code from d_invalidate()
> completely, so we don't get that check for free anymore. So, reintroduce
> it in btrfs_ioctl_snap_destroy().
>
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=93021
> Reported-by: Timo Kokkonen <timo.kokkonen@...code.fi>
> Fixes: bafc9b754f75 ("vfs: More precise tests in d_invalidate")
> Signed-off-by: Omar Sandoval <osandov@...ndov.com>
Tested-by: Timo Kokkonen <timo.kokkonen@...code.fi>
Thank you
-Timo
> ---
> This applies to 4.0-rc6. To be honest, I'm not sure that this is the most
> correct fix for this bug, but it's equivalent to the pre-3.18 behavior and it's
> the best that I could come up with. Thoughts?
>
> fs/btrfs/ioctl.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index 74609b9..39b0538 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -2384,6 +2384,12 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
> goto out_dput;
> }
>
> + spin_lock(&dentry->d_lock);
> + err = dentry->d_lockref.count > 1 ? -EBUSY : 0;
> + spin_unlock(&dentry->d_lock);
> + if (err)
> + goto out_dput;
> +
> mutex_lock(&inode->i_mutex);
>
> /*
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists