From: Kent Overstreet Date: Thu, 1 May 2025 02:05:49 +0000 (-0400) Subject: bcachefs: Fix setting ca->name in device add X-Git-Tag: block-6.16-20250606~39^2~115 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=8a6b883e78bfed6909e21c2afb6138b603d1ee6c;p=linux-block.git bcachefs: Fix setting ca->name in device add Device add doesn't get the devide index and attach to the filesystem until after attaching the block device, and setting the device name from the block device name - these needs some minor tweaks. Signed-off-by: Kent Overstreet --- diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c index e89b659514b2..9381644cabee 100644 --- a/fs/bcachefs/super.c +++ b/fs/bcachefs/super.c @@ -1488,7 +1488,9 @@ static void bch2_dev_attach(struct bch_fs *c, struct bch_dev *ca, { ca->dev_idx = dev_idx; __set_bit(ca->dev_idx, ca->self.d); - scnprintf(ca->name, sizeof(ca->name), "dev-%u", dev_idx); + + if (!ca->name[0]) + scnprintf(ca->name, sizeof(ca->name), "dev-%u", dev_idx); ca->fs = c; rcu_assign_pointer(c->devs[ca->dev_idx], ca); @@ -1540,6 +1542,11 @@ static int __bch2_dev_attach_bdev(struct bch_dev *ca, struct bch_sb_handle *sb) if (ret) return ret; + struct printbuf name = PRINTBUF; + prt_bdevname(&name, sb->bdev); + strscpy(ca->name, name.buf, sizeof(ca->name)); + printbuf_exit(&name); + /* Commit: */ ca->disk_sb = *sb; memset(sb, 0, sizeof(*sb)); @@ -1581,11 +1588,6 @@ static int bch2_dev_attach_bdev(struct bch_fs *c, struct bch_sb_handle *sb) bch2_dev_sysfs_online(c, ca); - struct printbuf name = PRINTBUF; - prt_bdevname(&name, ca->disk_sb.bdev); - strscpy(ca->name, name.buf, sizeof(ca->name)); - printbuf_exit(&name); - bch2_rebalance_wakeup(c); return 0; }