diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2017-04-03 19:45:20 -0800 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2017-04-03 19:45:43 -0800 |
commit | 1f24d505224ef4bd06d752c1d56c4e7651f2771a (patch) | |
tree | b1815af5a586a4cc8429d5a81f6ad641704fa045 /cmd_debug.c | |
parent | 2831b89a7c8ba9262a00ec6d70d1355c02f84a67 (diff) |
cmd_dump: fix crash when a device is offline
Diffstat (limited to 'cmd_debug.c')
-rw-r--r-- | cmd_debug.c | 10 |
1 files 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); } |