diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2025-05-01 05:05:49 +0300 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2025-05-22 03:14:39 +0300 |
commit | 8a6b883e78bfed6909e21c2afb6138b603d1ee6c (patch) | |
tree | 95df57ba06bb6359979d249d3d12e8ec60b5fd9f | |
parent | 5ce11d9d1bd5dfd8876d35bd9e61f38f47807c42 (diff) | |
download | linux-8a6b883e78bfed6909e21c2afb6138b603d1ee6c.tar.xz |
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 <kent.overstreet@linux.dev>
-rw-r--r-- | fs/bcachefs/super.c | 14 |
1 files changed, 8 insertions, 6 deletions
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; } |