6 #include "libbcachefs/bcachefs_ioctl.h"
7 #include "libbcachefs/btree_cache.h"
10 #include "libbcachefs.h"
12 static void data_rereplicate_usage(void)
14 puts("bcachefs data rereplicate\n"
15 "Usage: bcachefs data rereplicate filesystem\n"
17 "Walks existing data in a filesystem, writing additional copies\n"
18 "of any degraded data\n"
21 " -h, --help display this help and exit\n"
22 "Report bugs to <linux-bcache@vger.kernel.org>");
26 int cmd_data_rereplicate(int argc, char *argv[])
30 while ((opt = getopt(argc, argv, "h")) != -1)
33 data_rereplicate_usage();
37 char *fs_path = arg_pop();
39 die("Please supply a filesystem");
42 die("too many arguments");
44 return bchu_data(bcache_fs_open(fs_path), (struct bch_ioctl_data) {
45 .op = BCH_DATA_OP_REREPLICATE,
48 .end_btree = BTREE_ID_NR,
53 static void data_job_usage(void)
55 puts("bcachefs data job\n"
56 "Usage: bcachefs data job [job} filesystem\n"
58 "Kick off a data job and report progress\n"
60 "job: one of scrub, rereplicate, migrate, or rewrite_old_nodes\n"
63 " -b btree btree to operate on\n"
64 " -s inode:offset start position\n"
65 " -e inode:offset end position\n"
66 " -h, --help display this help and exit\n"
67 "Report bugs to <linux-bcache@vger.kernel.org>");
71 const char * const data_jobs[] = {
79 int cmd_data_job(int argc, char *argv[])
81 struct bch_ioctl_data op = {
84 .end_btree = BTREE_ID_NR,
89 while ((opt = getopt(argc, argv, "s:e:h")) != -1)
92 op.start_btree = read_string_list_or_die(optarg,
93 bch2_btree_ids, "btree id");
94 op.end_btree = op.start_btree;
97 op.start_pos = bpos_parse(optarg);
99 op.end_pos = bpos_parse(optarg);
107 char *job = arg_pop();
109 die("please specify which type of job");
111 op.op = read_string_list_or_die(job, data_jobs, "bad job type");
113 if (op.op == BCH_DATA_OP_SCRUB)
114 die("scrub not implemented yet");
116 char *fs_path = arg_pop();
121 die("too many arguments");
123 return bchu_data(bcache_fs_open(fs_path), op);