summaryrefslogtreecommitdiff
path: root/fs/bcachefs/disk_groups.c
diff options
context:
space:
mode:
authorBrian Foster <bfoster@redhat.com>2023-05-30 14:41:50 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:10:03 -0400
commitfec4fc82b531beb2cc67b734140ffe776af33f7c (patch)
tree69eb17cf9b842e4ae2071a30a9ccc8c1d9afb7b9 /fs/bcachefs/disk_groups.c
parent28551613b725c28552210121499f4e2f6c6a9054 (diff)
bcachefs: create internal disk_groups sysfs file
We have bch2_sb_disk_groups_to_text() to dump disk group labels, but no good information on device group membership at runtime. Add bch2_disk_groups_to_text() and an associated 'disk_groups' sysfs file to print group and device relationships. Signed-off-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/disk_groups.c')
-rw-r--r--fs/bcachefs/disk_groups.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/fs/bcachefs/disk_groups.c b/fs/bcachefs/disk_groups.c
index 1a8f8b3750da..aa3a4e5a8b2e 100644
--- a/fs/bcachefs/disk_groups.c
+++ b/fs/bcachefs/disk_groups.c
@@ -87,6 +87,40 @@ err:
return ret;
}
+void bch2_disk_groups_to_text(struct printbuf *out, struct bch_fs *c)
+{
+ struct bch_disk_groups_cpu *g;
+ struct bch_dev *ca;
+ int i;
+ unsigned iter;
+
+ out->atomic++;
+ rcu_read_lock();
+
+ g = rcu_dereference(c->disk_groups);
+ if (!g)
+ goto out;
+
+ for (i = 0; i < g->nr; i++) {
+ if (i)
+ prt_printf(out, " ");
+
+ if (g->entries[i].deleted) {
+ prt_printf(out, "[deleted]");
+ continue;
+ }
+
+ prt_printf(out, "[parent %d devs", g->entries[i].parent);
+ for_each_member_device_rcu(ca, c, iter, &g->entries[i].devs)
+ prt_printf(out, " %s", ca->name);
+ prt_printf(out, "]");
+ }
+
+out:
+ rcu_read_unlock();
+ out->atomic--;
+}
+
static void bch2_sb_disk_groups_to_text(struct printbuf *out,
struct bch_sb *sb,
struct bch_sb_field *f)