From 1f24d505224ef4bd06d752c1d56c4e7651f2771a Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Mon, 3 Apr 2017 19:45:20 -0800 Subject: [PATCH] cmd_dump: fix crash when a device is offline --- cmd_debug.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd_debug.c b/cmd_debug.c index 02f4b49d..64f7f379 100644 --- a/cmd_debug.c +++ b/cmd_debug.c @@ -86,6 +86,7 @@ int cmd_dump(int argc, char *argv[]) { struct bch_opts opts = bch2_opts_empty(); struct bch_fs *c = NULL; + struct bch_dev *ca; const char *err; char *out = NULL; unsigned i, nr_devices = 0; @@ -121,13 +122,12 @@ int cmd_dump(int argc, char *argv[]) down_read(&c->gc_lock); - for (i = 0; i < c->sb.nr_devices; i++) - if (c->devs[i]) - nr_devices++; + for_each_online_member(ca, c, i) + nr_devices++; BUG_ON(!nr_devices); - for (i = 0; i < c->sb.nr_devices; i++) { + for_each_online_member(ca, c, i) { int mode = O_WRONLY|O_CREAT|O_TRUNC; if (!force) @@ -142,7 +142,7 @@ int cmd_dump(int argc, char *argv[]) fd = xopen(path, mode, 0600); free(path); - dump_one_device(c, c->devs[i], fd); + dump_one_device(c, ca, fd); close(fd); }