bcachefs: preserve device path as device name
authorBrian Foster <bfoster@redhat.com>
Thu, 16 Nov 2023 17:13:43 +0000 (12:13 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Fri, 24 Nov 2023 07:42:07 +0000 (02:42 -0500)
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>
fs/bcachefs/fs.c
fs/bcachefs/super-io.c
fs/bcachefs/super_types.h

index 8ef817304e4a2eed0a70a6e5f38e62683e22705e..4d51be813509891458735d494b44e36c043035c6 100644 (file)
@@ -1667,8 +1667,7 @@ static int bch2_show_devname(struct seq_file *seq, struct dentry *root)
                if (!first)
                        seq_putc(seq, ':');
                first = false;
-               seq_puts(seq, "/dev/");
-               seq_puts(seq, ca->name);
+               seq_puts(seq, ca->disk_sb.sb_name);
        }
 
        return 0;
index f4cad903f4d69da7776825f50bf561a1980a02a0..f3e12f7979d5ea65c2bd51b56da8392c2953bcde 100644 (file)
@@ -166,6 +166,7 @@ void bch2_free_super(struct bch_sb_handle *sb)
        if (!IS_ERR_OR_NULL(sb->bdev))
                blkdev_put(sb->bdev, sb->holder);
        kfree(sb->holder);
+       kfree(sb->sb_name);
 
        kfree(sb->sb);
        memset(sb, 0, sizeof(*sb));
@@ -675,6 +676,10 @@ retry:
        if (!sb->holder)
                return -ENOMEM;
 
+       sb->sb_name = kstrdup(path, GFP_KERNEL);
+       if (!sb->sb_name)
+               return -ENOMEM;
+
 #ifndef __KERNEL__
        if (opt_get(*opts, direct_io) == false)
                sb->mode |= BLK_OPEN_BUFFERED;
index 7dda4985b99fe6cfdde52c6df869e3df446d48d0..9c1fd4ca2b103478c9d943a2063f64825b8550cb 100644 (file)
@@ -5,6 +5,7 @@
 struct bch_sb_handle {
        struct bch_sb           *sb;
        struct block_device     *bdev;
+       char                    *sb_name;
        struct bio              *bio;
        void                    *holder;
        size_t                  buffer_size;