mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-03-10 00:00:04 +03:00
minor disk group fixes;, add background_compression option
This commit is contained in:
parent
1991277c8e
commit
8a57b1f1d5
10
cmd_format.c
10
cmd_format.c
@ -37,6 +37,7 @@ x(0, btree_node_size, "size", "Default 256k") \
|
|||||||
x(0, metadata_checksum_type, "(none|crc32c|crc64)", NULL) \
|
x(0, metadata_checksum_type, "(none|crc32c|crc64)", NULL) \
|
||||||
x(0, data_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, compression_type, "(none|lz4|gzip)", NULL) \
|
||||||
|
x(0, background_compression_type, "(none|lz4|gzip)", NULL) \
|
||||||
x(0, replicas, "#", NULL) \
|
x(0, replicas, "#", NULL) \
|
||||||
x(0, data_replicas, "#", NULL) \
|
x(0, data_replicas, "#", NULL) \
|
||||||
x(0, metadata_replicas, "#", NULL) \
|
x(0, metadata_replicas, "#", NULL) \
|
||||||
@ -78,7 +79,8 @@ static void usage(void)
|
|||||||
" --btree_node=size Btree node size, default 256k\n"
|
" --btree_node=size Btree node size, default 256k\n"
|
||||||
" --metadata_checksum_type=(none|crc32c|crc64)\n"
|
" --metadata_checksum_type=(none|crc32c|crc64)\n"
|
||||||
" --data_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"
|
" --data_replicas=# Number of data replicas\n"
|
||||||
" --metadata_replicas=# Number of metadata replicas\n"
|
" --metadata_replicas=# Number of metadata replicas\n"
|
||||||
" --replicas=# Sets both data and metadata replicas\n"
|
" --replicas=# Sets both data and metadata replicas\n"
|
||||||
@ -178,6 +180,12 @@ int cmd_format(int argc, char *argv[])
|
|||||||
bch2_compression_types,
|
bch2_compression_types,
|
||||||
"compression type");
|
"compression type");
|
||||||
break;
|
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:
|
case O_data_replicas:
|
||||||
if (kstrtouint(optarg, 10, &opts.data_replicas) ||
|
if (kstrtouint(optarg, 10, &opts.data_replicas) ||
|
||||||
!opts.data_replicas ||
|
!opts.data_replicas ||
|
||||||
|
@ -128,8 +128,8 @@ static unsigned parse_target(struct dev_opts *devs, size_t nr_devs,
|
|||||||
struct bch_sb_field_disk_groups *gi,
|
struct bch_sb_field_disk_groups *gi,
|
||||||
const char *s)
|
const char *s)
|
||||||
{
|
{
|
||||||
struct bch_disk_group *g;
|
|
||||||
struct dev_opts *i;
|
struct dev_opts *i;
|
||||||
|
int idx;
|
||||||
|
|
||||||
if (!s)
|
if (!s)
|
||||||
return 0;
|
return 0;
|
||||||
@ -138,15 +138,9 @@ static unsigned parse_target(struct dev_opts *devs, size_t nr_devs,
|
|||||||
if (!strcmp(s, i->path))
|
if (!strcmp(s, i->path))
|
||||||
return dev_to_target(i - devs);
|
return dev_to_target(i - devs);
|
||||||
|
|
||||||
for (g = gi->entries;
|
idx = __bch2_disk_group_find(gi, s);
|
||||||
g < gi->entries + disk_groups_nr(gi);
|
if (idx >= 0)
|
||||||
g++) {
|
return group_to_target(idx);
|
||||||
unsigned len = strnlen(g->label, sizeof(g->label));
|
|
||||||
|
|
||||||
if (len == strlen(s) &&
|
|
||||||
!memcmp(s, g->label, len))
|
|
||||||
return group_to_target(g - gi->entries);
|
|
||||||
}
|
|
||||||
|
|
||||||
die("Invalid target %s", s);
|
die("Invalid target %s", s);
|
||||||
return 0;
|
return 0;
|
||||||
@ -212,6 +206,7 @@ struct bch_sb *bch2_format(struct format_opts opts,
|
|||||||
SET_BCH_SB_META_CSUM_TYPE(sb, opts.meta_csum_type);
|
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_DATA_CSUM_TYPE(sb, opts.data_csum_type);
|
||||||
SET_BCH_SB_COMPRESSION_TYPE(sb, opts.compression_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_BTREE_NODE_SIZE(sb, opts.btree_node_size);
|
||||||
SET_BCH_SB_GC_RESERVE(sb, 8);
|
SET_BCH_SB_GC_RESERVE(sb, 8);
|
||||||
@ -446,12 +441,16 @@ static void bch2_sb_print_members(struct bch_sb *sb, struct bch_sb_field *f,
|
|||||||
uuid_unparse(m->uuid.b, member_uuid_str);
|
uuid_unparse(m->uuid.b, member_uuid_str);
|
||||||
|
|
||||||
if (BCH_MEMBER_GROUP(m)) {
|
if (BCH_MEMBER_GROUP(m)) {
|
||||||
if (BCH_MEMBER_GROUP(m) < disk_groups_nr(gi))
|
unsigned idx = BCH_MEMBER_GROUP(m) - 1;
|
||||||
memcpy(group, gi->entries[BCH_MEMBER_GROUP(m)].label,
|
|
||||||
|
if (idx < disk_groups_nr(gi)) {
|
||||||
|
memcpy(group, gi->entries[idx].label,
|
||||||
BCH_SB_LABEL_SIZE);
|
BCH_SB_LABEL_SIZE);
|
||||||
else
|
group[BCH_SB_LABEL_SIZE] = '\0';
|
||||||
|
} else {
|
||||||
strcpy(group, "(bad disk groups section");
|
strcpy(group, "(bad disk groups section");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bch2_scnprint_flag_list(data_allowed_str,
|
bch2_scnprint_flag_list(data_allowed_str,
|
||||||
sizeof(data_allowed_str),
|
sizeof(data_allowed_str),
|
||||||
|
@ -32,6 +32,7 @@ struct format_opts {
|
|||||||
unsigned meta_csum_type;
|
unsigned meta_csum_type;
|
||||||
unsigned data_csum_type;
|
unsigned data_csum_type;
|
||||||
unsigned compression_type;
|
unsigned compression_type;
|
||||||
|
unsigned background_compression_type;
|
||||||
|
|
||||||
bool encrypted;
|
bool encrypted;
|
||||||
char *passphrase;
|
char *passphrase;
|
||||||
|
Loading…
Reference in New Issue
Block a user