Support size suffixes in pool-create --block_size / --bitmap_granularity

This commit is contained in:
Vitaliy Filippov
2024-07-15 11:47:05 +03:00
parent 9c628646fa
commit 93b0947720
+5 -5
View File
@@ -71,8 +71,7 @@ std::string validate_pool_config(json11::Json::object & new_cfg, json11::Json ol
auto & key = kv_it->first;
auto & value = kv_it->second;
if (key == "pg_size" || key == "parity_chunks" || key == "pg_minsize" ||
key == "pg_count" || key == "max_osd_combinations" ||
key == "bitmap_granularity" || key == "pg_stripe_size")
key == "pg_count" || key == "max_osd_combinations")
{
if (value.is_number() && value.uint64_value() != value.number_value() ||
value.is_string() && !value.uint64_value() && value.string_value() != "0")
@@ -81,13 +80,14 @@ std::string validate_pool_config(json11::Json::object & new_cfg, json11::Json ol
}
value = value.uint64_value();
}
else if (key == "block_size")
else if (key == "block_size" || key == "bitmap_granularity" || key == "pg_stripe_size")
{
uint64_t block_size = value.is_string() ? parse_size(value.string_value()) : value.uint64_value();
if (!block_size)
uint64_t sz = value.is_string() ? parse_size(value.string_value()) : value.uint64_value();
if (!sz)
{
return key+" must be an integer with or without size suffix (K/M/G/T)";
}
value = sz;
}
else if (key == "name" || key == "scheme" || key == "immediate_commit" ||
key == "failure_domain" || key == "root_node" || key == "scrub_interval" || key == "used_for_fs" ||