6 #include "libbcachefs/bcachefs_ioctl.h"
7 #include "libbcachefs/btree_cache.h"
8 #include "libbcachefs/move.h"
11 #include "libbcachefs.h"
15 puts("bcachefs data - manage filesystem data\n"
16 "Usage: bcachefs data <CMD> [OPTIONS]\n"
19 " rereplicate Rereplicate degraded data\n"
20 " job Kick off low level data jobs\n"
22 "Report bugs to <linux-bcachefs@vger.kernel.org>");
26 static void data_rereplicate_usage(void)
28 puts("bcachefs data rereplicate\n"
29 "Usage: bcachefs data rereplicate filesystem\n"
31 "Walks existing data in a filesystem, writing additional copies\n"
32 "of any degraded data\n"
35 " -h, --help display this help and exit\n"
36 "Report bugs to <linux-bcachefs@vger.kernel.org>");
40 int cmd_data_rereplicate(int argc, char *argv[])
44 while ((opt = getopt(argc, argv, "h")) != -1)
47 data_rereplicate_usage();
51 char *fs_path = arg_pop();
53 die("Please supply a filesystem");
56 die("too many arguments");
58 return bchu_data(bcache_fs_open(fs_path), (struct bch_ioctl_data) {
59 .op = BCH_DATA_OP_rereplicate,
62 .end_btree = BTREE_ID_NR,
67 static void data_job_usage(void)
69 puts("bcachefs data job\n"
70 "Usage: bcachefs data job [job} filesystem\n"
72 "Kick off a data job and report progress\n"
74 "job: one of scrub, rereplicate, migrate, rewrite_old_nodes, or drop_extra_replicas\n"
77 " -b btree btree to operate on\n"
78 " -s inode:offset start position\n"
79 " -e inode:offset end position\n"
80 " -h, --help display this help and exit\n"
81 "Report bugs to <linux-bcachefs@vger.kernel.org>");
85 int cmd_data_job(int argc, char *argv[])
87 struct bch_ioctl_data op = {
90 .end_btree = BTREE_ID_NR,
95 while ((opt = getopt(argc, argv, "s:e:h")) != -1)
98 op.start_btree = read_string_list_or_die(optarg,
99 __bch2_btree_ids, "btree id");
100 op.end_btree = op.start_btree;
103 op.start_pos = bpos_parse(optarg);
105 op.end_pos = bpos_parse(optarg);
113 char *job = arg_pop();
115 die("please specify which type of job");
117 op.op = read_string_list_or_die(job, bch2_data_ops_strs, "bad job type");
119 char *fs_path = arg_pop();
124 die("too many arguments");
126 return bchu_data(bcache_fs_open(fs_path), op);