Skip to content

Commit 3ef3959

Browse files
josefbacikkdave
authored andcommitted
btrfs: don't show full path of bind mounts in subvol=
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/sda /mnt/test btrfs rw,relatime,subvolid=256,subvol=/foo 0 0 /dev/sda /mnt/test/baz btrfs rw,relatime,subvolid=256,subvol=/foo/bar 0 0 Despite subvolid=256 being subvol=/foo. 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. With this fix the same test looks like this /dev/sda /mnt/test btrfs rw,relatime,subvolid=256,subvol=/foo 0 0 /dev/sda /mnt/test/baz btrfs rw,relatime,subvolid=256,subvol=/foo 0 0 Reported-by: Chris Murphy <[email protected]> CC: [email protected] # 4.4+ Signed-off-by: Josef Bacik <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 27942c9 commit 3ef3959

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

fs/btrfs/super.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,6 +1386,7 @@ static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry)
13861386
{
13871387
struct btrfs_fs_info *info = btrfs_sb(dentry->d_sb);
13881388
const char *compress_type;
1389+
const char *subvol_name;
13891390

13901391
if (btrfs_test_opt(info, DEGRADED))
13911392
seq_puts(seq, ",degraded");
@@ -1472,8 +1473,13 @@ static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry)
14721473
seq_puts(seq, ",ref_verify");
14731474
seq_printf(seq, ",subvolid=%llu",
14741475
BTRFS_I(d_inode(dentry))->root->root_key.objectid);
1475-
seq_puts(seq, ",subvol=");
1476-
seq_dentry(seq, dentry, " \t\n\\");
1476+
subvol_name = btrfs_get_subvol_name_from_objectid(info,
1477+
BTRFS_I(d_inode(dentry))->root->root_key.objectid);
1478+
if (!IS_ERR(subvol_name)) {
1479+
seq_puts(seq, ",subvol=");
1480+
seq_escape(seq, subvol_name, " \t\n\\");
1481+
kfree(subvol_name);
1482+
}
14771483
return 0;
14781484
}
14791485

0 commit comments

Comments
 (0)