mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-02-23 00:00:02 +03:00
cmd_dump: fix crash when a device is offline
This commit is contained in:
parent
2831b89a7c
commit
1f24d50522
10
cmd_debug.c
10
cmd_debug.c
@ -86,6 +86,7 @@ int cmd_dump(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
struct bch_opts opts = bch2_opts_empty();
|
struct bch_opts opts = bch2_opts_empty();
|
||||||
struct bch_fs *c = NULL;
|
struct bch_fs *c = NULL;
|
||||||
|
struct bch_dev *ca;
|
||||||
const char *err;
|
const char *err;
|
||||||
char *out = NULL;
|
char *out = NULL;
|
||||||
unsigned i, nr_devices = 0;
|
unsigned i, nr_devices = 0;
|
||||||
@ -121,13 +122,12 @@ int cmd_dump(int argc, char *argv[])
|
|||||||
|
|
||||||
down_read(&c->gc_lock);
|
down_read(&c->gc_lock);
|
||||||
|
|
||||||
for (i = 0; i < c->sb.nr_devices; i++)
|
for_each_online_member(ca, c, i)
|
||||||
if (c->devs[i])
|
nr_devices++;
|
||||||
nr_devices++;
|
|
||||||
|
|
||||||
BUG_ON(!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;
|
int mode = O_WRONLY|O_CREAT|O_TRUNC;
|
||||||
|
|
||||||
if (!force)
|
if (!force)
|
||||||
@ -142,7 +142,7 @@ int cmd_dump(int argc, char *argv[])
|
|||||||
fd = xopen(path, mode, 0600);
|
fd = xopen(path, mode, 0600);
|
||||||
free(path);
|
free(path);
|
||||||
|
|
||||||
dump_one_device(c, c->devs[i], fd);
|
dump_one_device(c, ca, fd);
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user