All of lore.kernel.org
 help / color / mirror / Atom feed
From: Omar Sandoval <osandov@osandov.com>
To: David Sterba <dsterba@suse.cz>,
	Qu Wenruo <quwenruo@cn.fujitsu.com>,
	linux-btrfs@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 0/6] Btrfs: show subvolume name and ID in /proc/mounts
Date: Mon, 11 May 2015 02:42:58 -0700	[thread overview]
Message-ID: <20150511094258.GA18249@mew> (raw)
In-Reply-To: <cover.1428614837.git.osandov@osandov.com>

On Thu, Apr 09, 2015 at 02:34:50PM -0700, Omar Sandoval wrote:
> Here's version 2 of providing the subvolume name and ID in /proc/mounts.
> 
> It turns out that getting the name of a subvolume reliably is a bit
> trickier than it would seem because of how mounting subvolumes by ID is
> implemented. In particular, in that case, the dentry we get for the root
> of the mount is not necessarily attached to the dentry tree, which means
> that the obvious solution of just dumping the dentry does not work. The
> solution I put together makes the tradeoff of churning a bit more code
> in order to avoid implementing this with weird hacks.
> 
> Changes from v1 (https://lkml.org/lkml/2015/4/8/16):
> 
> - Put subvol= last in show_options
> - Change commit log to remove comment about userspace having no way to
>   know which subvolume is mounted, as David pointed out you can use
>   btrfs inspect-internal rootid <mountpoint>
> - Split up patch 2
> - Minor coding style fixes
> 
> This still applies to v4.0-rc7. Tested manually and with the script
> below (updated from v1).
> 
> Thanks!
> 
> Omar Sandoval (6):
>   Btrfs: lock superblock before remounting for rw subvol
>   Btrfs: remove all subvol options before mounting top-level
>   Btrfs: clean up error handling in mount_subvol()
>   Btrfs: fail on mismatched subvol and subvolid mount options
>   Btrfs: unify subvol= and subvolid= mounting
>   Btrfs: show subvol= and subvolid= in /proc/mounts
> 
>  fs/btrfs/super.c | 376 ++++++++++++++++++++++++++++++++++++-------------------
>  fs/seq_file.c    |   1 +
>  2 files changed, 251 insertions(+), 126 deletions(-)
> 

Hi, everyone,

Just wanted to revive this so we can hopefully come up with a solution
we agree on in time for 4.2.

Just to recap, my approach (and also Qu Wenruo's original approach) is
to convert subvolid= mounts to subvol= mounts at mount time, which makes
showing the subvolume in /proc/mounts easy. The benefit of this approach
is that looking at mount information, which is supposed to be a
lightweight operation, is simple and always works. Additionally, we'll
have the info in a convenient format in /proc/mounts in addition to
/proc/$PID/mountinfo. The only caveat is that a mount by subvolid can
fail if the mount races with a rename of the subvolume.

Qu Wenruo's second approach was to instead convert the subvolid to a
subvolume path when reading /proc/$PID/mountinfo. The benefit of this
approach is that mounts by subvolid will always succeed in the face of
concurrent renames. However, instead, getting the subvolume path in
mountinfo can now fail, and it makes what should probably be a
lightweight operation somewhat complex.

In terms of the code, I think the original approach is cleaner: the
heavy lifting is done when mounting instead of when reading a proc file.
Additionally, I don't think that the concurrent rename race will be much
of a problem in practice. I can't imagine that too many people are
actively renaming subvolumes at the same time as they are mounting them,
and even if they are, I don't think it's so surprising that it would
fail. On the other hand, reading mount info while renaming subvolumes
might be marginally more common, and personally, if that failed, I'd be
unpleasantly surprised.

Orthogonal to that decision is the precedence of subvolid= and subvol=.
Although it's true that mount options usually have last-one-wins
behavior, I think David's argument regarding the principle of least
surprise is solid. Namely, someone's going to be unhappy with a
seemingly arbitrary decision when they don't match.

Sorry for the long-winded email! Thoughts, David, Qu?

Thanks,
-- 
Omar

  parent reply	other threads:[~2015-05-11  9:43 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-09 21:34 [PATCH v2 0/6] Btrfs: show subvolume name and ID in /proc/mounts Omar Sandoval
2015-04-09 21:34 ` [PATCH v2 1/6] Btrfs: lock superblock before remounting for rw subvol Omar Sandoval
2015-05-11 16:07   ` David Sterba
2015-04-09 21:34 ` [PATCH v2 2/6] Btrfs: remove all subvol options before mounting top-level Omar Sandoval
2015-05-11 16:08   ` David Sterba
2015-04-09 21:34 ` [PATCH v2 3/6] Btrfs: clean up error handling in mount_subvol() Omar Sandoval
2015-05-11 16:08   ` David Sterba
2015-04-09 21:34 ` [PATCH v2 4/6] Btrfs: fail on mismatched subvol and subvolid mount options Omar Sandoval
2015-04-10  0:39   ` Qu Wenruo
2015-04-14 15:07     ` David Sterba
2015-05-11 16:09   ` David Sterba
2015-04-09 21:34 ` [PATCH v2 5/6] Btrfs: unify subvol= and subvolid= mounting Omar Sandoval
2015-05-11 15:37   ` David Sterba
2015-05-11 21:15     ` Omar Sandoval
2015-05-11 16:10   ` David Sterba
2015-04-09 21:34 ` [PATCH v2 6/6] Btrfs: show subvol= and subvolid= in /proc/mounts Omar Sandoval
2015-05-11 16:10   ` David Sterba
2015-05-11  9:42 ` Omar Sandoval [this message]
2015-05-11 14:51   ` [PATCH v2 0/6] Btrfs: show subvolume name and ID " David Sterba
2015-05-11 21:20     ` Omar Sandoval
2015-05-12  0:46   ` Qu Wenruo

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=20150511094258.GA18249@mew \
    --to=osandov@osandov.com \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=quwenruo@cn.fujitsu.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.