From: Timo Kokkonen <timo.kokkonen@offcode.fi>
To: Omar Sandoval <osandov@osandov.com>, Chris Mason <clm@fb.com>,
Josef Bacik <jbacik@fb.com>, David Sterba <dsterba@suse.cz>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>,
linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Btrfs: prevent deletion of mounted subvolumes
Date: Mon, 30 Mar 2015 12:30:11 +0300 [thread overview]
Message-ID: <551917A3.3080203@offcode.fi> (raw)
In-Reply-To: <64e28e67cbab0a2cd97411b848911414a743d83f.1427705646.git.osandov@osandov.com>
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@offcode.fi>
> Fixes: bafc9b754f75 ("vfs: More precise tests in d_invalidate")
> Signed-off-by: Omar Sandoval <osandov@osandov.com>
Tested-by: Timo Kokkonen <timo.kokkonen@offcode.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);
>
> /*
>
next prev parent reply other threads:[~2015-03-30 9:35 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-30 9:02 [PATCH] Btrfs: prevent deletion of mounted subvolumes Omar Sandoval
2015-03-30 9:30 ` Timo Kokkonen [this message]
2015-03-30 12:30 ` David Sterba
2015-03-30 18:41 ` Omar Sandoval
2015-04-01 3:54 ` Eric W. Biederman
2015-04-01 7:03 ` Omar Sandoval
2015-04-01 7:27 ` Timo Kokkonen
2015-04-01 11:22 ` David Sterba
2015-04-02 3:49 ` Omar Sandoval
2015-04-02 15:02 ` David Sterba
2015-04-03 21:08 ` Omar Sandoval
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=551917A3.3080203@offcode.fi \
--to=timo.kokkonen@offcode.fi \
--cc=clm@fb.com \
--cc=dsterba@suse.cz \
--cc=ebiederm@xmission.com \
--cc=jbacik@fb.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=osandov@osandov.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.