aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2025-06-07 12:01:22 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2025-06-11 23:21:30 -0400
commitaf5b88618a38371545251ad92ce42bc4bfa1142a (patch)
treecab03f293c6c24662e8550b9bf4b185a90615ba4
parentbcachefs: Add more flags to btree nodes for rewrite reason (diff)
downloadwireguard-linux-af5b88618a38371545251ad92ce42bc4bfa1142a.tar.xz
wireguard-linux-af5b88618a38371545251ad92ce42bc4bfa1142a.zip
bcachefs: Update /dev/disk/by-uuid on device add
Invalidate pagecache after we write the new superblock and send a uevent. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r--fs/bcachefs/super.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c
index 397a69da5a75..8648f22411be 100644
--- a/fs/bcachefs/super.c
+++ b/fs/bcachefs/super.c
@@ -1995,6 +1995,22 @@ int bch2_dev_add(struct bch_fs *c, const char *path)
goto err_late;
}
+ /*
+ * We just changed the superblock UUID, invalidate cache and send a
+ * uevent to update /dev/disk/by-uuid
+ */
+ invalidate_bdev(ca->disk_sb.bdev);
+
+ char uuid_str[37];
+ snprintf(uuid_str, sizeof(uuid_str), "UUID=%pUb", &c->sb.uuid);
+
+ char *envp[] = {
+ "CHANGE=uuid",
+ uuid_str,
+ NULL,
+ };
+ kobject_uevent_env(&ca->disk_sb.bdev->bd_device.kobj, KOBJ_CHANGE, envp);
+
up_write(&c->state_lock);
out:
printbuf_exit(&label);