Skip to content

Commit f50a0ab

Browse files
josefbacikgregkh
authored andcommitted
btrfs: don't show full path of bind mounts in subvol=
[ Upstream commit 3ef3959 ] 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 <chris@colorremedies.com> CC: stable@vger.kernel.org # 4.4+ Signed-off-by: Josef Bacik <josef@toxicpanda.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent dd39b6f commit f50a0ab

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

fs/btrfs/super.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,6 +1282,7 @@ static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry)
12821282
{
12831283
struct btrfs_fs_info *info = btrfs_sb(dentry->d_sb);
12841284
const char *compress_type;
1285+
const char *subvol_name;
12851286

12861287
if (btrfs_test_opt(info, DEGRADED))
12871288
seq_puts(seq, ",degraded");
@@ -1366,8 +1367,13 @@ static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry)
13661367
seq_puts(seq, ",ref_verify");
13671368
seq_printf(seq, ",subvolid=%llu",
13681369
BTRFS_I(d_inode(dentry))->root->root_key.objectid);
1369-
seq_puts(seq, ",subvol=");
1370-
seq_dentry(seq, dentry, " \t\n\\");
1370+
subvol_name = btrfs_get_subvol_name_from_objectid(info,
1371+
BTRFS_I(d_inode(dentry))->root->root_key.objectid);
1372+
if (!IS_ERR(subvol_name)) {
1373+
seq_puts(seq, ",subvol=");
1374+
seq_escape(seq, subvol_name, " \t\n\\");
1375+
kfree(subvol_name);
1376+
}
13711377
return 0;
13721378
}
13731379

0 commit comments

Comments
 (0)