diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2022-08-18 23:57:24 +0200 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 23:09:39 +0200 |
commit | 02afcb8c26b14ae317754d8c79339f41b3dfeaae (patch) | |
tree | 00ece659f7a8ee8aa78d5f9c787dca6c1630fd33 /fs/bcachefs/disk_groups.c | |
parent | bcachefs: fsck: Another transaction restart handling fix (diff) | |
download | linux-02afcb8c26b14ae317754d8c79339f41b3dfeaae.tar.xz linux-02afcb8c26b14ae317754d8c79339f41b3dfeaae.zip |
bcachefs: Fix adding a device with a label
Device labels are represented as pointers in the member info section: we
need to get and then set the label for it to be kept correctly.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/disk_groups.c')
-rw-r--r-- | fs/bcachefs/disk_groups.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/fs/bcachefs/disk_groups.c b/fs/bcachefs/disk_groups.c index 33d2702e6849..5f405d38b3de 100644 --- a/fs/bcachefs/disk_groups.c +++ b/fs/bcachefs/disk_groups.c @@ -384,32 +384,34 @@ inval: prt_printf(out, "invalid label %u", v); } -int bch2_dev_group_set(struct bch_fs *c, struct bch_dev *ca, const char *name) +int __bch2_dev_group_set(struct bch_fs *c, struct bch_dev *ca, const char *name) { struct bch_member *mi; - int v = -1; - int ret = 0; - - mutex_lock(&c->sb_lock); + int ret, v = -1; if (!strlen(name) || !strcmp(name, "none")) - goto write_sb; + return 0; v = bch2_disk_path_find_or_create(&c->disk_sb, name); - if (v < 0) { - mutex_unlock(&c->sb_lock); + if (v < 0) return v; - } ret = bch2_sb_disk_groups_to_cpu(c); if (ret) - goto unlock; -write_sb: + return ret; + mi = &bch2_sb_get_members(c->disk_sb.sb)->members[ca->dev_idx]; SET_BCH_MEMBER_GROUP(mi, v + 1); + return 0; +} - bch2_write_super(c); -unlock: +int bch2_dev_group_set(struct bch_fs *c, struct bch_dev *ca, const char *name) +{ + int ret; + + mutex_lock(&c->sb_lock); + ret = __bch2_dev_group_set(c, ca, name) ?: + bch2_write_super(c); mutex_unlock(&c->sb_lock); return ret; |