#define OPTS \
t("bcachefs format - create a new bcachefs filesystem on one or more devices") \
-t("Usage: bcachefs format [OPTION]... <devices>") \
+t("Usage: bcachefs format [OPTION]... <devices>") \
t("") \
x('b', block_size, "size", NULL) \
x(0, btree_node_size, "size", "Default 256k") \
x(0, metadata_checksum_type, "(none|crc32c|crc64)", NULL) \
x(0, data_checksum_type, "(none|crc32c|crc64)", NULL) \
x(0, compression_type, "(none|lz4|gzip)", NULL) \
+x(0, background_compression_type, "(none|lz4|gzip)", NULL) \
x(0, replicas, "#", NULL) \
x(0, data_replicas, "#", NULL) \
x(0, metadata_replicas, "#", NULL) \
x(0, foreground_target, "target", NULL) \
x(0, background_target, "target", NULL) \
-x(0, promote_target, "target", NULL) \
+x(0, promote_target, "target", NULL) \
x(0, encrypted, NULL, "Enable whole filesystem encryption (chacha20/poly1305)")\
x(0, no_passphrase, NULL, "Don't encrypt master encryption key")\
x('e', error_action, "(continue|remount-ro|panic)", NULL) \
" --btree_node=size Btree node size, default 256k\n"
" --metadata_checksum_type=(none|crc32c|crc64)\n"
" --data_checksum_type=(none|crc32c|crc64)\n"
- " --compression_type=(none|lz4|gzip)\n"
+ " --compression_type=(none|lz4|gzip|zstd)\n"
+ " --background_compression_type=(none|lz4|gzip|zstd)\n"
" --data_replicas=# Number of data replicas\n"
" --metadata_replicas=# Number of metadata replicas\n"
" --replicas=# Sets both data and metadata replicas\n"
bch2_compression_types,
"compression type");
break;
+ case O_background_compression_type:
+ opts.background_compression_type =
+ read_string_list_or_die(optarg,
+ bch2_compression_types,
+ "compression type");
+ break;
case O_data_replicas:
if (kstrtouint(optarg, 10, &opts.data_replicas) ||
!opts.data_replicas ||
struct bch_sb_field_disk_groups *gi,
const char *s)
{
- struct bch_disk_group *g;
struct dev_opts *i;
+ int idx;
if (!s)
return 0;
if (!strcmp(s, i->path))
return dev_to_target(i - devs);
- for (g = gi->entries;
- g < gi->entries + disk_groups_nr(gi);
- g++) {
- unsigned len = strnlen(g->label, sizeof(g->label));
-
- if (len == strlen(s) &&
- !memcmp(s, g->label, len))
- return group_to_target(g - gi->entries);
- }
+ idx = __bch2_disk_group_find(gi, s);
+ if (idx >= 0)
+ return group_to_target(idx);
die("Invalid target %s", s);
return 0;
SET_BCH_SB_META_CSUM_TYPE(sb, opts.meta_csum_type);
SET_BCH_SB_DATA_CSUM_TYPE(sb, opts.data_csum_type);
SET_BCH_SB_COMPRESSION_TYPE(sb, opts.compression_type);
+ SET_BCH_SB_BACKGROUND_COMPRESSION_TYPE(sb, opts.background_compression_type);
SET_BCH_SB_BTREE_NODE_SIZE(sb, opts.btree_node_size);
SET_BCH_SB_GC_RESERVE(sb, 8);
uuid_unparse(m->uuid.b, member_uuid_str);
if (BCH_MEMBER_GROUP(m)) {
- if (BCH_MEMBER_GROUP(m) < disk_groups_nr(gi))
- memcpy(group, gi->entries[BCH_MEMBER_GROUP(m)].label,
+ unsigned idx = BCH_MEMBER_GROUP(m) - 1;
+
+ if (idx < disk_groups_nr(gi)) {
+ memcpy(group, gi->entries[idx].label,
BCH_SB_LABEL_SIZE);
- else
+ group[BCH_SB_LABEL_SIZE] = '\0';
+ } else {
strcpy(group, "(bad disk groups section");
+ }
}
bch2_scnprint_flag_list(data_allowed_str,