mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-02-23 00:00:02 +03:00
cmd_fsck can now take colon separated devices
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
5134a64ceb
commit
ca4892af17
@ -59,7 +59,6 @@ static void dump_one_device(struct bch_fs *c, struct bch_dev *ca, int fd,
|
|||||||
|
|
||||||
/* Btree: */
|
/* Btree: */
|
||||||
for (i = 0; i < BTREE_ID_NR; i++) {
|
for (i = 0; i < BTREE_ID_NR; i++) {
|
||||||
const struct bch_extent_ptr *ptr;
|
|
||||||
struct bkey_ptrs_c ptrs;
|
struct bkey_ptrs_c ptrs;
|
||||||
struct btree_trans *trans = bch2_trans_get(c);
|
struct btree_trans *trans = bch2_trans_get(c);
|
||||||
struct btree_iter iter;
|
struct btree_iter iter;
|
||||||
|
15
cmd_fsck.c
15
cmd_fsck.c
@ -90,7 +90,6 @@ int cmd_fsck(int argc, char *argv[])
|
|||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
struct bch_opts opts = bch2_opts_empty();
|
struct bch_opts opts = bch2_opts_empty();
|
||||||
unsigned i;
|
|
||||||
int opt, ret = 0;
|
int opt, ret = 0;
|
||||||
|
|
||||||
opt_set(opts, degraded, true);
|
opt_set(opts, degraded, true);
|
||||||
@ -138,15 +137,15 @@ int cmd_fsck(int argc, char *argv[])
|
|||||||
exit(8);
|
exit(8);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < argc; i++)
|
darray_str devs = get_or_split_cmdline_devs(argc, argv);
|
||||||
if (dev_mounted(argv[i]))
|
|
||||||
return fsck_online(argv[i]);
|
|
||||||
|
|
||||||
struct bch_fs *c = bch2_fs_open(argv, argc, opts);
|
darray_for_each(devs, i)
|
||||||
if (IS_ERR(c)) {
|
if (dev_mounted(*i))
|
||||||
fprintf(stderr, "error opening %s: %s\n", argv[0], bch2_err_str(PTR_ERR(c)));
|
return fsck_online(*i);
|
||||||
|
|
||||||
|
struct bch_fs *c = bch2_fs_open(devs.data, devs.nr, opts);
|
||||||
|
if (IS_ERR(c))
|
||||||
exit(8);
|
exit(8);
|
||||||
}
|
|
||||||
|
|
||||||
if (test_bit(BCH_FS_errors_fixed, &c->flags)) {
|
if (test_bit(BCH_FS_errors_fixed, &c->flags)) {
|
||||||
fprintf(stderr, "%s: errors fixed\n", c->name);
|
fprintf(stderr, "%s: errors fixed\n", c->name);
|
||||||
|
@ -79,15 +79,12 @@ int cmd_kill_btree_node(int argc, char *argv[])
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!node_index) {
|
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;
|
struct printbuf buf = PRINTBUF;
|
||||||
|
|
||||||
bch2_bkey_val_to_text(&buf, c, bkey_i_to_s_c(&b->key));
|
bch2_bkey_val_to_text(&buf, c, bkey_i_to_s_c(&b->key));
|
||||||
bch_info(c, "killing btree node %s", buf.buf);
|
bch_info(c, "killing btree node %s", buf.buf);
|
||||||
printbuf_exit(&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) {
|
bkey_for_each_ptr(ptrs, ptr) {
|
||||||
struct bch_dev *ca = bch_dev_bkey_exists(c, ptr->dev);
|
struct bch_dev *ca = bch_dev_bkey_exists(c, ptr->dev);
|
||||||
|
|
||||||
|
@ -263,7 +263,9 @@ int cmd_list_journal(int argc, char *argv[])
|
|||||||
if (!argc)
|
if (!argc)
|
||||||
die("Please supply device(s) to open");
|
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))
|
if (IS_ERR(c))
|
||||||
die("error opening %s: %s", argv[0], bch2_err_str(PTR_ERR(c)));
|
die("error opening %s: %s", argv[0], bch2_err_str(PTR_ERR(c)));
|
||||||
|
|
||||||
|
14
tools-util.c
14
tools-util.c
@ -650,3 +650,17 @@ struct bbpos bbpos_parse(char *buf)
|
|||||||
ret.pos = bpos_parse(s);
|
ret.pos = bpos_parse(s);
|
||||||
return ret;
|
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;
|
||||||
|
}
|
||||||
|
@ -199,4 +199,6 @@ do { \
|
|||||||
struct bpos bpos_parse(char *);
|
struct bpos bpos_parse(char *);
|
||||||
struct bbpos bbpos_parse(char *);
|
struct bbpos bbpos_parse(char *);
|
||||||
|
|
||||||
|
darray_str get_or_split_cmdline_devs(int argc, char *argv[]);
|
||||||
|
|
||||||
#endif /* _TOOLS_UTIL_H */
|
#endif /* _TOOLS_UTIL_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user