6 #include "libbcachefs/bcachefs_ioctl.h"
7 #include "libbcachefs/btree_cache.h"
10 #include "libbcachefs.h"
14 puts("bcachefs data - manage filesystem data\n"
15 "Usage: bcachefs data <CMD> [OPTIONS]\n"
18 " rereplicate Rereplicate degraded data\n"
19 " job Kick off low level data jobs\n"
21 "Report bugs to <linux-bcache@vger.kernel.org>");
25 static void data_rereplicate_usage(void)
27 puts("bcachefs data rereplicate\n"
28 "Usage: bcachefs data rereplicate filesystem\n"
30 "Walks existing data in a filesystem, writing additional copies\n"
31 "of any degraded data\n"
34 " -h, --help display this help and exit\n"
35 "Report bugs to <linux-bcache@vger.kernel.org>");
39 int cmd_data_rereplicate(int argc, char *argv[])
43 while ((opt = getopt(argc, argv, "h")) != -1)
46 data_rereplicate_usage();
50 char *fs_path = arg_pop();
52 die("Please supply a filesystem");
55 die("too many arguments");
57 return bchu_data(bcache_fs_open(fs_path), (struct bch_ioctl_data) {
58 .op = BCH_DATA_OP_REREPLICATE,
61 .end_btree = BTREE_ID_NR,
66 static void data_job_usage(void)
68 puts("bcachefs data job\n"
69 "Usage: bcachefs data job [job} filesystem\n"
71 "Kick off a data job and report progress\n"
73 "job: one of scrub, rereplicate, migrate, or rewrite_old_nodes\n"
76 " -b btree btree to operate on\n"
77 " -s inode:offset start position\n"
78 " -e inode:offset end position\n"
79 " -h, --help display this help and exit\n"
80 "Report bugs to <linux-bcache@vger.kernel.org>");
84 const char * const data_jobs[] = {
92 int cmd_data_job(int argc, char *argv[])
94 struct bch_ioctl_data op = {
97 .end_btree = BTREE_ID_NR,
102 while ((opt = getopt(argc, argv, "s:e:h")) != -1)
105 op.start_btree = read_string_list_or_die(optarg,
106 bch2_btree_ids, "btree id");
107 op.end_btree = op.start_btree;
110 op.start_pos = bpos_parse(optarg);
112 op.end_pos = bpos_parse(optarg);
120 char *job = arg_pop();
122 die("please specify which type of job");
124 op.op = read_string_list_or_die(job, data_jobs, "bad job type");
126 if (op.op == BCH_DATA_OP_SCRUB)
127 die("scrub not implemented yet");
129 char *fs_path = arg_pop();
134 die("too many arguments");
136 return bchu_data(bcache_fs_open(fs_path), op);