Skip to content

Commit e269927

Browse files
author
Kent Overstreet
committed
bcachefs: Fix __bch2_dev_group_set()
bch2_sb_disk_groups_to_cpu() goes off of the superblock member info, so we need to set that first. Reported-by: Stijn Tintel <stijn@linux-ipv6.be> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent e660d7c commit e269927

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

fs/bcachefs/disk_groups.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -470,23 +470,22 @@ void bch2_disk_path_to_text_sb(struct printbuf *out, struct bch_sb *sb, unsigned
470470

471471
int __bch2_dev_group_set(struct bch_fs *c, struct bch_dev *ca, const char *name)
472472
{
473-
struct bch_member *mi;
474-
int ret, v = -1;
473+
lockdep_assert_held(&c->sb_lock);
475474

476-
if (!strlen(name) || !strcmp(name, "none"))
477-
return 0;
478475

479-
v = bch2_disk_path_find_or_create(&c->disk_sb, name);
480-
if (v < 0)
481-
return v;
476+
if (!strlen(name) || !strcmp(name, "none")) {
477+
struct bch_member *mi = bch2_members_v2_get_mut(c->disk_sb.sb, ca->dev_idx);
478+
SET_BCH_MEMBER_GROUP(mi, 0);
479+
} else {
480+
int v = bch2_disk_path_find_or_create(&c->disk_sb, name);
481+
if (v < 0)
482+
return v;
482483

483-
ret = bch2_sb_disk_groups_to_cpu(c);
484-
if (ret)
485-
return ret;
484+
struct bch_member *mi = bch2_members_v2_get_mut(c->disk_sb.sb, ca->dev_idx);
485+
SET_BCH_MEMBER_GROUP(mi, v + 1);
486+
}
486487

487-
mi = bch2_members_v2_get_mut(c->disk_sb.sb, ca->dev_idx);
488-
SET_BCH_MEMBER_GROUP(mi, v + 1);
489-
return 0;
488+
return bch2_sb_disk_groups_to_cpu(c);
490489
}
491490

492491
int bch2_dev_group_set(struct bch_fs *c, struct bch_dev *ca, const char *name)

0 commit comments

Comments
 (0)