Compare commits
2 Commits
a028b4fa4c
...
aff6f3e970
Author | SHA1 | Date |
---|---|---|
Vitaliy Filippov | aff6f3e970 | |
Vitaliy Filippov | 49fca80f1c |
|
@ -19,8 +19,8 @@ bool string_to_addr(std::string str, bool parse_port, int default_port, struct s
|
||||||
if (p != std::string::npos && !(str.length() > 0 && str[p-1] == ']')) // "[ipv6]" which contains ':'
|
if (p != std::string::npos && !(str.length() > 0 && str[p-1] == ']')) // "[ipv6]" which contains ':'
|
||||||
{
|
{
|
||||||
char null_byte = 0;
|
char null_byte = 0;
|
||||||
int n = sscanf(str.c_str()+p+1, "%d%c", &default_port, &null_byte);
|
int scanned = sscanf(str.c_str()+p+1, "%d%c", &default_port, &null_byte);
|
||||||
if (n != 1 || default_port >= 0x10000)
|
if (scanned != 1 || default_port >= 0x10000)
|
||||||
return false;
|
return false;
|
||||||
str = str.substr(0, p);
|
str = str.substr(0, p);
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,8 +77,8 @@ struct alloc_osd_t
|
||||||
std::string key = base64_decode(kv["key"].string_value());
|
std::string key = base64_decode(kv["key"].string_value());
|
||||||
osd_num_t cur_osd;
|
osd_num_t cur_osd;
|
||||||
char null_byte = 0;
|
char null_byte = 0;
|
||||||
sscanf(key.c_str() + parent->cli->st_cli.etcd_prefix.length(), "/osd/stats/%lu%c", &cur_osd, &null_byte);
|
int scanned = sscanf(key.c_str() + parent->cli->st_cli.etcd_prefix.length(), "/osd/stats/%lu%c", &cur_osd, &null_byte);
|
||||||
if (!cur_osd || null_byte != 0)
|
if (scanned != 1 || !cur_osd)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Invalid key in etcd: %s\n", key.c_str());
|
fprintf(stderr, "Invalid key in etcd: %s\n", key.c_str());
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -67,8 +67,8 @@ resume_1:
|
||||||
// pool ID
|
// pool ID
|
||||||
pool_id_t pool_id;
|
pool_id_t pool_id;
|
||||||
char null_byte = 0;
|
char null_byte = 0;
|
||||||
sscanf(kv.key.substr(parent->cli->st_cli.etcd_prefix.length()).c_str(), "/pool/stats/%u%c", &pool_id, &null_byte);
|
int scanned = sscanf(kv.key.substr(parent->cli->st_cli.etcd_prefix.length()).c_str(), "/pool/stats/%u%c", &pool_id, &null_byte);
|
||||||
if (!pool_id || pool_id >= POOL_ID_MAX || null_byte != 0)
|
if (scanned != 1 || !pool_id || pool_id >= POOL_ID_MAX)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Invalid key in etcd: %s\n", kv.key.c_str());
|
fprintf(stderr, "Invalid key in etcd: %s\n", kv.key.c_str());
|
||||||
continue;
|
continue;
|
||||||
|
@ -82,8 +82,8 @@ resume_1:
|
||||||
// osd ID
|
// osd ID
|
||||||
osd_num_t osd_num;
|
osd_num_t osd_num;
|
||||||
char null_byte = 0;
|
char null_byte = 0;
|
||||||
sscanf(kv.key.substr(parent->cli->st_cli.etcd_prefix.length()).c_str(), "/osd/stats/%lu%c", &osd_num, &null_byte);
|
int scanned = sscanf(kv.key.substr(parent->cli->st_cli.etcd_prefix.length()).c_str(), "/osd/stats/%lu%c", &osd_num, &null_byte);
|
||||||
if (!osd_num || osd_num >= POOL_ID_MAX || null_byte != 0)
|
if (scanned != 1 || !osd_num || osd_num >= POOL_ID_MAX)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Invalid key in etcd: %s\n", kv.key.c_str());
|
fprintf(stderr, "Invalid key in etcd: %s\n", kv.key.c_str());
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -133,8 +133,8 @@ resume_1:
|
||||||
// pool ID
|
// pool ID
|
||||||
pool_id_t pool_id;
|
pool_id_t pool_id;
|
||||||
char null_byte = 0;
|
char null_byte = 0;
|
||||||
sscanf(kv.key.substr(parent->cli->st_cli.etcd_prefix.length()).c_str(), "/pool/stats/%u%c", &pool_id, &null_byte);
|
int scanned = sscanf(kv.key.substr(parent->cli->st_cli.etcd_prefix.length()).c_str(), "/pool/stats/%u%c", &pool_id, &null_byte);
|
||||||
if (!pool_id || pool_id >= POOL_ID_MAX || null_byte != 0)
|
if (scanned != 1 || !pool_id || pool_id >= POOL_ID_MAX)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Invalid key in etcd: %s\n", kv.key.c_str());
|
fprintf(stderr, "Invalid key in etcd: %s\n", kv.key.c_str());
|
||||||
continue;
|
continue;
|
||||||
|
@ -149,9 +149,9 @@ resume_1:
|
||||||
pool_id_t pool_id;
|
pool_id_t pool_id;
|
||||||
inode_t only_inode_num;
|
inode_t only_inode_num;
|
||||||
char null_byte = 0;
|
char null_byte = 0;
|
||||||
sscanf(kv.key.substr(parent->cli->st_cli.etcd_prefix.length()).c_str(),
|
int scanned = sscanf(kv.key.substr(parent->cli->st_cli.etcd_prefix.length()).c_str(),
|
||||||
"/inode/stats/%u/%lu%c", &pool_id, &only_inode_num, &null_byte);
|
"/inode/stats/%u/%lu%c", &pool_id, &only_inode_num, &null_byte);
|
||||||
if (!pool_id || pool_id >= POOL_ID_MAX || INODE_POOL(only_inode_num) != 0 || null_byte != 0)
|
if (scanned != 2 || !pool_id || pool_id >= POOL_ID_MAX || INODE_POOL(only_inode_num) != 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Invalid key in etcd: %s\n", kv.key.c_str());
|
fprintf(stderr, "Invalid key in etcd: %s\n", kv.key.c_str());
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -384,8 +384,8 @@ resume_100:
|
||||||
pool_id_t pool_id = 0;
|
pool_id_t pool_id = 0;
|
||||||
inode_t inode = 0;
|
inode_t inode = 0;
|
||||||
char null_byte = 0;
|
char null_byte = 0;
|
||||||
sscanf(kv.key.c_str() + parent->cli->st_cli.etcd_prefix.length()+13, "%u/%lu%c", &pool_id, &inode, &null_byte);
|
int scanned = sscanf(kv.key.c_str() + parent->cli->st_cli.etcd_prefix.length()+13, "%u/%lu%c", &pool_id, &inode, &null_byte);
|
||||||
if (!inode || null_byte != 0)
|
if (scanned != 2 || !inode)
|
||||||
{
|
{
|
||||||
result = (cli_result_t){ .err = EIO, .text = "Bad key returned from etcd: "+kv.key };
|
result = (cli_result_t){ .err = EIO, .text = "Bad key returned from etcd: "+kv.key };
|
||||||
state = 100;
|
state = 100;
|
||||||
|
|
|
@ -132,8 +132,8 @@ resume_2:
|
||||||
auto kv = parent->cli->st_cli.parse_etcd_kv(osd_stats[i]);
|
auto kv = parent->cli->st_cli.parse_etcd_kv(osd_stats[i]);
|
||||||
osd_num_t stat_osd_num = 0;
|
osd_num_t stat_osd_num = 0;
|
||||||
char null_byte = 0;
|
char null_byte = 0;
|
||||||
sscanf(kv.key.c_str() + parent->cli->st_cli.etcd_prefix.size(), "/osd/stats/%lu%c", &stat_osd_num, &null_byte);
|
int scanned = sscanf(kv.key.c_str() + parent->cli->st_cli.etcd_prefix.size(), "/osd/stats/%lu%c", &stat_osd_num, &null_byte);
|
||||||
if (!stat_osd_num || null_byte != 0)
|
if (scanned != 1 || !stat_osd_num)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Invalid key in etcd: %s\n", kv.key.c_str());
|
fprintf(stderr, "Invalid key in etcd: %s\n", kv.key.c_str());
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -684,8 +684,8 @@ void etcd_state_client_t::parse_state(const etcd_kv_t & kv)
|
||||||
// ID
|
// ID
|
||||||
pool_id_t pool_id;
|
pool_id_t pool_id;
|
||||||
char null_byte = 0;
|
char null_byte = 0;
|
||||||
sscanf(pool_item.first.c_str(), "%u%c", &pool_id, &null_byte);
|
int scanned = sscanf(pool_item.first.c_str(), "%u%c", &pool_id, &null_byte);
|
||||||
if (!pool_id || pool_id >= POOL_ID_MAX || null_byte != 0)
|
if (scanned != 1 || !pool_id || pool_id >= POOL_ID_MAX)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Pool ID %s is invalid (must be a number less than 0x%x), skipping pool\n", pool_item.first.c_str(), POOL_ID_MAX);
|
fprintf(stderr, "Pool ID %s is invalid (must be a number less than 0x%x), skipping pool\n", pool_item.first.c_str(), POOL_ID_MAX);
|
||||||
continue;
|
continue;
|
||||||
|
@ -829,8 +829,8 @@ void etcd_state_client_t::parse_state(const etcd_kv_t & kv)
|
||||||
{
|
{
|
||||||
pool_id_t pool_id;
|
pool_id_t pool_id;
|
||||||
char null_byte = 0;
|
char null_byte = 0;
|
||||||
sscanf(pool_item.first.c_str(), "%u%c", &pool_id, &null_byte);
|
int scanned = sscanf(pool_item.first.c_str(), "%u%c", &pool_id, &null_byte);
|
||||||
if (!pool_id || pool_id >= POOL_ID_MAX || null_byte != 0)
|
if (scanned != 1 || !pool_id || pool_id >= POOL_ID_MAX)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Pool ID %s is invalid in PG configuration (must be a number less than 0x%x), skipping pool\n", pool_item.first.c_str(), POOL_ID_MAX);
|
fprintf(stderr, "Pool ID %s is invalid in PG configuration (must be a number less than 0x%x), skipping pool\n", pool_item.first.c_str(), POOL_ID_MAX);
|
||||||
continue;
|
continue;
|
||||||
|
@ -838,8 +838,8 @@ void etcd_state_client_t::parse_state(const etcd_kv_t & kv)
|
||||||
for (auto & pg_item: pool_item.second.object_items())
|
for (auto & pg_item: pool_item.second.object_items())
|
||||||
{
|
{
|
||||||
pg_num_t pg_num = 0;
|
pg_num_t pg_num = 0;
|
||||||
sscanf(pg_item.first.c_str(), "%u%c", &pg_num, &null_byte);
|
int scanned = sscanf(pg_item.first.c_str(), "%u%c", &pg_num, &null_byte);
|
||||||
if (!pg_num || null_byte != 0)
|
if (scanned != 1 || !pg_num)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Bad key in pool %u PG configuration: %s (must be a number), skipped\n", pool_id, pg_item.first.c_str());
|
fprintf(stderr, "Bad key in pool %u PG configuration: %s (must be a number), skipped\n", pool_id, pg_item.first.c_str());
|
||||||
continue;
|
continue;
|
||||||
|
@ -889,8 +889,8 @@ void etcd_state_client_t::parse_state(const etcd_kv_t & kv)
|
||||||
pool_id_t pool_id = 0;
|
pool_id_t pool_id = 0;
|
||||||
pg_num_t pg_num = 0;
|
pg_num_t pg_num = 0;
|
||||||
char null_byte = 0;
|
char null_byte = 0;
|
||||||
sscanf(key.c_str() + etcd_prefix.length()+12, "%u/%u%c", &pool_id, &pg_num, &null_byte);
|
int scanned = sscanf(key.c_str() + etcd_prefix.length()+12, "%u/%u%c", &pool_id, &pg_num, &null_byte);
|
||||||
if (!pool_id || pool_id >= POOL_ID_MAX || !pg_num || null_byte != 0)
|
if (scanned != 2 || !pool_id || pool_id >= POOL_ID_MAX || !pg_num)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Bad etcd key %s, ignoring\n", key.c_str());
|
fprintf(stderr, "Bad etcd key %s, ignoring\n", key.c_str());
|
||||||
}
|
}
|
||||||
|
@ -944,8 +944,8 @@ void etcd_state_client_t::parse_state(const etcd_kv_t & kv)
|
||||||
pool_id_t pool_id = 0;
|
pool_id_t pool_id = 0;
|
||||||
pg_num_t pg_num = 0;
|
pg_num_t pg_num = 0;
|
||||||
char null_byte = 0;
|
char null_byte = 0;
|
||||||
sscanf(key.c_str() + etcd_prefix.length()+10, "%u/%u%c", &pool_id, &pg_num, &null_byte);
|
int scanned = sscanf(key.c_str() + etcd_prefix.length()+10, "%u/%u%c", &pool_id, &pg_num, &null_byte);
|
||||||
if (!pool_id || pool_id >= POOL_ID_MAX || !pg_num || null_byte != 0)
|
if (scanned != 2 || !pool_id || pool_id >= POOL_ID_MAX || !pg_num)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Bad etcd key %s, ignoring\n", key.c_str());
|
fprintf(stderr, "Bad etcd key %s, ignoring\n", key.c_str());
|
||||||
}
|
}
|
||||||
|
@ -1015,8 +1015,8 @@ void etcd_state_client_t::parse_state(const etcd_kv_t & kv)
|
||||||
uint64_t pool_id = 0;
|
uint64_t pool_id = 0;
|
||||||
uint64_t inode_num = 0;
|
uint64_t inode_num = 0;
|
||||||
char null_byte = 0;
|
char null_byte = 0;
|
||||||
sscanf(key.c_str() + etcd_prefix.length()+14, "%lu/%lu%c", &pool_id, &inode_num, &null_byte);
|
int scanned = sscanf(key.c_str() + etcd_prefix.length()+14, "%lu/%lu%c", &pool_id, &inode_num, &null_byte);
|
||||||
if (!pool_id || pool_id >= POOL_ID_MAX || !inode_num || (inode_num >> (64-POOL_ID_BITS)) || null_byte != 0)
|
if (scanned != 2 || !pool_id || pool_id >= POOL_ID_MAX || !inode_num || (inode_num >> (64-POOL_ID_BITS)))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Bad etcd key %s, ignoring\n", key.c_str());
|
fprintf(stderr, "Bad etcd key %s, ignoring\n", key.c_str());
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,12 +19,12 @@ std::string msgr_rdma_address_t::to_string()
|
||||||
bool msgr_rdma_address_t::from_string(const char *str, msgr_rdma_address_t *dest)
|
bool msgr_rdma_address_t::from_string(const char *str, msgr_rdma_address_t *dest)
|
||||||
{
|
{
|
||||||
uint64_t* gid = (uint64_t*)&dest->gid;
|
uint64_t* gid = (uint64_t*)&dest->gid;
|
||||||
int n = sscanf(
|
int scanned = sscanf(
|
||||||
str, "%hx:%x:%x:%16lx%16lx", &dest->lid, &dest->qpn, &dest->psn, gid, gid+1
|
str, "%hx:%x:%x:%16lx%16lx", &dest->lid, &dest->qpn, &dest->psn, gid, gid+1
|
||||||
);
|
);
|
||||||
gid[0] = be64toh(gid[0]);
|
gid[0] = be64toh(gid[0]);
|
||||||
gid[1] = be64toh(gid[1]);
|
gid[1] = be64toh(gid[1]);
|
||||||
return n == 5;
|
return scanned == 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
msgr_rdma_context_t::~msgr_rdma_context_t()
|
msgr_rdma_context_t::~msgr_rdma_context_t()
|
||||||
|
|
|
@ -346,8 +346,8 @@ void nfs_proxy_t::parse_stats(etcd_kv_t & kv)
|
||||||
pool_id_t pool_id = 0;
|
pool_id_t pool_id = 0;
|
||||||
inode_t inode_num = 0;
|
inode_t inode_num = 0;
|
||||||
char null_byte = 0;
|
char null_byte = 0;
|
||||||
sscanf(key.c_str() + cli->st_cli.etcd_prefix.length()+13, "%u/%lu%c", &pool_id, &inode_num, &null_byte);
|
int scanned = sscanf(key.c_str() + cli->st_cli.etcd_prefix.length()+13, "%u/%lu%c", &pool_id, &inode_num, &null_byte);
|
||||||
if (!pool_id || pool_id >= POOL_ID_MAX || !inode_num || null_byte != 0)
|
if (scanned != 2 || !pool_id || pool_id >= POOL_ID_MAX || !inode_num)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Bad etcd key %s, ignoring\n", key.c_str());
|
fprintf(stderr, "Bad etcd key %s, ignoring\n", key.c_str());
|
||||||
}
|
}
|
||||||
|
@ -360,8 +360,8 @@ void nfs_proxy_t::parse_stats(etcd_kv_t & kv)
|
||||||
{
|
{
|
||||||
pool_id_t pool_id = 0;
|
pool_id_t pool_id = 0;
|
||||||
char null_byte = 0;
|
char null_byte = 0;
|
||||||
sscanf(key.c_str() + cli->st_cli.etcd_prefix.length()+12, "%u%c", &pool_id, &null_byte);
|
int scanned = sscanf(key.c_str() + cli->st_cli.etcd_prefix.length()+12, "%u%c", &pool_id, &null_byte);
|
||||||
if (!pool_id || pool_id >= POOL_ID_MAX)
|
if (scanned != 1 || !pool_id || pool_id >= POOL_ID_MAX)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Bad etcd key %s, ignoring\n", key.c_str());
|
fprintf(stderr, "Bad etcd key %s, ignoring\n", key.c_str());
|
||||||
}
|
}
|
||||||
|
|
|
@ -967,8 +967,8 @@ void osd_t::report_pg_states()
|
||||||
pool_id_t pool_id = 0;
|
pool_id_t pool_id = 0;
|
||||||
pg_num_t pg_num = 0;
|
pg_num_t pg_num = 0;
|
||||||
char null_byte = 0;
|
char null_byte = 0;
|
||||||
sscanf(kv.key.c_str() + st_cli.etcd_prefix.length()+10, "%u/%u%c", &pool_id, &pg_num, &null_byte);
|
int scanned = sscanf(kv.key.c_str() + st_cli.etcd_prefix.length()+10, "%u/%u%c", &pool_id, &pg_num, &null_byte);
|
||||||
if (null_byte == 0)
|
if (scanned == 2)
|
||||||
{
|
{
|
||||||
auto pg_it = pgs.find({ .pool_id = pool_id, .pg_num = pg_num });
|
auto pg_it = pgs.find({ .pool_id = pool_id, .pg_num = pg_num });
|
||||||
if (pg_it != pgs.end() && pg_it->second.state != PG_OFFLINE && pg_it->second.state != PG_STARTING &&
|
if (pg_it != pgs.end() && pg_it->second.state != PG_OFFLINE && pg_it->second.state != PG_STARTING &&
|
||||||
|
|
|
@ -493,6 +493,10 @@ static int vitastor_file_open(BlockDriverState *bs, QDict *options, int flags, E
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
bs->total_sectors = client->size / BDRV_SECTOR_SIZE;
|
bs->total_sectors = client->size / BDRV_SECTOR_SIZE;
|
||||||
|
#if QEMU_VERSION_MAJOR > 5 || QEMU_VERSION_MAJOR == 5 && QEMU_VERSION_MINOR >= 1
|
||||||
|
/* When extending regular files, we get zeros from the OS */
|
||||||
|
bs->supported_truncate_flags = BDRV_REQ_ZERO_WRITE;
|
||||||
|
#endif
|
||||||
//client->aio_context = bdrv_get_aio_context(bs);
|
//client->aio_context = bdrv_get_aio_context(bs);
|
||||||
qdict_del(options, "use-rdma");
|
qdict_del(options, "use-rdma");
|
||||||
qdict_del(options, "rdma-mtu");
|
qdict_del(options, "rdma-mtu");
|
||||||
|
|
Loading…
Reference in New Issue