Skip to content

Commit af5b886

Browse files
author
Kent Overstreet
committed
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 <[email protected]>
1 parent b76cce1 commit af5b886

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

fs/bcachefs/super.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1995,6 +1995,22 @@ int bch2_dev_add(struct bch_fs *c, const char *path)
19951995
goto err_late;
19961996
}
19971997

1998+
/*
1999+
* We just changed the superblock UUID, invalidate cache and send a
2000+
* uevent to update /dev/disk/by-uuid
2001+
*/
2002+
invalidate_bdev(ca->disk_sb.bdev);
2003+
2004+
char uuid_str[37];
2005+
snprintf(uuid_str, sizeof(uuid_str), "UUID=%pUb", &c->sb.uuid);
2006+
2007+
char *envp[] = {
2008+
"CHANGE=uuid",
2009+
uuid_str,
2010+
NULL,
2011+
};
2012+
kobject_uevent_env(&ca->disk_sb.bdev->bd_device.kobj, KOBJ_CHANGE, envp);
2013+
19982014
up_write(&c->state_lock);
19992015
out:
20002016
printbuf_exit(&label);

0 commit comments

Comments
 (0)