Skip to content

Commit 63807d9

Browse files
Brian FosterKent Overstreet
authored andcommitted
bcachefs: preserve device path as device name
Various userspace scripts/tools may expect mount entries in /proc/mounts to reflect the device path names used to mount the associated filesystem. bcachefs seems to normalize the device path to the underlying device name based on the block device. This confuses tools like fstests when the test devices might be lvm or device-mapper based. The default behavior for show_vfsmnt() appers to be to use the string passed to alloc_vfsmnt(), so tweak bcachefs to copy the path at device superblock read time and to display it via ->show_devname(). Signed-off-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent 0a11adf commit 63807d9

3 files changed

Lines changed: 7 additions & 2 deletions

File tree

fs/bcachefs/fs.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1667,8 +1667,7 @@ static int bch2_show_devname(struct seq_file *seq, struct dentry *root)
16671667
if (!first)
16681668
seq_putc(seq, ':');
16691669
first = false;
1670-
seq_puts(seq, "/dev/");
1671-
seq_puts(seq, ca->name);
1670+
seq_puts(seq, ca->disk_sb.sb_name);
16721671
}
16731672

16741673
return 0;

fs/bcachefs/super-io.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ void bch2_free_super(struct bch_sb_handle *sb)
166166
if (!IS_ERR_OR_NULL(sb->bdev))
167167
blkdev_put(sb->bdev, sb->holder);
168168
kfree(sb->holder);
169+
kfree(sb->sb_name);
169170

170171
kfree(sb->sb);
171172
memset(sb, 0, sizeof(*sb));
@@ -675,6 +676,10 @@ int bch2_read_super(const char *path, struct bch_opts *opts,
675676
if (!sb->holder)
676677
return -ENOMEM;
677678

679+
sb->sb_name = kstrdup(path, GFP_KERNEL);
680+
if (!sb->sb_name)
681+
return -ENOMEM;
682+
678683
#ifndef __KERNEL__
679684
if (opt_get(*opts, direct_io) == false)
680685
sb->mode |= BLK_OPEN_BUFFERED;

fs/bcachefs/super_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
struct bch_sb_handle {
66
struct bch_sb *sb;
77
struct block_device *bdev;
8+
char *sb_name;
89
struct bio *bio;
910
void *holder;
1011
size_t buffer_size;

0 commit comments

Comments
 (0)