minor disk group fixes;, add background_compression option

This commit is contained in:
Kent Overstreet 2018-02-28 17:56:53 -05:00
parent 1991277c8e
commit 8a57b1f1d5
3 changed files with 24 additions and 16 deletions

View File

@ -37,6 +37,7 @@ 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) \
@ -78,7 +79,8 @@ static void usage(void)
" --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"
@ -178,6 +180,12 @@ int cmd_format(int argc, char *argv[])
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 ||

View File

@ -128,8 +128,8 @@ static unsigned parse_target(struct dev_opts *devs, size_t nr_devs,
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;
@ -138,15 +138,9 @@ static unsigned parse_target(struct dev_opts *devs, size_t nr_devs,
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;
@ -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_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);
@ -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);
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,
sizeof(data_allowed_str),

View File

@ -32,6 +32,7 @@ struct format_opts {
unsigned meta_csum_type;
unsigned data_csum_type;
unsigned compression_type;
unsigned background_compression_type;
bool encrypted;
char *passphrase;