cmd_fsck can now take colon separated devices

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2023-12-22 21:29:36 -05:00
parent 5134a64ceb
commit ca4892af17
6 changed files with 27 additions and 14 deletions

View File

@ -59,7 +59,6 @@ static void dump_one_device(struct bch_fs *c, struct bch_dev *ca, int fd,
/* Btree: */
for (i = 0; i < BTREE_ID_NR; i++) {
const struct bch_extent_ptr *ptr;
struct bkey_ptrs_c ptrs;
struct btree_trans *trans = bch2_trans_get(c);
struct btree_iter iter;

View File

@ -90,7 +90,6 @@ int cmd_fsck(int argc, char *argv[])
{ NULL }
};
struct bch_opts opts = bch2_opts_empty();
unsigned i;
int opt, ret = 0;
opt_set(opts, degraded, true);
@ -138,15 +137,15 @@ int cmd_fsck(int argc, char *argv[])
exit(8);
}
for (i = 0; i < argc; i++)
if (dev_mounted(argv[i]))
return fsck_online(argv[i]);
darray_str devs = get_or_split_cmdline_devs(argc, argv);
struct bch_fs *c = bch2_fs_open(argv, argc, opts);
if (IS_ERR(c)) {
fprintf(stderr, "error opening %s: %s\n", argv[0], bch2_err_str(PTR_ERR(c)));
darray_for_each(devs, i)
if (dev_mounted(*i))
return fsck_online(*i);
struct bch_fs *c = bch2_fs_open(devs.data, devs.nr, opts);
if (IS_ERR(c))
exit(8);
}
if (test_bit(BCH_FS_errors_fixed, &c->flags)) {
fprintf(stderr, "%s: errors fixed\n", c->name);

View File

@ -79,15 +79,12 @@ int cmd_kill_btree_node(int argc, char *argv[])
continue;
if (!node_index) {
struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(bkey_i_to_s_c(&b->key));
const struct bch_extent_ptr *ptr;
struct printbuf buf = PRINTBUF;
bch2_bkey_val_to_text(&buf, c, bkey_i_to_s_c(&b->key));
bch_info(c, "killing btree node %s", buf.buf);
printbuf_exit(&buf);
struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(bkey_i_to_s_c(&b->key));
bkey_for_each_ptr(ptrs, ptr) {
struct bch_dev *ca = bch_dev_bkey_exists(c, ptr->dev);

View File

@ -263,7 +263,9 @@ int cmd_list_journal(int argc, char *argv[])
if (!argc)
die("Please supply device(s) to open");
struct bch_fs *c = bch2_fs_open(argv, argc, opts);
darray_str devs = get_or_split_cmdline_devs(argc, argv);
struct bch_fs *c = bch2_fs_open(devs.data, devs.nr, opts);
if (IS_ERR(c))
die("error opening %s: %s", argv[0], bch2_err_str(PTR_ERR(c)));

View File

@ -650,3 +650,17 @@ struct bbpos bbpos_parse(char *buf)
ret.pos = bpos_parse(s);
return ret;
}
darray_str get_or_split_cmdline_devs(int argc, char *argv[])
{
darray_str ret = {};
if (argc == 1) {
bch2_split_devs(argv[0], &ret);
} else {
for (unsigned i = 0; i < argc; i++)
darray_push(&ret, strdup(argv[i]));
}
return ret;
}

View File

@ -199,4 +199,6 @@ do { \
struct bpos bpos_parse(char *);
struct bbpos bbpos_parse(char *);
darray_str get_or_split_cmdline_devs(int argc, char *argv[]);
#endif /* _TOOLS_UTIL_H */