Skip to contentSkip to conversation

bcachefs: allow passing full device path for target options

PATCH Applied Thomas Bertschinger 2 participants 2 messages May 25, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bcachefs: allow passing full device path for target options

The output of mount options such as "metadata_target" in /proc/mounts uses the full path to the device.

mount(8) from util-linux uses the output from /proc/mounts to pass existing mount options when performing a remount, so bcachefs should accept as input the same form that it prints as output.

Without this change:

$ mount -t bcachefs -o metadata_target=vdb /dev/vdb /mnt
$ strace mount -o remount /mnt
...
fsconfig(4, FSCONFIG_SET_STRING, "metadata_target", "/dev/vdb", 0) = -1 EINVAL (Invalid argument)
...
---
 fs/bcachefs/super.c | 3 +++
 1 file changed, 3 insertions(+)
fs/bcachefs/super.c +3 -0
index 2206a8dee693..864c216346a5 100644
@@ -2029,6 +2029,9 @@ int bch2_dev_resize(struct bch_fs *c, struct bch_dev *ca, u64 nbuckets)
 /* return with ref on ca->ref: */
 struct bch_dev *bch2_dev_lookup(struct bch_fs *c, const char *name)
 {
+	if (!strncmp(name, "/dev/", strlen("/dev/")))
+		name += strlen("/dev/");
+
 	for_each_member_device(c, ca)
 		if (!strcmp(name, ca->name))
 			return ca;
Signature · 1 line
2.45.0
#1 lore raw
Quoted 9 lines · Thomas Bertschinger

The output of mount options such as "metadata_target" in /proc/mounts uses the full path to the device.

mount(8) from util-linux uses the output from /proc/mounts to pass existing mount options when performing a remount, so bcachefs should accept as input the same form that it prints as output.

Without this change:

Quoted 7 lines
$ mount -t bcachefs -o metadata_target=vdb /dev/vdb /mnt
$ strace mount -o remount /mnt
...
fsconfig(4, FSCONFIG_SET_STRING, "metadata_target", "/dev/vdb", 0) = -1 EINVAL (Invalid argument)
...

Applied