From: Josef Bacik <josef@toxicpanda.com>
To: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Cc: Chris Murphy <chris@colorremedies.com>
Subject: [PATCH][RFC] btrfs: don't show full path of bind mounts in subvol=
Date: Tue, 21 Jul 2020 14:16:56 -0400 [thread overview]
Message-ID: <20200721181656.16171-1-josef@toxicpanda.com> (raw)
Chris Murphy reported a problem where rpm ostree will bind mount a bunch
of things for whatever voodoo it's doing. But when it does this
/proc/mounts shows something like
/dev/vda4 on /usr type btrfs (ro,relatime,seclabel,space_cache,subvolid=256,subvol=/root/ostree/deploy/fedora/deploy/610b0f9be3141c79f19a65800f89746c70183cc7f14f3cfba29d695d49128075.0/usr)
Despite subvolid=256 being subvol=/root. This is because we're just
spitting out the dentry of the mount point, which in the case of bind
mounts is the source path for the mountpoint. Instead we should spit
out the path to the actual subvol. Fix this by looking up the name for
the subvolid we have mounted.
Fixes: c8d3fe028f64 ("Btrfs: show subvol= and subvolid= in /proc/mounts")
Reported-by: Chris Murphy <chris@colorremedies.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
I talked with Omar about this and his other suggestion is we simply don't spit
out subvol=<path> if we're not the actual subvolume dentry. I'm ok with that
option too, and it avoids a memory alloc for show_options, however it does mean
that we'll stop spitting out subvol= in some cases, which may cause problems?
If we prefer that option I can code that up instead.
fs/btrfs/super.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 58f890f73650..0e1647c08610 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1367,6 +1367,7 @@ static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry)
{
struct btrfs_fs_info *info = btrfs_sb(dentry->d_sb);
const char *compress_type;
+ const char *subvol_name;
if (btrfs_test_opt(info, DEGRADED))
seq_puts(seq, ",degraded");
@@ -1453,8 +1454,12 @@ static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry)
seq_puts(seq, ",ref_verify");
seq_printf(seq, ",subvolid=%llu",
BTRFS_I(d_inode(dentry))->root->root_key.objectid);
- seq_puts(seq, ",subvol=");
- seq_dentry(seq, dentry, " \t\n\\");
+ subvol_name = btrfs_get_subvol_name_from_objectid(info,
+ BTRFS_I(d_inode(dentry))->root->root_key.objectid);
+ if (subvol_name) {
+ seq_printf(seq, ",subvol=%s", subvol_name);
+ kfree(subvol_name);
+ }
return 0;
}
--
2.24.1
next reply other threads:[~2020-07-21 18:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-21 18:16 Josef Bacik [this message]
2020-07-22 14:46 ` [PATCH][RFC] btrfs: don't show full path of bind mounts in subvol= Johannes Thumshirn
2020-07-22 15:36 ` David Sterba
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=20200721181656.16171-1-josef@toxicpanda.com \
--to=josef@toxicpanda.com \
--cc=chris@colorremedies.com \
--cc=kernel-team@fb.com \
--cc=linux-btrfs@vger.kernel.org \
/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