]> git.sesse.net Git - bcachefs-tools-debian/blob - cmd_data.c
Update bcachefs sources to 242d37cbd0 bcachefs: Kill btree_iter_pos_changed()
[bcachefs-tools-debian] / cmd_data.c
1
2
3 #include <stdio.h>
4 #include <sys/ioctl.h>
5
6 #include "libbcachefs/bcachefs_ioctl.h"
7
8 #include "cmds.h"
9 #include "libbcachefs.h"
10
11 static void data_rereplicate_usage(void)
12 {
13         puts("bcachefs data rereplicate\n"
14              "Usage: bcachefs data rereplicate filesystem\n"
15              "\n"
16              "Walks existing data in a filesystem, writing additional copies\n"
17              "of any degraded data\n"
18              "\n"
19              "Options:\n"
20              "  -h, --help                  display this help and exit\n"
21              "Report bugs to <linux-bcache@vger.kernel.org>");
22         exit(EXIT_SUCCESS);
23 }
24
25 int cmd_data_rereplicate(int argc, char *argv[])
26 {
27         int opt;
28
29         while ((opt = getopt(argc, argv, "h")) != -1)
30                 switch (opt) {
31                 case 'h':
32                         data_rereplicate_usage();
33                 }
34         args_shift(optind);
35
36         char *fs_path = arg_pop();
37         if (!fs_path)
38                 die("Please supply a filesystem");
39
40         if (argc)
41                 die("too many arguments");
42
43         return bchu_data(bcache_fs_open(fs_path), (struct bch_ioctl_data) {
44                 .op             = BCH_DATA_OP_REREPLICATE,
45                 .start_btree    = 0,
46                 .start_pos      = POS_MIN,
47                 .end_btree      = BTREE_ID_NR,
48                 .end_pos        = POS_MAX,
49         });
50 }