Commit 63807d95 authored by Brian Foster's avatar Brian Foster Committed by Kent Overstreet
Browse files

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: default avatarBrian Foster <bfoster@redhat.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 0a11adfb
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -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;
+5 −0
Original line number Diff line number Diff line
@@ -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 @@ int bch2_read_super(const char *path, struct bch_opts *opts,
	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;
+1 −0
Original line number Diff line number Diff line
@@ -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;