]> git.sesse.net Git - bcachefs-tools-debian/commitdiff
Add --durability to format
authorKent Overstreet <kent.overstreet@gmail.com>
Tue, 13 Mar 2018 07:23:27 +0000 (03:23 -0400)
committerKent Overstreet <kent.overstreet@gmail.com>
Tue, 13 Mar 2018 07:23:27 +0000 (03:23 -0400)
cmd_format.c
libbcachefs.c
libbcachefs.h

index 065efd9df17bd0dc8509de821e005127872c5880..75efd5215757223e8ff674bc19378549f0fac251 100644 (file)
@@ -57,6 +57,7 @@ x(0,  bucket_size,            "size",                 "Bucket size")          \
 x('g', group,                  "label",                "Disk group")\
 x(0,   discard,                NULL,                   NULL)                   \
 x(0,   data_allowed,           "journal,btree,data",   "Allowed types of data on this device")\
+x(0,   durability,             "#",                    "Number of times data written to this device will have been considered replicated")\
 t("Device specific options must come before corresponding devices, e.g.")      \
 t("  bcachefs format --group cache /dev/sdb --tier 1 /dev/sdc")                        \
 t("")                                                                          \
@@ -96,6 +97,7 @@ static void usage(void)
             "      --fs_size=size          Size of filesystem on device\n"
             "      --bucket=size           Bucket size\n"
             "      --discard               Enable discards\n"
+            "      --durability=#          Device durability (0-4)\n"
             "  -g, --group=label           Disk group\n"
             "\n"
             "  -q, --quiet                 Only print errors\n"
@@ -261,6 +263,11 @@ int cmd_format(int argc, char *argv[])
                                read_flag_list_or_die(optarg,
                                        bch2_data_types, "data type");
                        break;
+               case O_durability:
+                       if (kstrtouint(optarg, 10, &dev_opts.durability) ||
+                           dev_opts.durability > BCH_REPLICAS_MAX)
+                               die("invalid durability");
+                       break;
                case O_no_opt:
                        dev_opts.path = strdup(optarg);
                        darray_append(devices, dev_opts);
index cd277fa72586c42527f517e30b148d6945352a9a..052ca35bcfa7dfd99828b8ba897eb666485ddb5e 100644 (file)
@@ -247,6 +247,7 @@ struct bch_sb *bch2_format(struct format_opts opts,
                SET_BCH_MEMBER_REPLACEMENT(m,   CACHE_REPLACEMENT_LRU);
                SET_BCH_MEMBER_DISCARD(m,       i->discard);
                SET_BCH_MEMBER_DATA_ALLOWED(m,  i->data_allowed);
+               SET_BCH_MEMBER_DURABILITY(m,    i->durability + 1);
        }
 
        /* Disk groups */
index deaa28751c4c6324f17097bdccacd98249936aab..8537a048b6b471ad5c58f50b609ebf88c0f533dd 100644 (file)
@@ -59,6 +59,7 @@ struct dev_opts {
        unsigned        bucket_size;
        const char      *group;
        unsigned        data_allowed;
+       unsigned        durability;
        bool            discard;
 
        u64             nbuckets;
@@ -71,6 +72,7 @@ static inline struct dev_opts dev_opts_default()
 {
        return (struct dev_opts) {
                .data_allowed           = ~0U << 2,
+               .durability             = 1,
        };
 }