From: David Sterba <dsterba@suse.cz>
To: Omar Sandoval <osandov@osandov.com>
Cc: Chris Mason <clm@fb.com>, Josef Bacik <jbacik@fb.com>,
"Eric W. Biederman" <ebiederm@xmission.com>,
Timo Kokkonen <timo.kokkonen@offcode.fi>,
linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Btrfs: prevent deletion of mounted subvolumes
Date: Mon, 30 Mar 2015 14:30:34 +0200 [thread overview]
Message-ID: <20150330123034.GB32051@suse.cz> (raw)
In-Reply-To: <64e28e67cbab0a2cd97411b848911414a743d83f.1427705646.git.osandov@osandov.com>
On Mon, Mar 30, 2015 at 02:02:17AM -0700, 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().
> 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?
> + spin_lock(&dentry->d_lock);
> + err = dentry->d_lockref.count > 1 ? -EBUSY : 0;
> + spin_unlock(&dentry->d_lock);
The fix restores the original behaviour, but I don't think opencoding and
using internals is fine. Either there should be a vfs api for that or
there's an existing one that can be used instead.
The bug here seems defined up to the point that we're trying to delete a
subvolume that's a mountpoint. My next guess is that a check
if (d_mountpoint(&dentry)) { ... }
could work.
next prev parent reply other threads:[~2015-03-30 12:30 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
2015-03-30 12:30 ` David Sterba [this message]
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=20150330123034.GB32051@suse.cz \
--to=dsterba@suse.cz \
--cc=clm@fb.com \
--cc=ebiederm@xmission.com \
--cc=jbacik@fb.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=osandov@osandov.com \
--cc=timo.kokkonen@offcode.fi \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).