Change st_cli to pointer
This commit is contained in:
@@ -53,23 +53,24 @@ cluster_client_t::cluster_client_t(ring_loop_t *ringloop, timerfd_manager_t *tfd
|
||||
};
|
||||
msgr.parse_config(config);
|
||||
|
||||
st_cli.tfd = tfd;
|
||||
st_cli.on_load_config_hook = [this](json11::Json::object & cfg) { on_load_config_hook(cfg); };
|
||||
st_cli.on_change_osd_state_hook = [this](uint64_t peer_osd) { on_change_osd_state_hook(peer_osd); };
|
||||
st_cli.on_change_pool_config_hook = [this]() { on_change_pool_config_hook(); };
|
||||
st_cli.on_change_pg_config_hook = [this]() { on_change_pool_config_hook(); };
|
||||
st_cli.on_change_pg_state_hook = [this](pool_id_t pool_id, pg_num_t pg_num, osd_num_t prev_primary) { on_change_pg_state_hook(pool_id, pg_num, prev_primary); };
|
||||
st_cli.on_change_node_placement_hook = [this]() { on_change_node_placement_hook(); };
|
||||
st_cli.on_load_pgs_hook = [this](bool success) { on_load_pgs_hook(success); };
|
||||
st_cli.on_reload_hook = [this]() { st_cli.load_global_config(); };
|
||||
st_cli = std::make_unique<etcd_state_client_t>();
|
||||
st_cli->tfd = tfd;
|
||||
st_cli->on_load_config_hook = [this](json11::Json::object & cfg) { on_load_config_hook(cfg); };
|
||||
st_cli->on_change_osd_state_hook = [this](uint64_t peer_osd) { on_change_osd_state_hook(peer_osd); };
|
||||
st_cli->on_change_pool_config_hook = [this]() { on_change_pool_config_hook(); };
|
||||
st_cli->on_change_pg_config_hook = [this]() { on_change_pool_config_hook(); };
|
||||
st_cli->on_change_pg_state_hook = [this](pool_id_t pool_id, pg_num_t pg_num, osd_num_t prev_primary) { on_change_pg_state_hook(pool_id, pg_num, prev_primary); };
|
||||
st_cli->on_change_node_placement_hook = [this]() { on_change_node_placement_hook(); };
|
||||
st_cli->on_load_pgs_hook = [this](bool success) { on_load_pgs_hook(success); };
|
||||
st_cli->on_reload_hook = [this]() { st_cli->load_global_config(); };
|
||||
|
||||
st_cli.parse_config(config);
|
||||
st_cli.infinite_start = false;
|
||||
st_cli->parse_config(config);
|
||||
st_cli->infinite_start = false;
|
||||
if (!config["client_infinite_start"].is_null())
|
||||
{
|
||||
st_cli.infinite_start = config["client_infinite_start"].bool_value();
|
||||
st_cli->infinite_start = config["client_infinite_start"].bool_value();
|
||||
}
|
||||
st_cli.load_global_config();
|
||||
st_cli->load_global_config();
|
||||
|
||||
scrap_buffer_size = SCRAP_BUFFER_SIZE;
|
||||
scrap_buffer = malloc_or_die(scrap_buffer_size);
|
||||
@@ -469,7 +470,7 @@ void cluster_client_t::on_load_config_hook(json11::Json::object & etcd_global_co
|
||||
auto etcd_report_interval = config["etcd_report_interval"].uint64_value();
|
||||
if (!etcd_report_interval)
|
||||
etcd_report_interval = 5;
|
||||
client_wait_up_timeout = 1+etcd_report_interval+(st_cli.max_etcd_attempts*(2*st_cli.etcd_quick_timeout)+999)/1000;
|
||||
client_wait_up_timeout = 1+etcd_report_interval+(st_cli->max_etcd_attempts*(2*st_cli->etcd_quick_timeout)+999)/1000;
|
||||
}
|
||||
// log_level
|
||||
log_level = config["log_level"].uint64_value();
|
||||
@@ -482,8 +483,8 @@ void cluster_client_t::on_load_config_hook(json11::Json::object & etcd_global_co
|
||||
client_hostname = new_hostname;
|
||||
}
|
||||
msgr.parse_config(config);
|
||||
st_cli.parse_config(config);
|
||||
st_cli.load_pgs();
|
||||
st_cli->parse_config(config);
|
||||
st_cli->load_pgs();
|
||||
}
|
||||
|
||||
osd_num_t cluster_client_t::select_random_osd(const std::vector<osd_num_t> & osds)
|
||||
@@ -492,7 +493,7 @@ osd_num_t cluster_client_t::select_random_osd(const std::vector<osd_num_t> & osd
|
||||
int alive_count = 0;
|
||||
for (auto & osd_num: osds)
|
||||
{
|
||||
if (!st_cli.peer_states[osd_num].is_null())
|
||||
if (!st_cli->peer_states[osd_num].is_null())
|
||||
alive_set[alive_count++] = osd_num;
|
||||
}
|
||||
if (!alive_count)
|
||||
@@ -509,7 +510,7 @@ osd_num_t cluster_client_t::select_nearest_osd(const std::vector<osd_num_t> & os
|
||||
while (self_tree_metrics.find(cur_id) == self_tree_metrics.end())
|
||||
{
|
||||
self_tree_metrics[cur_id] = metric++;
|
||||
json11::Json cur_placement = st_cli.node_placement[cur_id];
|
||||
json11::Json cur_placement = st_cli->node_placement[cur_id];
|
||||
cur_id = cur_placement["parent"].string_value();
|
||||
}
|
||||
if (cur_id != "")
|
||||
@@ -529,7 +530,7 @@ osd_num_t cluster_client_t::select_nearest_osd(const std::vector<osd_num_t> & os
|
||||
}
|
||||
else
|
||||
{
|
||||
auto & peer_state = st_cli.peer_states[osd_num];
|
||||
auto & peer_state = st_cli->peer_states[osd_num];
|
||||
if (!peer_state.is_null())
|
||||
{
|
||||
metric = self_tree_metrics[""];
|
||||
@@ -539,7 +540,7 @@ osd_num_t cluster_client_t::select_nearest_osd(const std::vector<osd_num_t> & os
|
||||
while (seen.find(cur_id) == seen.end())
|
||||
{
|
||||
seen.insert(cur_id);
|
||||
json11::Json cur_placement = st_cli.node_placement[cur_id];
|
||||
json11::Json cur_placement = st_cli->node_placement[cur_id];
|
||||
std::string cur_parent = cur_placement["parent"].string_value();
|
||||
cur_id = (!first || cur_parent != "" ? cur_parent : peer_state["host"].string_value());
|
||||
first = false;
|
||||
@@ -564,7 +565,7 @@ osd_num_t cluster_client_t::select_nearest_osd(const std::vector<osd_num_t> & os
|
||||
|
||||
void cluster_client_t::on_load_pgs_hook(bool success)
|
||||
{
|
||||
for (auto & pool_item: st_cli.pool_config)
|
||||
for (auto & pool_item: st_cli->pool_config)
|
||||
{
|
||||
pg_counts[pool_item.first] = pool_item.second.real_pg_count;
|
||||
}
|
||||
@@ -584,7 +585,7 @@ void cluster_client_t::on_load_pgs_hook(bool success)
|
||||
|
||||
void cluster_client_t::on_change_pool_config_hook()
|
||||
{
|
||||
for (auto & pool_item: st_cli.pool_config)
|
||||
for (auto & pool_item: st_cli->pool_config)
|
||||
{
|
||||
if (pg_counts[pool_item.first] != pool_item.second.real_pg_count)
|
||||
{
|
||||
@@ -612,7 +613,7 @@ void cluster_client_t::on_change_pool_config_hook()
|
||||
|
||||
void cluster_client_t::on_change_pg_state_hook(pool_id_t pool_id, pg_num_t pg_num, osd_num_t prev_primary)
|
||||
{
|
||||
auto & pg_cfg = st_cli.pool_config[pool_id].pg_config[pg_num];
|
||||
auto & pg_cfg = st_cli->pool_config[pool_id].pg_config[pg_num];
|
||||
if (pg_cfg.cur_primary != prev_primary)
|
||||
{
|
||||
// Repeat this PG operations because an OSD which stopped being primary may not fsync operations
|
||||
@@ -630,8 +631,8 @@ bool cluster_client_t::get_immediate_commit(uint64_t inode)
|
||||
pool_id_t pool_id = INODE_POOL(inode);
|
||||
if (!pool_id)
|
||||
return true;
|
||||
auto pool_it = st_cli.pool_config.find(pool_id);
|
||||
if (pool_it == st_cli.pool_config.end())
|
||||
auto pool_it = st_cli->pool_config.find(pool_id);
|
||||
if (pool_it == st_cli->pool_config.end())
|
||||
return true;
|
||||
return pool_it->second.immediate_commit == IMMEDIATE_ALL;
|
||||
}
|
||||
@@ -641,7 +642,7 @@ void cluster_client_t::on_change_osd_state_hook(uint64_t peer_osd)
|
||||
osd_tree_metrics.erase(peer_osd);
|
||||
if (msgr.wanted_peers.find(peer_osd) != msgr.wanted_peers.end())
|
||||
{
|
||||
msgr.connect_peer(peer_osd, st_cli.peer_states[peer_osd]);
|
||||
msgr.connect_peer(peer_osd, st_cli->peer_states[peer_osd]);
|
||||
continue_lists();
|
||||
}
|
||||
}
|
||||
@@ -936,8 +937,8 @@ bool cluster_client_t::check_rw(cluster_op_t *op)
|
||||
cb(op);
|
||||
return false;
|
||||
}
|
||||
auto pool_it = st_cli.pool_config.find(pool_id);
|
||||
if (pool_it == st_cli.pool_config.end() || pool_it->second.real_pg_count == 0)
|
||||
auto pool_it = st_cli->pool_config.find(pool_id);
|
||||
if (pool_it == st_cli->pool_config.end() || pool_it->second.real_pg_count == 0)
|
||||
{
|
||||
// Pools are loaded, but this one is unknown
|
||||
op->retval = -EINVAL;
|
||||
@@ -960,8 +961,8 @@ bool cluster_client_t::check_rw(cluster_op_t *op)
|
||||
}
|
||||
if ((op->opcode == OSD_OP_WRITE || op->opcode == OSD_OP_DELETE) && !(op->flags & OSD_OP_IGNORE_READONLY))
|
||||
{
|
||||
auto ino_it = st_cli.inode_config.find(op->inode);
|
||||
if (ino_it != st_cli.inode_config.end() && ino_it->second.readonly)
|
||||
auto ino_it = st_cli->inode_config.find(op->inode);
|
||||
if (ino_it != st_cli->inode_config.end() && ino_it->second.readonly)
|
||||
{
|
||||
op->retval = -EROFS;
|
||||
auto cb = std::move(op->callback);
|
||||
@@ -972,15 +973,15 @@ bool cluster_client_t::check_rw(cluster_op_t *op)
|
||||
op->deoptimise_snapshot = false;
|
||||
if (enable_writeback && (op->opcode == OSD_OP_READ || op->opcode == OSD_OP_READ_BITMAP || op->opcode == OSD_OP_READ_CHAIN_BITMAP))
|
||||
{
|
||||
auto ino_it = st_cli.inode_config.find(op->inode);
|
||||
if (ino_it != st_cli.inode_config.end())
|
||||
auto ino_it = st_cli->inode_config.find(op->inode);
|
||||
if (ino_it != st_cli->inode_config.end())
|
||||
{
|
||||
int chain_size = 0;
|
||||
while (ino_it != st_cli.inode_config.end() && ino_it->second.parent_id)
|
||||
while (ino_it != st_cli->inode_config.end() && ino_it->second.parent_id)
|
||||
{
|
||||
// Check for loops - FIXME check it in etcd_state_client
|
||||
if (ino_it->second.parent_id == op->inode ||
|
||||
chain_size > st_cli.inode_config.size())
|
||||
chain_size > st_cli->inode_config.size())
|
||||
{
|
||||
op->retval = -EINVAL;
|
||||
auto cb = std::move(op->callback);
|
||||
@@ -995,7 +996,7 @@ bool cluster_client_t::check_rw(cluster_op_t *op)
|
||||
break;
|
||||
}
|
||||
chain_size++;
|
||||
ino_it = st_cli.inode_config.find(ino_it->second.parent_id);
|
||||
ino_it = st_cli->inode_config.find(ino_it->second.parent_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1014,7 +1015,7 @@ void cluster_client_t::execute_raw(osd_num_t osd_num, osd_op_t *op)
|
||||
else
|
||||
{
|
||||
if (msgr.wanted_peers.find(osd_num) == msgr.wanted_peers.end())
|
||||
msgr.connect_peer(osd_num, st_cli.peer_states[osd_num]);
|
||||
msgr.connect_peer(osd_num, st_cli->peer_states[osd_num]);
|
||||
raw_ops.emplace(osd_num, op);
|
||||
}
|
||||
}
|
||||
@@ -1129,25 +1130,25 @@ resume_2:
|
||||
if (op->opcode == OSD_OP_READ || op->opcode == OSD_OP_READ_CHAIN_BITMAP)
|
||||
{
|
||||
// Check parent inode
|
||||
auto ino_it = st_cli.inode_config.find(op->cur_inode);
|
||||
auto ino_it = st_cli->inode_config.find(op->cur_inode);
|
||||
// Skip parents from the same pool
|
||||
int skipped = 0;
|
||||
while (!op->deoptimise_snapshot &&
|
||||
ino_it != st_cli.inode_config.end() && ino_it->second.parent_id &&
|
||||
ino_it != st_cli->inode_config.end() && ino_it->second.parent_id &&
|
||||
INODE_POOL(ino_it->second.parent_id) == INODE_POOL(op->cur_inode))
|
||||
{
|
||||
// Check for loops - FIXME check it in etcd_state_client
|
||||
if (ino_it->second.parent_id == op->inode ||
|
||||
skipped > st_cli.inode_config.size())
|
||||
skipped > st_cli->inode_config.size())
|
||||
{
|
||||
op->retval = -EINVAL;
|
||||
erase_op(op);
|
||||
return 1;
|
||||
}
|
||||
skipped++;
|
||||
ino_it = st_cli.inode_config.find(ino_it->second.parent_id);
|
||||
ino_it = st_cli->inode_config.find(ino_it->second.parent_id);
|
||||
}
|
||||
if (ino_it != st_cli.inode_config.end() &&
|
||||
if (ino_it != st_cli->inode_config.end() &&
|
||||
ino_it->second.parent_id &&
|
||||
ino_it->second.parent_id != op->inode)
|
||||
{
|
||||
@@ -1161,7 +1162,7 @@ resume_2:
|
||||
op->retval = op->len;
|
||||
if (op->opcode == OSD_OP_READ_BITMAP || op->opcode == OSD_OP_READ_CHAIN_BITMAP)
|
||||
{
|
||||
auto & pool_cfg = st_cli.pool_config.at(INODE_POOL(op->inode));
|
||||
auto & pool_cfg = st_cli->pool_config.at(INODE_POOL(op->inode));
|
||||
op->retval = op->len / pool_cfg.bitmap_granularity;
|
||||
}
|
||||
if (op->flush_id)
|
||||
@@ -1247,7 +1248,7 @@ void cluster_client_t::slice_rw(cluster_op_t *op)
|
||||
{
|
||||
// Slice the request into individual object stripe requests
|
||||
// Primary OSDs still operate individual stripes, but their size is multiplied by PG minsize in case of EC
|
||||
auto & pool_cfg = st_cli.pool_config.at(INODE_POOL(op->cur_inode));
|
||||
auto & pool_cfg = st_cli->pool_config.at(INODE_POOL(op->cur_inode));
|
||||
uint32_t pg_data_size = (pool_cfg.scheme == POOL_SCHEME_REPLICATED ? 1 : pool_cfg.pg_size-pool_cfg.parity_chunks);
|
||||
uint64_t pg_block_size = pool_cfg.data_block_size * pg_data_size;
|
||||
uint64_t first_stripe = (op->offset / pg_block_size) * pg_block_size;
|
||||
@@ -1346,7 +1347,7 @@ bool cluster_client_t::affects_pg(uint64_t inode, uint64_t offset, uint64_t len,
|
||||
{
|
||||
return false;
|
||||
}
|
||||
auto & pool_cfg = st_cli.pool_config.at(INODE_POOL(inode));
|
||||
auto & pool_cfg = st_cli->pool_config.at(INODE_POOL(inode));
|
||||
uint32_t pg_data_size = (pool_cfg.scheme == POOL_SCHEME_REPLICATED ? 1 : pool_cfg.pg_size-pool_cfg.parity_chunks);
|
||||
uint64_t pg_block_size = pool_cfg.data_block_size * pg_data_size;
|
||||
uint64_t first_stripe = (offset / pg_block_size) * pg_block_size;
|
||||
@@ -1365,7 +1366,7 @@ bool cluster_client_t::affects_pg(uint64_t inode, uint64_t offset, uint64_t len,
|
||||
|
||||
bool cluster_client_t::affects_osd(uint64_t inode, uint64_t offset, uint64_t len, osd_num_t osd)
|
||||
{
|
||||
auto & pool_cfg = st_cli.pool_config.at(INODE_POOL(inode));
|
||||
auto & pool_cfg = st_cli->pool_config.at(INODE_POOL(inode));
|
||||
uint32_t pg_data_size = (pool_cfg.scheme == POOL_SCHEME_REPLICATED ? 1 : pool_cfg.pg_size-pool_cfg.parity_chunks);
|
||||
uint64_t pg_block_size = pool_cfg.data_block_size * pg_data_size;
|
||||
uint64_t first_stripe = (offset / pg_block_size) * pg_block_size;
|
||||
@@ -1389,7 +1390,7 @@ int cluster_client_t::try_send(cluster_op_t *op, int i, std::function<void(osd_o
|
||||
init_msgr();
|
||||
}
|
||||
auto part = &op->parts[i];
|
||||
auto & pool_cfg = st_cli.pool_config.at(INODE_POOL(op->cur_inode));
|
||||
auto & pool_cfg = st_cli->pool_config.at(INODE_POOL(op->cur_inode));
|
||||
auto pg_it = pool_cfg.pg_config.find(part->pg_num);
|
||||
if (pg_it != pool_cfg.pg_config.end() &&
|
||||
!pg_it->second.pause && pg_it->second.cur_primary &&
|
||||
@@ -1420,8 +1421,8 @@ int cluster_client_t::try_send(cluster_op_t *op, int i, std::function<void(osd_o
|
||||
uint64_t meta_rev = 0;
|
||||
if (op->opcode != OSD_OP_READ_BITMAP && op->opcode != OSD_OP_DELETE && !op->deoptimise_snapshot)
|
||||
{
|
||||
auto ino_it = st_cli.inode_config.find(op->cur_inode);
|
||||
if (ino_it != st_cli.inode_config.end())
|
||||
auto ino_it = st_cli->inode_config.find(op->cur_inode);
|
||||
if (ino_it != st_cli->inode_config.end())
|
||||
meta_rev = ino_it->second.mod_revision;
|
||||
}
|
||||
part->op = (osd_op_t){
|
||||
@@ -1453,7 +1454,7 @@ int cluster_client_t::try_send(cluster_op_t *op, int i, std::function<void(osd_o
|
||||
}
|
||||
else if (msgr.wanted_peers.find(primary_osd) == msgr.wanted_peers.end())
|
||||
{
|
||||
msgr.connect_peer(primary_osd, st_cli.peer_states[primary_osd]);
|
||||
msgr.connect_peer(primary_osd, st_cli->peer_states[primary_osd]);
|
||||
return TRY_SEND_CONNECTING;
|
||||
}
|
||||
}
|
||||
@@ -1648,7 +1649,7 @@ void cluster_client_t::handle_op_part(cluster_op_part_t *part)
|
||||
void cluster_client_t::copy_part_bitmap(cluster_op_t *op, cluster_op_part_t *part)
|
||||
{
|
||||
// Copy (OR) bitmap
|
||||
auto & pool_cfg = st_cli.pool_config.at(INODE_POOL(op->cur_inode));
|
||||
auto & pool_cfg = st_cli->pool_config.at(INODE_POOL(op->cur_inode));
|
||||
uint32_t pg_block_size = pool_cfg.data_block_size * (
|
||||
pool_cfg.scheme == POOL_SCHEME_REPLICATED ? 1 : pool_cfg.pg_size-pool_cfg.parity_chunks
|
||||
);
|
||||
|
||||
@@ -131,7 +131,7 @@ class __attribute__((visibility("default"))) cluster_client_t
|
||||
bool msgr_initialized = false;
|
||||
|
||||
public:
|
||||
etcd_state_client_t st_cli;
|
||||
std::unique_ptr<etcd_state_client_t> st_cli;
|
||||
|
||||
osd_messenger_t msgr;
|
||||
void init_msgr();
|
||||
|
||||
@@ -63,14 +63,14 @@ void cluster_client_t::list_inode(inode_t inode, uint64_t min_offset, uint64_t m
|
||||
{
|
||||
init_msgr();
|
||||
pool_id_t pool_id = INODE_POOL(inode);
|
||||
if (!pool_id || st_cli.pool_config.find(pool_id) == st_cli.pool_config.end())
|
||||
if (!pool_id || st_cli->pool_config.find(pool_id) == st_cli->pool_config.end())
|
||||
{
|
||||
if (log_level > 0)
|
||||
fprintf(stderr, "Pool %u does not exist\n", pool_id);
|
||||
pg_callback(-EINVAL, 0, 0, std::set<object_id>());
|
||||
return;
|
||||
}
|
||||
auto pg_stripe_size = st_cli.pool_config.at(pool_id).pg_stripe_size;
|
||||
auto pg_stripe_size = st_cli->pool_config.at(pool_id).pg_stripe_size;
|
||||
if (min_offset)
|
||||
min_offset = (min_offset/pg_stripe_size) * pg_stripe_size;
|
||||
inode_list_t *lst = new inode_list_t();
|
||||
@@ -110,13 +110,13 @@ bool cluster_client_t::continue_listing(inode_list_t *lst)
|
||||
|
||||
bool cluster_client_t::restart_listing(inode_list_t* lst)
|
||||
{
|
||||
auto pool_it = st_cli.pool_config.find(lst->pool_id);
|
||||
auto pool_it = st_cli->pool_config.find(lst->pool_id);
|
||||
// We want listing to be consistent. To achieve it we should:
|
||||
// 1) retry listing of each PG if its state changes
|
||||
// 2) abort listing if PG count changes during listing
|
||||
// 3) ideally, only talk to the primary OSD - this will be done separately
|
||||
// So first we add all PGs without checking their state
|
||||
if (pool_it == st_cli.pool_config.end() ||
|
||||
if (pool_it == st_cli->pool_config.end() ||
|
||||
lst->real_pg_count != pool_it->second.real_pg_count)
|
||||
{
|
||||
for (auto pg: lst->pgs)
|
||||
@@ -136,7 +136,7 @@ bool cluster_client_t::restart_listing(inode_list_t* lst)
|
||||
fprintf(stderr, "PG count in pool %u changed during listing\n", lst->pool_id);
|
||||
}
|
||||
lst->pgs.clear();
|
||||
if (pool_it == st_cli.pool_config.end())
|
||||
if (pool_it == st_cli->pool_config.end())
|
||||
{
|
||||
// Unknown pool
|
||||
lst->callback(-EINVAL, 0, 0, std::set<object_id>());
|
||||
@@ -248,7 +248,7 @@ void cluster_client_t::set_list_retry_timeout(int ms, timespec new_time)
|
||||
|
||||
int cluster_client_t::start_pg_listing(inode_list_pg_t *pg)
|
||||
{
|
||||
auto & pool_cfg = st_cli.pool_config.at(pg->lst->pool_id);
|
||||
auto & pool_cfg = st_cli->pool_config.at(pg->lst->pool_id);
|
||||
auto pg_it = pool_cfg.pg_config.find(pg->pg_num);
|
||||
assert(pg->lst->real_pg_count == pool_cfg.real_pg_count);
|
||||
if (pg_it == pool_cfg.pg_config.end() ||
|
||||
@@ -277,7 +277,7 @@ int cluster_client_t::start_pg_listing(inode_list_pg_t *pg)
|
||||
for (auto peer_it = all_peers.begin(); peer_it != all_peers.end(); )
|
||||
{
|
||||
if (*peer_it != pg_it->second.cur_primary &&
|
||||
st_cli.peer_states[*peer_it].is_null())
|
||||
st_cli->peer_states[*peer_it].is_null())
|
||||
{
|
||||
pg->inactive_osds.push_back(*peer_it);
|
||||
all_peers.erase(peer_it++);
|
||||
@@ -298,11 +298,11 @@ int cluster_client_t::start_pg_listing(inode_list_pg_t *pg)
|
||||
if (msgr.osd_peers.find(peer_osd) == msgr.osd_peers.end())
|
||||
{
|
||||
// Initiate connection
|
||||
if (st_cli.peer_states[peer_osd].is_null())
|
||||
if (st_cli->peer_states[peer_osd].is_null())
|
||||
{
|
||||
return LIST_PG_WAIT_ACTIVE;
|
||||
}
|
||||
msgr.connect_peer(peer_osd, st_cli.peer_states[peer_osd]);
|
||||
msgr.connect_peer(peer_osd, st_cli->peer_states[peer_osd]);
|
||||
conn = false;
|
||||
}
|
||||
}
|
||||
@@ -336,7 +336,7 @@ void cluster_client_t::send_list(inode_list_osd_t *cur_list)
|
||||
if (!cur_list->pg->inflight_ops)
|
||||
cur_list->pg->lst->inflight_pgs++;
|
||||
cur_list->pg->inflight_ops++;
|
||||
auto & pool_cfg = st_cli.pool_config[cur_list->pg->lst->pool_id];
|
||||
auto & pool_cfg = st_cli->pool_config[cur_list->pg->lst->pool_id];
|
||||
osd_op_t *op = new osd_op_t();
|
||||
op->op_type = OSD_OP_OUT;
|
||||
// Already checked that it exists above, but anyway
|
||||
|
||||
@@ -525,7 +525,7 @@ help:
|
||||
break;
|
||||
ringloop->wait();
|
||||
}
|
||||
watch = cli->st_cli.watch_inode(image_name);
|
||||
watch = cli->st_cli->watch_inode(image_name);
|
||||
device_size = watch->cfg.size;
|
||||
if (!watch->cfg.num || !device_size)
|
||||
{
|
||||
|
||||
@@ -273,7 +273,7 @@ help:
|
||||
}
|
||||
if (!inode)
|
||||
{
|
||||
watch = cli->st_cli.watch_inode(image_name);
|
||||
watch = cli->st_cli->watch_inode(image_name);
|
||||
device_size = watch->cfg.size;
|
||||
if (!watch->cfg.num || !device_size)
|
||||
{
|
||||
@@ -283,8 +283,8 @@ help:
|
||||
}
|
||||
}
|
||||
const bool writeback = !cli->get_immediate_commit(inode ? inode : watch->cfg.num);
|
||||
auto pool_it = cli->st_cli.pool_config.find(INODE_POOL(inode ? inode : watch->cfg.num));
|
||||
if (pool_it == cli->st_cli.pool_config.end())
|
||||
auto pool_it = cli->st_cli->pool_config.find(INODE_POOL(inode ? inode : watch->cfg.num));
|
||||
if (pool_it == cli->st_cli->pool_config.end())
|
||||
{
|
||||
fprintf(stderr, "Pool %u does not exist\n", INODE_POOL(inode ? inode : watch->cfg.num));
|
||||
exit(1);
|
||||
|
||||
@@ -396,7 +396,7 @@ void vitastor_c_watch_inode(vitastor_c *client, char *image, VitastorIOHandler c
|
||||
{
|
||||
client->cli->on_ready([=]()
|
||||
{
|
||||
auto watch = client->cli->st_cli.watch_inode(std::string(image));
|
||||
auto watch = client->cli->st_cli->watch_inode(std::string(image));
|
||||
cb(opaque, (long)watch);
|
||||
});
|
||||
if (client->ringloop)
|
||||
@@ -407,7 +407,7 @@ void vitastor_c_watch_inode(vitastor_c *client, char *image, VitastorIOHandler c
|
||||
|
||||
void vitastor_c_close_watch(vitastor_c *client, void *handle)
|
||||
{
|
||||
client->cli->st_cli.close_watch((inode_watch_t*)handle);
|
||||
client->cli->st_cli->close_watch((inode_watch_t*)handle);
|
||||
}
|
||||
|
||||
uint64_t vitastor_c_inode_get_size(void *handle)
|
||||
@@ -424,8 +424,8 @@ uint64_t vitastor_c_inode_get_num(void *handle)
|
||||
|
||||
uint32_t vitastor_c_inode_get_block_size(vitastor_c *client, uint64_t inode_num)
|
||||
{
|
||||
auto pool_it = client->cli->st_cli.pool_config.find(INODE_POOL(inode_num));
|
||||
if (pool_it == client->cli->st_cli.pool_config.end())
|
||||
auto pool_it = client->cli->st_cli->pool_config.find(INODE_POOL(inode_num));
|
||||
if (pool_it == client->cli->st_cli->pool_config.end())
|
||||
return 0;
|
||||
auto & pool_cfg = pool_it->second;
|
||||
uint32_t pg_data_size = (pool_cfg.scheme == POOL_SCHEME_REPLICATED ? 1 : pool_cfg.pg_size-pool_cfg.parity_chunks);
|
||||
@@ -434,8 +434,8 @@ uint32_t vitastor_c_inode_get_block_size(vitastor_c *client, uint64_t inode_num)
|
||||
|
||||
uint32_t vitastor_c_inode_get_bitmap_granularity(vitastor_c *client, uint64_t inode_num)
|
||||
{
|
||||
auto pool_it = client->cli->st_cli.pool_config.find(INODE_POOL(inode_num));
|
||||
if (pool_it == client->cli->st_cli.pool_config.end())
|
||||
auto pool_it = client->cli->st_cli->pool_config.find(INODE_POOL(inode_num));
|
||||
if (pool_it == client->cli->st_cli->pool_config.end())
|
||||
return 0;
|
||||
// FIXME: READ_BITMAP may fails if parent bitmap granularity differs from inode bitmap granularity
|
||||
return pool_it->second.bitmap_granularity;
|
||||
@@ -471,8 +471,8 @@ uint64_t vitastor_c_inode_get_mod_revision(void *handle)
|
||||
|
||||
uint32_t vitastor_c_inode_get_immediate_commit(vitastor_c *client, uint64_t inode_num)
|
||||
{
|
||||
auto pool_it = client->cli->st_cli.pool_config.find(INODE_POOL(inode_num));
|
||||
if (pool_it == client->cli->st_cli.pool_config.end())
|
||||
auto pool_it = client->cli->st_cli->pool_config.find(INODE_POOL(inode_num));
|
||||
if (pool_it == client->cli->st_cli->pool_config.end())
|
||||
return 0;
|
||||
return pool_it->second.immediate_commit;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ struct alloc_osd_t
|
||||
{ "target", "VERSION" },
|
||||
{ "version", 0 },
|
||||
{ "key", base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+"/osd/stats/"+std::to_string(new_id)
|
||||
parent->cli->st_cli->etcd_prefix+"/osd/stats/"+std::to_string(new_id)
|
||||
) },
|
||||
},
|
||||
} },
|
||||
@@ -43,7 +43,7 @@ struct alloc_osd_t
|
||||
json11::Json::object {
|
||||
{ "request_put", json11::Json::object {
|
||||
{ "key", base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+"/osd/stats/"+std::to_string(new_id)
|
||||
parent->cli->st_cli->etcd_prefix+"/osd/stats/"+std::to_string(new_id)
|
||||
) },
|
||||
{ "value", base64_encode("{}") },
|
||||
} },
|
||||
@@ -52,8 +52,8 @@ struct alloc_osd_t
|
||||
{ "failure", json11::Json::array {
|
||||
json11::Json::object {
|
||||
{ "request_range", json11::Json::object {
|
||||
{ "key", base64_encode(parent->cli->st_cli.etcd_prefix+"/osd/stats/") },
|
||||
{ "range_end", base64_encode(parent->cli->st_cli.etcd_prefix+"/osd/stats0") },
|
||||
{ "key", base64_encode(parent->cli->st_cli->etcd_prefix+"/osd/stats/") },
|
||||
{ "range_end", base64_encode(parent->cli->st_cli->etcd_prefix+"/osd/stats0") },
|
||||
{ "keys_only", true },
|
||||
} },
|
||||
},
|
||||
|
||||
+13
-13
@@ -8,8 +8,8 @@
|
||||
|
||||
void cli_tool_t::change_parent(inode_t cur, inode_t new_parent, cli_result_t *result)
|
||||
{
|
||||
auto cur_cfg_it = cli->st_cli.inode_config.find(cur);
|
||||
if (cur_cfg_it == cli->st_cli.inode_config.end())
|
||||
auto cur_cfg_it = cli->st_cli->inode_config.find(cur);
|
||||
if (cur_cfg_it == cli->st_cli->inode_config.end())
|
||||
{
|
||||
char buf[128];
|
||||
snprintf(buf, 128, "Inode 0x%jx disappeared", cur);
|
||||
@@ -18,13 +18,13 @@ void cli_tool_t::change_parent(inode_t cur, inode_t new_parent, cli_result_t *re
|
||||
}
|
||||
inode_config_t new_cfg = cur_cfg_it->second;
|
||||
std::string cur_name = new_cfg.name;
|
||||
std::string cur_cfg_key = base64_encode(cli->st_cli.etcd_prefix+
|
||||
std::string cur_cfg_key = base64_encode(cli->st_cli->etcd_prefix+
|
||||
"/config/inode/"+std::to_string(INODE_POOL(cur))+
|
||||
"/"+std::to_string(INODE_NO_POOL(cur)));
|
||||
new_cfg.parent_id = new_parent;
|
||||
json11::Json::object cur_cfg_json = cli->st_cli.serialize_inode_cfg(&new_cfg);
|
||||
json11::Json::object cur_cfg_json = cli->st_cli->serialize_inode_cfg(&new_cfg);
|
||||
waiting++;
|
||||
cli->st_cli.etcd_txn_slow(json11::Json::object {
|
||||
cli->st_cli->etcd_txn_slow(json11::Json::object {
|
||||
{ "compare", json11::Json::array {
|
||||
json11::Json::object {
|
||||
{ "target", "MOD" },
|
||||
@@ -53,8 +53,8 @@ void cli_tool_t::change_parent(inode_t cur, inode_t new_parent, cli_result_t *re
|
||||
}
|
||||
else if (new_parent)
|
||||
{
|
||||
auto new_parent_it = cli->st_cli.inode_config.find(new_parent);
|
||||
std::string new_parent_name = new_parent_it != cli->st_cli.inode_config.end()
|
||||
auto new_parent_it = cli->st_cli->inode_config.find(new_parent);
|
||||
std::string new_parent_name = new_parent_it != cli->st_cli->inode_config.end()
|
||||
? new_parent_it->second.name : "<unknown>";
|
||||
*result = (cli_result_t){
|
||||
.text = "Parent of layer "+cur_name+" (inode "+std::to_string(INODE_NO_POOL(cur))+
|
||||
@@ -77,7 +77,7 @@ void cli_tool_t::change_parent(inode_t cur, inode_t new_parent, cli_result_t *re
|
||||
void cli_tool_t::etcd_txn(json11::Json txn)
|
||||
{
|
||||
waiting++;
|
||||
cli->st_cli.etcd_txn_slow(txn, [this](std::string err, json11::Json res)
|
||||
cli->st_cli->etcd_txn_slow(txn, [this](std::string err, json11::Json res)
|
||||
{
|
||||
waiting--;
|
||||
if (err != "")
|
||||
@@ -91,7 +91,7 @@ void cli_tool_t::etcd_txn(json11::Json txn)
|
||||
|
||||
inode_config_t* cli_tool_t::get_inode_cfg(const std::string & name)
|
||||
{
|
||||
for (auto & ic: cli->st_cli.inode_config)
|
||||
for (auto & ic: cli->st_cli->inode_config)
|
||||
{
|
||||
if (ic.second.name == name)
|
||||
{
|
||||
@@ -171,11 +171,11 @@ void cli_tool_t::iterate_kvs_1(json11::Json kvs, const std::string & prefix, std
|
||||
bool is_pool = prefix == "/pool/stats/";
|
||||
for (auto & kv_item: kvs.array_items())
|
||||
{
|
||||
auto kv = cli->st_cli.parse_etcd_kv(kv_item);
|
||||
auto kv = cli->st_cli->parse_etcd_kv(kv_item);
|
||||
uint64_t num = 0;
|
||||
char null_byte = 0;
|
||||
// OSD or pool number
|
||||
int scanned = sscanf(kv.key.substr(cli->st_cli.etcd_prefix.size() + prefix.size()).c_str(), "%ju%c", &num, &null_byte);
|
||||
int scanned = sscanf(kv.key.substr(cli->st_cli->etcd_prefix.size() + prefix.size()).c_str(), "%ju%c", &num, &null_byte);
|
||||
if (scanned != 1 || !num || is_pool && num >= POOL_ID_MAX)
|
||||
{
|
||||
fprintf(stderr, "Invalid key in etcd: %s\n", kv.key.c_str());
|
||||
@@ -190,12 +190,12 @@ void cli_tool_t::iterate_kvs_2(json11::Json kvs, const std::string & prefix, std
|
||||
bool is_inode = prefix == "/config/inode/" || prefix == "/inode/stats/";
|
||||
for (auto & kv_item: kvs.array_items())
|
||||
{
|
||||
auto kv = cli->st_cli.parse_etcd_kv(kv_item);
|
||||
auto kv = cli->st_cli->parse_etcd_kv(kv_item);
|
||||
pool_id_t pool_id = 0;
|
||||
uint64_t num = 0;
|
||||
char null_byte = 0;
|
||||
// pool+pg or pool+inode
|
||||
int scanned = sscanf(kv.key.substr(cli->st_cli.etcd_prefix.size() + prefix.size()).c_str(),
|
||||
int scanned = sscanf(kv.key.substr(cli->st_cli->etcd_prefix.size() + prefix.size()).c_str(),
|
||||
"%u/%ju%c", &pool_id, &num, &null_byte);
|
||||
if (scanned != 2 || !pool_id || is_inode && INODE_POOL(num) || !is_inode && num >= UINT32_MAX)
|
||||
{
|
||||
|
||||
+29
-29
@@ -46,7 +46,7 @@ struct image_creator_t
|
||||
|
||||
void loop()
|
||||
{
|
||||
auto & pools = parent->cli->st_cli.pool_config;
|
||||
auto & pools = parent->cli->st_cli->pool_config;
|
||||
if (state >= 1)
|
||||
goto resume_1;
|
||||
if (image_name == "")
|
||||
@@ -117,7 +117,7 @@ struct image_creator_t
|
||||
goto resume_2;
|
||||
else if (state == 3)
|
||||
goto resume_3;
|
||||
for (auto & ic: parent->cli->st_cli.inode_config)
|
||||
for (auto & ic: parent->cli->st_cli->inode_config)
|
||||
{
|
||||
if (ic.second.name == image_name)
|
||||
{
|
||||
@@ -193,7 +193,7 @@ resume_3:
|
||||
} while (!parent->etcd_result["succeeded"].bool_value());
|
||||
// Save into inode_config for library users to be able to take it from there immediately
|
||||
new_cfg.mod_revision = parent->etcd_result["header"]["revision"].uint64_value();
|
||||
parent->cli->st_cli.insert_inode_config(new_cfg);
|
||||
parent->cli->st_cli->insert_inode_config(new_cfg);
|
||||
result = (cli_result_t){
|
||||
.err = 0,
|
||||
.text = "Image "+image_name+" created",
|
||||
@@ -215,8 +215,8 @@ resume_3:
|
||||
goto resume_3;
|
||||
else if (state == 4)
|
||||
goto resume_4;
|
||||
// FIXME: take all info from etcd requests, not mixed with st_cli.inode_config
|
||||
for (auto & ic: parent->cli->st_cli.inode_config)
|
||||
// FIXME: take all info from etcd requests, not mixed with st_cli->inode_config
|
||||
for (auto & ic: parent->cli->st_cli->inode_config)
|
||||
{
|
||||
if (ic.second.name == image_name+"@"+new_snap)
|
||||
{
|
||||
@@ -271,7 +271,7 @@ resume_4:
|
||||
} while (!parent->etcd_result["succeeded"].bool_value());
|
||||
// Save into inode_config for library users to be able to take it from there immediately
|
||||
new_cfg.mod_revision = parent->etcd_result["header"]["revision"].uint64_value();
|
||||
parent->cli->st_cli.insert_inode_config(new_cfg);
|
||||
parent->cli->st_cli->insert_inode_config(new_cfg);
|
||||
result = (cli_result_t){
|
||||
.err = 0,
|
||||
.text = "Snapshot "+image_name+"@"+new_snap+" created",
|
||||
@@ -291,7 +291,7 @@ resume_4:
|
||||
return json11::Json::object {
|
||||
{ "request_range", json11::Json::object {
|
||||
{ "key", base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+"/index/maxid/"+std::to_string(new_pool_id)
|
||||
parent->cli->st_cli->etcd_prefix+"/index/maxid/"+std::to_string(new_pool_id)
|
||||
) },
|
||||
} },
|
||||
};
|
||||
@@ -303,13 +303,13 @@ resume_4:
|
||||
max_id_mod_rev = 0;
|
||||
if (response["response_range"]["kvs"].array_items().size() > 0)
|
||||
{
|
||||
auto kv = parent->cli->st_cli.parse_etcd_kv(response["response_range"]["kvs"][0]);
|
||||
auto kv = parent->cli->st_cli->parse_etcd_kv(response["response_range"]["kvs"][0]);
|
||||
new_id = 1+INODE_NO_POOL(kv.value.uint64_value());
|
||||
max_id_mod_rev = kv.mod_revision;
|
||||
}
|
||||
// Also check existing inodes - for the case when some inodes are created without changing /index/maxid
|
||||
auto ino_it = parent->cli->st_cli.inode_config.lower_bound(INODE_WITH_POOL(new_pool_id+1, 0));
|
||||
if (ino_it != parent->cli->st_cli.inode_config.begin())
|
||||
auto ino_it = parent->cli->st_cli->inode_config.lower_bound(INODE_WITH_POOL(new_pool_id+1, 0));
|
||||
if (ino_it != parent->cli->st_cli->inode_config.begin())
|
||||
{
|
||||
ino_it--;
|
||||
if (INODE_POOL(ino_it->first) == new_pool_id && new_id < 1+INODE_NO_POOL(ino_it->first))
|
||||
@@ -325,7 +325,7 @@ resume_4:
|
||||
goto resume_3;
|
||||
if (!new_pool_id)
|
||||
{
|
||||
for (auto & ic: parent->cli->st_cli.inode_config)
|
||||
for (auto & ic: parent->cli->st_cli->inode_config)
|
||||
{
|
||||
if (ic.second.name == image_name)
|
||||
{
|
||||
@@ -339,7 +339,7 @@ resume_4:
|
||||
json11::Json::object {
|
||||
{ "request_range", json11::Json::object {
|
||||
{ "key", base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+"/index/image/"+image_name
|
||||
parent->cli->st_cli->etcd_prefix+"/index/image/"+image_name
|
||||
) },
|
||||
} },
|
||||
},
|
||||
@@ -360,7 +360,7 @@ resume_2:
|
||||
cfg_mod_rev = idx_mod_rev = 0;
|
||||
if (parent->etcd_result["responses"][1]["response_range"]["kvs"].array_items().size() == 0)
|
||||
{
|
||||
for (auto & ic: parent->cli->st_cli.inode_config)
|
||||
for (auto & ic: parent->cli->st_cli->inode_config)
|
||||
{
|
||||
if (ic.second.name == image_name)
|
||||
{
|
||||
@@ -377,7 +377,7 @@ resume_2:
|
||||
{
|
||||
// FIXME: Parse kvs in etcd_state_client automatically
|
||||
{
|
||||
auto kv = parent->cli->st_cli.parse_etcd_kv(parent->etcd_result["responses"][1]["response_range"]["kvs"][0]);
|
||||
auto kv = parent->cli->st_cli->parse_etcd_kv(parent->etcd_result["responses"][1]["response_range"]["kvs"][0]);
|
||||
old_id = INODE_NO_POOL(kv.value["id"].uint64_value());
|
||||
old_pool_id = (pool_id_t)kv.value["pool_id"].uint64_value();
|
||||
idx_mod_rev = kv.mod_revision;
|
||||
@@ -393,7 +393,7 @@ resume_2:
|
||||
json11::Json::object {
|
||||
{ "request_range", json11::Json::object {
|
||||
{ "key", base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+"/config/inode/"+
|
||||
parent->cli->st_cli->etcd_prefix+"/config/inode/"+
|
||||
std::to_string(old_pool_id)+"/"+std::to_string(old_id)
|
||||
) },
|
||||
} },
|
||||
@@ -411,7 +411,7 @@ resume_3:
|
||||
return;
|
||||
}
|
||||
{
|
||||
auto kv = parent->cli->st_cli.parse_etcd_kv(parent->etcd_result["responses"][0]["response_range"]["kvs"][0]);
|
||||
auto kv = parent->cli->st_cli->parse_etcd_kv(parent->etcd_result["responses"][0]["response_range"]["kvs"][0]);
|
||||
size = kv.value["size"].uint64_value();
|
||||
new_parent_id = kv.value["parent_id"].uint64_value();
|
||||
uint64_t parent_pool_id = kv.value["parent_pool"].uint64_value();
|
||||
@@ -439,7 +439,7 @@ resume_3:
|
||||
{ "target", "VERSION" },
|
||||
{ "version", 0 },
|
||||
{ "key", base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+"/config/inode/"+
|
||||
parent->cli->st_cli->etcd_prefix+"/config/inode/"+
|
||||
std::to_string(new_pool_id)+"/"+std::to_string(new_id)
|
||||
) },
|
||||
},
|
||||
@@ -447,31 +447,31 @@ resume_3:
|
||||
{ "target", "VERSION" },
|
||||
{ "version", 0 },
|
||||
{ "key", base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+"/index/image/"+image_name+
|
||||
parent->cli->st_cli->etcd_prefix+"/index/image/"+image_name+
|
||||
(new_snap != "" ? "@"+new_snap : "")
|
||||
) },
|
||||
},
|
||||
json11::Json::object {
|
||||
{ "target", "MOD" },
|
||||
{ "mod_revision", max_id_mod_rev },
|
||||
{ "key", base64_encode(parent->cli->st_cli.etcd_prefix+"/index/maxid/"+std::to_string(new_pool_id)) },
|
||||
{ "key", base64_encode(parent->cli->st_cli->etcd_prefix+"/index/maxid/"+std::to_string(new_pool_id)) },
|
||||
},
|
||||
};
|
||||
json11::Json::array success = json11::Json::array {
|
||||
json11::Json::object {
|
||||
{ "request_put", json11::Json::object {
|
||||
{ "key", base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+"/config/inode/"+
|
||||
parent->cli->st_cli->etcd_prefix+"/config/inode/"+
|
||||
std::to_string(new_pool_id)+"/"+std::to_string(new_id)
|
||||
) },
|
||||
{ "value", base64_encode(
|
||||
json11::Json(parent->cli->st_cli.serialize_inode_cfg(&new_cfg)).dump()
|
||||
json11::Json(parent->cli->st_cli->serialize_inode_cfg(&new_cfg)).dump()
|
||||
) },
|
||||
} },
|
||||
},
|
||||
json11::Json::object {
|
||||
{ "request_put", json11::Json::object {
|
||||
{ "key", base64_encode(parent->cli->st_cli.etcd_prefix+"/index/image/"+image_name) },
|
||||
{ "key", base64_encode(parent->cli->st_cli->etcd_prefix+"/index/image/"+image_name) },
|
||||
{ "value", base64_encode(json11::Json(json11::Json::object{
|
||||
{ "id", new_id },
|
||||
{ "pool_id", (uint64_t)new_pool_id },
|
||||
@@ -481,7 +481,7 @@ resume_3:
|
||||
json11::Json::object {
|
||||
{ "request_put", json11::Json::object {
|
||||
{ "key", base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+"/index/maxid/"+
|
||||
parent->cli->st_cli->etcd_prefix+"/index/maxid/"+
|
||||
std::to_string(new_pool_id)
|
||||
) },
|
||||
{ "value", base64_encode(std::to_string(new_id)) }
|
||||
@@ -492,7 +492,7 @@ resume_3:
|
||||
json11::Json::object {
|
||||
{ "request_range", json11::Json::object {
|
||||
{ "key", base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+"/index/image/"+
|
||||
parent->cli->st_cli->etcd_prefix+"/index/image/"+
|
||||
image_name+(new_snap != "" ? "@"+new_snap : "")
|
||||
) },
|
||||
} },
|
||||
@@ -511,29 +511,29 @@ resume_3:
|
||||
{ "target", "MOD" },
|
||||
{ "mod_revision", cfg_mod_rev },
|
||||
{ "key", base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+"/config/inode/"+
|
||||
parent->cli->st_cli->etcd_prefix+"/config/inode/"+
|
||||
std::to_string(old_pool_id)+"/"+std::to_string(old_id)
|
||||
) },
|
||||
});
|
||||
checks.push_back(json11::Json::object {
|
||||
{ "target", "MOD" },
|
||||
{ "mod_revision", idx_mod_rev },
|
||||
{ "key", base64_encode(parent->cli->st_cli.etcd_prefix+"/index/image/"+image_name) }
|
||||
{ "key", base64_encode(parent->cli->st_cli->etcd_prefix+"/index/image/"+image_name) }
|
||||
});
|
||||
success.push_back(json11::Json::object {
|
||||
{ "request_put", json11::Json::object {
|
||||
{ "key", base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+"/config/inode/"+
|
||||
parent->cli->st_cli->etcd_prefix+"/config/inode/"+
|
||||
std::to_string(old_pool_id)+"/"+std::to_string(old_id)
|
||||
) },
|
||||
{ "value", base64_encode(
|
||||
json11::Json(parent->cli->st_cli.serialize_inode_cfg(&snap_cfg)).dump()
|
||||
json11::Json(parent->cli->st_cli->serialize_inode_cfg(&snap_cfg)).dump()
|
||||
) },
|
||||
} },
|
||||
});
|
||||
success.push_back(json11::Json::object {
|
||||
{ "request_put", json11::Json::object {
|
||||
{ "key", base64_encode(parent->cli->st_cli.etcd_prefix+"/index/image/"+image_name+"@"+new_snap) },
|
||||
{ "key", base64_encode(parent->cli->st_cli->etcd_prefix+"/index/image/"+image_name+"@"+new_snap) },
|
||||
{ "value", base64_encode(json11::Json(json11::Json::object{
|
||||
{ "id", old_id },
|
||||
{ "pool_id", (uint64_t)old_pool_id },
|
||||
|
||||
+19
-19
@@ -52,19 +52,19 @@ struct dd_in_info_t
|
||||
in_seekable = true;
|
||||
if (iimg != "")
|
||||
{
|
||||
iwatch = parent->cli->st_cli.watch_inode(iimg);
|
||||
iwatch = parent->cli->st_cli->watch_inode(iimg);
|
||||
if (!iwatch->cfg.num)
|
||||
{
|
||||
result = (cli_result_t){ .err = ENOENT, .text = "Image "+iimg+" does not exist" };
|
||||
parent->cli->st_cli.close_watch(iwatch);
|
||||
parent->cli->st_cli->close_watch(iwatch);
|
||||
iwatch = NULL;
|
||||
return;
|
||||
}
|
||||
auto pool_it = parent->cli->st_cli.pool_config.find(INODE_POOL(iwatch->cfg.num));
|
||||
if (pool_it == parent->cli->st_cli.pool_config.end())
|
||||
auto pool_it = parent->cli->st_cli->pool_config.find(INODE_POOL(iwatch->cfg.num));
|
||||
if (pool_it == parent->cli->st_cli->pool_config.end())
|
||||
{
|
||||
result = (cli_result_t){ .err = ENOENT, .text = "Pool of image "+iimg+" does not exist" };
|
||||
parent->cli->st_cli.close_watch(iwatch);
|
||||
parent->cli->st_cli->close_watch(iwatch);
|
||||
iwatch = NULL;
|
||||
return;
|
||||
}
|
||||
@@ -131,7 +131,7 @@ struct dd_in_info_t
|
||||
{
|
||||
if (iimg != "")
|
||||
{
|
||||
parent->cli->st_cli.close_watch(iwatch);
|
||||
parent->cli->st_cli->close_watch(iwatch);
|
||||
iwatch = NULL;
|
||||
}
|
||||
else if (ifile != "")
|
||||
@@ -163,11 +163,11 @@ struct dd_out_info_t
|
||||
|
||||
pool_config_t *find_pool(cli_tool_t *parent, const std::string & name)
|
||||
{
|
||||
if (name == "" && parent->cli->st_cli.pool_config.size() == 1)
|
||||
if (name == "" && parent->cli->st_cli->pool_config.size() == 1)
|
||||
{
|
||||
return &parent->cli->st_cli.pool_config.begin()->second;
|
||||
return &parent->cli->st_cli->pool_config.begin()->second;
|
||||
}
|
||||
for (auto & pp: parent->cli->st_cli.pool_config)
|
||||
for (auto & pp: parent->cli->st_cli->pool_config)
|
||||
{
|
||||
if (pp.second.name == name)
|
||||
{
|
||||
@@ -186,14 +186,14 @@ struct dd_out_info_t
|
||||
if (oimg != "")
|
||||
{
|
||||
out_seekable = true;
|
||||
owatch = parent->cli->st_cli.watch_inode(oimg);
|
||||
owatch = parent->cli->st_cli->watch_inode(oimg);
|
||||
if (owatch->cfg.num)
|
||||
{
|
||||
auto pool_it = parent->cli->st_cli.pool_config.find(INODE_POOL(owatch->cfg.num));
|
||||
if (pool_it == parent->cli->st_cli.pool_config.end())
|
||||
auto pool_it = parent->cli->st_cli->pool_config.find(INODE_POOL(owatch->cfg.num));
|
||||
if (pool_it == parent->cli->st_cli->pool_config.end())
|
||||
{
|
||||
result = (cli_result_t){ .err = ENOENT, .text = "Pool of image "+oimg+" does not exist" };
|
||||
parent->cli->st_cli.close_watch(owatch);
|
||||
parent->cli->st_cli->close_watch(owatch);
|
||||
owatch = NULL;
|
||||
return true;
|
||||
}
|
||||
@@ -209,7 +209,7 @@ struct dd_out_info_t
|
||||
else
|
||||
{
|
||||
result = (cli_result_t){ .err = ENOENT, .text = "Pool to create output image "+oimg+" is not specified" };
|
||||
parent->cli->st_cli.close_watch(owatch);
|
||||
parent->cli->st_cli->close_watch(owatch);
|
||||
owatch = NULL;
|
||||
return true;
|
||||
}
|
||||
@@ -224,14 +224,14 @@ struct dd_out_info_t
|
||||
if (!out_create)
|
||||
{
|
||||
result = (cli_result_t){ .err = ENOENT, .text = "Image "+oimg+" does not exist" };
|
||||
parent->cli->st_cli.close_watch(owatch);
|
||||
parent->cli->st_cli->close_watch(owatch);
|
||||
owatch = NULL;
|
||||
return true;
|
||||
}
|
||||
if (!out_size)
|
||||
{
|
||||
result = (cli_result_t){ .err = ENOENT, .text = "Input size is unknown, specify size to create output image "+oimg };
|
||||
parent->cli->st_cli.close_watch(owatch);
|
||||
parent->cli->st_cli->close_watch(owatch);
|
||||
owatch = NULL;
|
||||
return true;
|
||||
}
|
||||
@@ -247,7 +247,7 @@ struct dd_out_info_t
|
||||
if (!out_size)
|
||||
{
|
||||
result = (cli_result_t){ .err = ENOENT, .text = "Input size is unknown, specify size to truncate output image" };
|
||||
parent->cli->st_cli.close_watch(owatch);
|
||||
parent->cli->st_cli->close_watch(owatch);
|
||||
owatch = NULL;
|
||||
return true;
|
||||
}
|
||||
@@ -275,7 +275,7 @@ resume_1:
|
||||
sub_cb = NULL;
|
||||
if (result.err)
|
||||
{
|
||||
parent->cli->st_cli.close_watch(owatch);
|
||||
parent->cli->st_cli->close_watch(owatch);
|
||||
owatch = NULL;
|
||||
return true;
|
||||
}
|
||||
@@ -354,7 +354,7 @@ resume_2:
|
||||
{
|
||||
if (oimg != "")
|
||||
{
|
||||
parent->cli->st_cli.close_watch(owatch);
|
||||
parent->cli->st_cli->close_watch(owatch);
|
||||
owatch = NULL;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -60,7 +60,7 @@ struct cli_describe_t
|
||||
only_pool = cfg["pool"].uint64_value();
|
||||
if (!only_pool && cfg["pool"].is_string())
|
||||
{
|
||||
for (auto & pp: parent->cli->st_cli.pool_config)
|
||||
for (auto & pp: parent->cli->st_cli->pool_config)
|
||||
{
|
||||
if (pp.second.name == cfg["pool"].string_value())
|
||||
{
|
||||
@@ -125,7 +125,7 @@ struct cli_describe_t
|
||||
{
|
||||
uint64_t min_pool = min_inode >> (64-POOL_ID_BITS);
|
||||
uint64_t max_pool = max_inode >> (64-POOL_ID_BITS);
|
||||
for (auto & pp: parent->cli->st_cli.pool_config)
|
||||
for (auto & pp: parent->cli->st_cli->pool_config)
|
||||
{
|
||||
if (pp.first >= min_pool && (!max_pool || pp.first <= max_pool))
|
||||
{
|
||||
|
||||
+2
-2
@@ -134,8 +134,8 @@ struct cli_fix_t
|
||||
return;
|
||||
}
|
||||
auto & obj = objects[processed_count++];
|
||||
auto pool_cfg_it = parent->cli->st_cli.pool_config.find(INODE_POOL(obj.inode));
|
||||
if (pool_cfg_it == parent->cli->st_cli.pool_config.end())
|
||||
auto pool_cfg_it = parent->cli->st_cli->pool_config.find(INODE_POOL(obj.inode));
|
||||
if (pool_cfg_it == parent->cli->st_cli->pool_config.end())
|
||||
{
|
||||
fprintf(stderr, "Object %jx:%jx is from unknown pool\n", obj.inode, obj.stripe);
|
||||
continue;
|
||||
|
||||
@@ -41,8 +41,8 @@ struct snap_flattener_t
|
||||
chain_list.push_back(cur->num);
|
||||
while (cur->parent_id != 0 && cur->parent_id != target_cfg->num)
|
||||
{
|
||||
auto it = parent->cli->st_cli.inode_config.find(cur->parent_id);
|
||||
if (it == parent->cli->st_cli.inode_config.end())
|
||||
auto it = parent->cli->st_cli->inode_config.find(cur->parent_id);
|
||||
if (it == parent->cli->st_cli->inode_config.end())
|
||||
{
|
||||
result = (cli_result_t){
|
||||
.err = ENOENT,
|
||||
|
||||
+18
-18
@@ -37,7 +37,7 @@ struct image_lister_t
|
||||
{
|
||||
if (list_pool_name != "")
|
||||
{
|
||||
for (auto & ic: parent->cli->st_cli.pool_config)
|
||||
for (auto & ic: parent->cli->st_cli->pool_config)
|
||||
{
|
||||
if (ic.second.name == list_pool_name)
|
||||
{
|
||||
@@ -52,14 +52,14 @@ struct image_lister_t
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (auto & ic: parent->cli->st_cli.inode_config)
|
||||
for (auto & ic: parent->cli->st_cli->inode_config)
|
||||
{
|
||||
if (list_pool_id && INODE_POOL(ic.second.num) != list_pool_id)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
auto pool_it = parent->cli->st_cli.pool_config.find(INODE_POOL(ic.second.num));
|
||||
bool good_pool = pool_it != parent->cli->st_cli.pool_config.end();
|
||||
auto pool_it = parent->cli->st_cli->pool_config.find(INODE_POOL(ic.second.num));
|
||||
bool good_pool = pool_it != parent->cli->st_cli->pool_config.end();
|
||||
auto item = json11::Json::object {
|
||||
{ "name", ic.second.name },
|
||||
{ "size", ic.second.size },
|
||||
@@ -73,8 +73,8 @@ struct image_lister_t
|
||||
};
|
||||
if (ic.second.parent_id)
|
||||
{
|
||||
auto p_it = parent->cli->st_cli.inode_config.find(ic.second.parent_id);
|
||||
item["parent_name"] = p_it != parent->cli->st_cli.inode_config.end()
|
||||
auto p_it = parent->cli->st_cli->inode_config.find(ic.second.parent_id);
|
||||
item["parent_name"] = p_it != parent->cli->st_cli->inode_config.end()
|
||||
? p_it->second.name : "";
|
||||
item["parent_pool_id"] = (uint64_t)INODE_POOL(ic.second.parent_id);
|
||||
item["parent_inode_num"] = INODE_NO_POOL(ic.second.parent_id);
|
||||
@@ -96,21 +96,21 @@ struct image_lister_t
|
||||
json11::Json::object {
|
||||
{ "request_range", (list_pool_id
|
||||
? json11::Json::object {
|
||||
{ "key", base64_encode(parent->cli->st_cli.etcd_prefix+"/pool/stats/"+std::to_string(list_pool_id)) },
|
||||
{ "key", base64_encode(parent->cli->st_cli->etcd_prefix+"/pool/stats/"+std::to_string(list_pool_id)) },
|
||||
}
|
||||
: json11::Json::object {
|
||||
{ "key", base64_encode(parent->cli->st_cli.etcd_prefix+"/pool/stats/") },
|
||||
{ "range_end", base64_encode(parent->cli->st_cli.etcd_prefix+"/pool/stats0") },
|
||||
{ "key", base64_encode(parent->cli->st_cli->etcd_prefix+"/pool/stats/") },
|
||||
{ "range_end", base64_encode(parent->cli->st_cli->etcd_prefix+"/pool/stats0") },
|
||||
}) },
|
||||
},
|
||||
json11::Json::object {
|
||||
{ "request_range", json11::Json::object {
|
||||
{ "key", base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+"/inode/stats"+
|
||||
parent->cli->st_cli->etcd_prefix+"/inode/stats"+
|
||||
(list_pool_id ? "/"+std::to_string(list_pool_id) : "")+"/"
|
||||
) },
|
||||
{ "range_end", base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+"/inode/stats"+
|
||||
parent->cli->st_cli->etcd_prefix+"/inode/stats"+
|
||||
(list_pool_id ? "/"+std::to_string(list_pool_id) : "")+"0"
|
||||
) },
|
||||
} },
|
||||
@@ -131,11 +131,11 @@ resume_1:
|
||||
std::map<pool_id_t, uint64_t> pool_pg_real_size;
|
||||
for (auto & kv_item: space_info["responses"][0]["response_range"]["kvs"].array_items())
|
||||
{
|
||||
auto kv = parent->cli->st_cli.parse_etcd_kv(kv_item);
|
||||
auto kv = parent->cli->st_cli->parse_etcd_kv(kv_item);
|
||||
// pool ID
|
||||
pool_id_t pool_id;
|
||||
char null_byte = 0;
|
||||
int scanned = 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 (scanned != 1 || !pool_id || pool_id >= POOL_ID_MAX)
|
||||
{
|
||||
fprintf(stderr, "Invalid key in etcd: %s\n", kv.key.c_str());
|
||||
@@ -146,12 +146,12 @@ resume_1:
|
||||
}
|
||||
for (auto & kv_item: space_info["responses"][1]["response_range"]["kvs"].array_items())
|
||||
{
|
||||
auto kv = parent->cli->st_cli.parse_etcd_kv(kv_item);
|
||||
auto kv = parent->cli->st_cli->parse_etcd_kv(kv_item);
|
||||
// pool ID & inode number
|
||||
pool_id_t pool_id;
|
||||
inode_t only_inode_num;
|
||||
char null_byte = 0;
|
||||
int scanned = 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/%ju%c", &pool_id, &only_inode_num, &null_byte);
|
||||
if (scanned != 2 || !pool_id || pool_id >= POOL_ID_MAX || INODE_POOL(only_inode_num) != 0)
|
||||
{
|
||||
@@ -161,8 +161,8 @@ resume_1:
|
||||
inode_t inode_num = INODE_WITH_POOL(pool_id, only_inode_num);
|
||||
uint64_t used_size = kv.value["raw_used"].uint64_value();
|
||||
// save stats
|
||||
auto pool_it = parent->cli->st_cli.pool_config.find(pool_id);
|
||||
if (pool_it != parent->cli->st_cli.pool_config.end())
|
||||
auto pool_it = parent->cli->st_cli->pool_config.find(pool_id);
|
||||
if (pool_it != parent->cli->st_cli->pool_config.end())
|
||||
{
|
||||
auto & pool_cfg = pool_it->second;
|
||||
used_size = used_size / (pool_pg_real_size[pool_id] ? pool_pg_real_size[pool_id] : 1)
|
||||
@@ -176,7 +176,7 @@ resume_1:
|
||||
{ "size", 0 },
|
||||
{ "readonly", false },
|
||||
{ "pool_id", (uint64_t)INODE_POOL(inode_num) },
|
||||
{ "pool_name", pool_it != parent->cli->st_cli.pool_config.end()
|
||||
{ "pool_name", pool_it != parent->cli->st_cli->pool_config.end()
|
||||
? (pool_it->second.name == "" ? "<Unnamed>" : pool_it->second.name) : "?" },
|
||||
{ "inode_num", INODE_NO_POOL(inode_num) },
|
||||
{ "inode_id", inode_num },
|
||||
|
||||
@@ -110,8 +110,8 @@ struct snap_merger_t
|
||||
cur->parent_id != to_cfg->num &&
|
||||
cur->parent_id != 0)
|
||||
{
|
||||
auto it = parent->cli->st_cli.inode_config.find(cur->parent_id);
|
||||
if (it == parent->cli->st_cli.inode_config.end())
|
||||
auto it = parent->cli->st_cli->inode_config.find(cur->parent_id);
|
||||
if (it == parent->cli->st_cli->inode_config.end())
|
||||
{
|
||||
result = (cli_result_t){
|
||||
.err = ENOENT,
|
||||
@@ -166,7 +166,7 @@ struct snap_merger_t
|
||||
//
|
||||
// <from> - <layer 1> - <target> - <to>
|
||||
// \- <layer 2> <---------X-------- NOT ALLOWED
|
||||
for (auto & ic: parent->cli->st_cli.inode_config)
|
||||
for (auto & ic: parent->cli->st_cli->inode_config)
|
||||
{
|
||||
auto it = sources.find(ic.second.num);
|
||||
if (it == sources.end() && ic.second.parent_id != 0)
|
||||
@@ -182,7 +182,7 @@ struct snap_merger_t
|
||||
.text = "Layers at or above "+(check_delete_source ? from_name : target_name)+
|
||||
", but below "+to_name+" are not allowed to have other children, but "+
|
||||
ic.second.name+" is a child of "+
|
||||
parent->cli->st_cli.inode_config.at(ic.second.parent_id).name,
|
||||
parent->cli->st_cli->inode_config.at(ic.second.parent_id).name,
|
||||
};
|
||||
state = 100;
|
||||
return;
|
||||
@@ -213,7 +213,7 @@ struct snap_merger_t
|
||||
|
||||
uint64_t get_block_size(inode_t inode, uint32_t *bitmap_granularity)
|
||||
{
|
||||
auto & pool_cfg = parent->cli->st_cli.pool_config.at(INODE_POOL(inode));
|
||||
auto & pool_cfg = parent->cli->st_cli->pool_config.at(INODE_POOL(inode));
|
||||
uint64_t pg_data_size = (pool_cfg.scheme == POOL_SCHEME_REPLICATED ? 1 : pool_cfg.pg_size-pool_cfg.parity_chunks);
|
||||
if (bitmap_granularity)
|
||||
*bitmap_granularity = pool_cfg.bitmap_granularity;
|
||||
@@ -418,7 +418,7 @@ struct snap_merger_t
|
||||
}
|
||||
if (!pgs_left)
|
||||
{
|
||||
auto & name = parent->cli->st_cli.inode_config.at(src).name;
|
||||
auto & name = parent->cli->st_cli->inode_config.at(src).name;
|
||||
if (list_errcode.find(src) != list_errcode.end())
|
||||
{
|
||||
fprintf(stderr, "Failed to get listing of layer %s (inode %ju in pool %u): %s (code %d)\n",
|
||||
|
||||
@@ -53,7 +53,7 @@ struct image_changer_t
|
||||
state = 100;
|
||||
return;
|
||||
}
|
||||
for (auto & ic: parent->cli->st_cli.inode_config)
|
||||
for (auto & ic: parent->cli->st_cli->inode_config)
|
||||
{
|
||||
if (ic.second.name == image_name)
|
||||
{
|
||||
@@ -74,7 +74,7 @@ struct image_changer_t
|
||||
state = 100;
|
||||
return;
|
||||
}
|
||||
for (auto & ic: parent->cli->st_cli.inode_config)
|
||||
for (auto & ic: parent->cli->st_cli->inode_config)
|
||||
{
|
||||
if (ic.second.parent_id == inode_num)
|
||||
{
|
||||
@@ -153,7 +153,7 @@ resume_1:
|
||||
cfg.name = new_name;
|
||||
}
|
||||
{
|
||||
std::string cur_cfg_key = base64_encode(parent->cli->st_cli.etcd_prefix+
|
||||
std::string cur_cfg_key = base64_encode(parent->cli->st_cli->etcd_prefix+
|
||||
"/config/inode/"+std::to_string(INODE_POOL(inode_num))+
|
||||
"/"+std::to_string(INODE_NO_POOL(inode_num)));
|
||||
checks.push_back(json11::Json::object {
|
||||
@@ -166,7 +166,7 @@ resume_1:
|
||||
{ "request_put", json11::Json::object {
|
||||
{ "key", cur_cfg_key },
|
||||
{ "value", base64_encode(json11::Json(
|
||||
parent->cli->st_cli.serialize_inode_cfg(&cfg)
|
||||
parent->cli->st_cli->serialize_inode_cfg(&cfg)
|
||||
).dump()) },
|
||||
} }
|
||||
});
|
||||
@@ -174,10 +174,10 @@ resume_1:
|
||||
if (new_name != "")
|
||||
{
|
||||
std::string old_idx_key = base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+"/index/image/"+image_name
|
||||
parent->cli->st_cli->etcd_prefix+"/index/image/"+image_name
|
||||
);
|
||||
std::string new_idx_key = base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+"/index/image/"+new_name
|
||||
parent->cli->st_cli->etcd_prefix+"/index/image/"+new_name
|
||||
);
|
||||
checks.push_back(json11::Json::object {
|
||||
{ "target", "MOD" },
|
||||
@@ -229,9 +229,9 @@ resume_2:
|
||||
cfg.mod_revision = parent->etcd_result["header"]["revision"].uint64_value();
|
||||
if (new_name != "")
|
||||
{
|
||||
parent->cli->st_cli.inode_by_name.erase(image_name);
|
||||
parent->cli->st_cli->inode_by_name.erase(image_name);
|
||||
}
|
||||
parent->cli->st_cli.insert_inode_config(cfg);
|
||||
parent->cli->st_cli->insert_inode_config(cfg);
|
||||
result = (cli_result_t){
|
||||
.err = 0,
|
||||
.text = "Image "+image_name+" modified",
|
||||
|
||||
@@ -68,12 +68,12 @@ struct osd_changer_t
|
||||
{ "success", json11::Json::array {
|
||||
json11::Json::object {
|
||||
{ "request_range", json11::Json::object {
|
||||
{ "key", base64_encode(parent->cli->st_cli.etcd_prefix+"/osd/stats/"+std::to_string(osd_num)) },
|
||||
{ "key", base64_encode(parent->cli->st_cli->etcd_prefix+"/osd/stats/"+std::to_string(osd_num)) },
|
||||
} },
|
||||
},
|
||||
json11::Json::object {
|
||||
{ "request_range", json11::Json::object {
|
||||
{ "key", base64_encode(parent->cli->st_cli.etcd_prefix+"/config/osd/"+std::to_string(osd_num)) },
|
||||
{ "key", base64_encode(parent->cli->st_cli->etcd_prefix+"/config/osd/"+std::to_string(osd_num)) },
|
||||
} },
|
||||
},
|
||||
} },
|
||||
@@ -89,14 +89,14 @@ resume_1:
|
||||
return;
|
||||
}
|
||||
{
|
||||
auto osd_stats = parent->cli->st_cli.parse_etcd_kv(parent->etcd_result["responses"][0]["response_range"]["kvs"][0]).value;
|
||||
auto osd_stats = parent->cli->st_cli->parse_etcd_kv(parent->etcd_result["responses"][0]["response_range"]["kvs"][0]).value;
|
||||
if (!osd_stats.is_object() && !force)
|
||||
{
|
||||
result = (cli_result_t){ .err = ENOENT, .text = "OSD "+std::to_string(osd_num)+" does not exist. Use --force to set configuration anyway" };
|
||||
state = 100;
|
||||
return;
|
||||
}
|
||||
auto kv = parent->cli->st_cli.parse_etcd_kv(parent->etcd_result["responses"][1]["response_range"]["kvs"][0]);
|
||||
auto kv = parent->cli->st_cli->parse_etcd_kv(parent->etcd_result["responses"][1]["response_range"]["kvs"][0]);
|
||||
osd_cfg_mod_rev = kv.mod_revision;
|
||||
osd_cfg = kv.value.object_items();
|
||||
if (set_reweight)
|
||||
@@ -124,7 +124,7 @@ resume_1:
|
||||
{
|
||||
compare.push_back(json11::Json::object {
|
||||
{ "target", "MOD" },
|
||||
{ "key", base64_encode(parent->cli->st_cli.etcd_prefix+"/config/osd/"+std::to_string(osd_num)) },
|
||||
{ "key", base64_encode(parent->cli->st_cli->etcd_prefix+"/config/osd/"+std::to_string(osd_num)) },
|
||||
{ "result", "LESS" },
|
||||
{ "mod_revision", osd_cfg_mod_rev+1 },
|
||||
});
|
||||
@@ -133,7 +133,7 @@ resume_1:
|
||||
{
|
||||
compare.push_back(json11::Json::object {
|
||||
{ "target", "VERSION" },
|
||||
{ "key", base64_encode(parent->cli->st_cli.etcd_prefix+"/config/osd/"+std::to_string(osd_num)) },
|
||||
{ "key", base64_encode(parent->cli->st_cli->etcd_prefix+"/config/osd/"+std::to_string(osd_num)) },
|
||||
{ "version", 0 },
|
||||
});
|
||||
}
|
||||
@@ -141,7 +141,7 @@ resume_1:
|
||||
{
|
||||
success.push_back(json11::Json::object {
|
||||
{ "request_delete_range", json11::Json::object {
|
||||
{ "key", base64_encode(parent->cli->st_cli.etcd_prefix+"/config/osd/"+std::to_string(osd_num)) },
|
||||
{ "key", base64_encode(parent->cli->st_cli->etcd_prefix+"/config/osd/"+std::to_string(osd_num)) },
|
||||
} },
|
||||
});
|
||||
}
|
||||
@@ -149,7 +149,7 @@ resume_1:
|
||||
{
|
||||
success.push_back(json11::Json::object {
|
||||
{ "request_put", json11::Json::object {
|
||||
{ "key", base64_encode(parent->cli->st_cli.etcd_prefix+"/config/osd/"+std::to_string(osd_num)) },
|
||||
{ "key", base64_encode(parent->cli->st_cli->etcd_prefix+"/config/osd/"+std::to_string(osd_num)) },
|
||||
{ "value", base64_encode(json11::Json(osd_cfg).dump()) },
|
||||
} },
|
||||
});
|
||||
|
||||
@@ -62,19 +62,19 @@ struct osd_tree_printer_t
|
||||
{ "success", json11::Json::array {
|
||||
json11::Json::object {
|
||||
{ "request_range", json11::Json::object {
|
||||
{ "key", base64_encode(parent->cli->st_cli.etcd_prefix+"/config/node_placement") },
|
||||
{ "key", base64_encode(parent->cli->st_cli->etcd_prefix+"/config/node_placement") },
|
||||
} },
|
||||
},
|
||||
json11::Json::object {
|
||||
{ "request_range", json11::Json::object {
|
||||
{ "key", base64_encode(parent->cli->st_cli.etcd_prefix+"/config/osd/") },
|
||||
{ "range_end", base64_encode(parent->cli->st_cli.etcd_prefix+"/config/osd0") },
|
||||
{ "key", base64_encode(parent->cli->st_cli->etcd_prefix+"/config/osd/") },
|
||||
{ "range_end", base64_encode(parent->cli->st_cli->etcd_prefix+"/config/osd0") },
|
||||
} },
|
||||
},
|
||||
json11::Json::object {
|
||||
{ "request_range", json11::Json::object {
|
||||
{ "key", base64_encode(parent->cli->st_cli.etcd_prefix+"/osd/stats/") },
|
||||
{ "range_end", base64_encode(parent->cli->st_cli.etcd_prefix+"/osd/stats0") },
|
||||
{ "key", base64_encode(parent->cli->st_cli->etcd_prefix+"/osd/stats/") },
|
||||
{ "range_end", base64_encode(parent->cli->st_cli->etcd_prefix+"/osd/stats0") },
|
||||
} },
|
||||
},
|
||||
} },
|
||||
@@ -91,7 +91,7 @@ resume_1:
|
||||
}
|
||||
for (auto & item: parent->etcd_result["responses"][0]["response_range"]["kvs"].array_items())
|
||||
{
|
||||
node_placement = parent->cli->st_cli.parse_etcd_kv(item).value;
|
||||
node_placement = parent->cli->st_cli->parse_etcd_kv(item).value;
|
||||
}
|
||||
parent->iterate_kvs_1(parent->etcd_result["responses"][1]["response_range"]["kvs"], "/config/osd/", [&](uint64_t cur_osd, json11::Json value)
|
||||
{
|
||||
@@ -132,7 +132,7 @@ resume_1:
|
||||
.parent = kv.second["host"].string_value(),
|
||||
.size = kv.second["size"].uint64_value(),
|
||||
.free = kv.second["free"].uint64_value(),
|
||||
.up = parent->cli->st_cli.peer_states.find(kv.first) != parent->cli->st_cli.peer_states.end(),
|
||||
.up = parent->cli->st_cli->peer_states.find(kv.first) != parent->cli->st_cli->peer_states.end(),
|
||||
.reweight = 1,
|
||||
.noout = false,
|
||||
.block_size = (uint32_t)kv.second["data_block_size"].uint64_value(),
|
||||
|
||||
@@ -32,7 +32,7 @@ struct pg_lister_t
|
||||
if (pool_name != "")
|
||||
{
|
||||
pool_id = 0;
|
||||
for (auto & pp: parent->cli->st_cli.pool_config)
|
||||
for (auto & pp: parent->cli->st_cli->pool_config)
|
||||
{
|
||||
if (pp.second.name == pool_name)
|
||||
{
|
||||
@@ -51,8 +51,8 @@ struct pg_lister_t
|
||||
{ "success", json11::Json::array {
|
||||
json11::Json::object {
|
||||
{ "request_range", json11::Json::object {
|
||||
{ "key", base64_encode(parent->cli->st_cli.etcd_prefix+"/pgstats"+(pool_id ? "/"+std::to_string(pool_id)+"/" : "/")) },
|
||||
{ "range_end", base64_encode(parent->cli->st_cli.etcd_prefix+"/pgstats"+(pool_id ? "/"+std::to_string(pool_id)+"0" : "0")) },
|
||||
{ "key", base64_encode(parent->cli->st_cli->etcd_prefix+"/pgstats"+(pool_id ? "/"+std::to_string(pool_id)+"/" : "/")) },
|
||||
{ "range_end", base64_encode(parent->cli->st_cli->etcd_prefix+"/pgstats"+(pool_id ? "/"+std::to_string(pool_id)+"0" : "0")) },
|
||||
} },
|
||||
},
|
||||
} },
|
||||
@@ -129,7 +129,7 @@ resume_1:
|
||||
}
|
||||
}
|
||||
json11::Json::array pgs;
|
||||
for (auto & pp: parent->cli->st_cli.pool_config)
|
||||
for (auto & pp: parent->cli->st_cli->pool_config)
|
||||
{
|
||||
if ((!pool_id || pp.first == pool_id) && (pool_name == "" || pp.second.name == pool_name))
|
||||
{
|
||||
|
||||
+21
-21
@@ -60,8 +60,8 @@ struct pool_creator_t
|
||||
// Validate pool parameters
|
||||
{
|
||||
auto new_cfg = cfg.object_items();
|
||||
result.text = validate_pool_config(new_cfg, json11::Json(), parent->cli->st_cli.global_block_size,
|
||||
parent->cli->st_cli.global_bitmap_granularity, force);
|
||||
result.text = validate_pool_config(new_cfg, json11::Json(), parent->cli->st_cli->global_block_size,
|
||||
parent->cli->st_cli->global_bitmap_granularity, force);
|
||||
cfg = new_cfg;
|
||||
}
|
||||
if (result.text != "")
|
||||
@@ -72,7 +72,7 @@ struct pool_creator_t
|
||||
}
|
||||
|
||||
// Validate pool name
|
||||
for (auto & pp: parent->cli->st_cli.pool_config)
|
||||
for (auto & pp: parent->cli->st_cli->pool_config)
|
||||
{
|
||||
if (pp.second.name == cfg["name"].string_value())
|
||||
{
|
||||
@@ -95,13 +95,13 @@ resume_1:
|
||||
{ "success", json11::Json::array {
|
||||
json11::Json::object {
|
||||
{ "request_range", json11::Json::object {
|
||||
{ "key", base64_encode(parent->cli->st_cli.etcd_prefix+"/config/node_placement") },
|
||||
{ "key", base64_encode(parent->cli->st_cli->etcd_prefix+"/config/node_placement") },
|
||||
} },
|
||||
},
|
||||
json11::Json::object {
|
||||
{ "request_range", json11::Json::object {
|
||||
{ "key", base64_encode(parent->cli->st_cli.etcd_prefix+"/osd/stats/") },
|
||||
{ "range_end", base64_encode(parent->cli->st_cli.etcd_prefix+"/osd/stats0") },
|
||||
{ "key", base64_encode(parent->cli->st_cli->etcd_prefix+"/osd/stats/") },
|
||||
{ "range_end", base64_encode(parent->cli->st_cli->etcd_prefix+"/osd/stats0") },
|
||||
} },
|
||||
},
|
||||
} },
|
||||
@@ -120,7 +120,7 @@ resume_2:
|
||||
|
||||
// Get state_node_tree based on node_placement and osd stats
|
||||
{
|
||||
auto node_placement_kv = parent->cli->st_cli.parse_etcd_kv(parent->etcd_result["responses"][0]["response_range"]["kvs"][0]);
|
||||
auto node_placement_kv = parent->cli->st_cli->parse_etcd_kv(parent->etcd_result["responses"][0]["response_range"]["kvs"][0]);
|
||||
timespec tv_now;
|
||||
clock_gettime(CLOCK_REALTIME, &tv_now);
|
||||
uint64_t osd_out_time = parent->cli->config["osd_out_time"].uint64_value();
|
||||
@@ -145,7 +145,7 @@ resume_2:
|
||||
{
|
||||
osd_configs.push_back(json11::Json::object {
|
||||
{ "request_range", json11::Json::object {
|
||||
{ "key", base64_encode(parent->cli->st_cli.etcd_prefix+"/config/osd/"+osd_num.as_string()) },
|
||||
{ "key", base64_encode(parent->cli->st_cli->etcd_prefix+"/config/osd/"+osd_num.as_string()) },
|
||||
} }
|
||||
});
|
||||
}
|
||||
@@ -168,7 +168,7 @@ resume_3:
|
||||
std::vector<json11::Json> osd_configs;
|
||||
for (auto & ocr: parent->etcd_result["responses"].array_items())
|
||||
{
|
||||
auto kv = parent->cli->st_cli.parse_etcd_kv(ocr["response_range"]["kvs"][0]);
|
||||
auto kv = parent->cli->st_cli->parse_etcd_kv(ocr["response_range"]["kvs"][0]);
|
||||
osd_configs.push_back(kv.value);
|
||||
}
|
||||
state_node_tree = filter_state_node_tree_by_tags(state_node_tree, osd_configs);
|
||||
@@ -229,7 +229,7 @@ resume_5:
|
||||
{ "success", json11::Json::array {
|
||||
json11::Json::object {
|
||||
{ "request_range", json11::Json::object {
|
||||
{ "key", base64_encode(parent->cli->st_cli.etcd_prefix+"/config/pools") },
|
||||
{ "key", base64_encode(parent->cli->st_cli->etcd_prefix+"/config/pools") },
|
||||
} }
|
||||
},
|
||||
} },
|
||||
@@ -246,7 +246,7 @@ resume_6:
|
||||
}
|
||||
{
|
||||
// Add new pool
|
||||
auto kv = parent->cli->st_cli.parse_etcd_kv(parent->etcd_result["responses"][0]["response_range"]["kvs"][0]);
|
||||
auto kv = parent->cli->st_cli->parse_etcd_kv(parent->etcd_result["responses"][0]["response_range"]["kvs"][0]);
|
||||
new_pools = create_pool(kv);
|
||||
if (new_pools.is_string())
|
||||
{
|
||||
@@ -261,7 +261,7 @@ resume_6:
|
||||
{ "compare", json11::Json::array {
|
||||
json11::Json::object {
|
||||
{ "target", "MOD" },
|
||||
{ "key", base64_encode(parent->cli->st_cli.etcd_prefix+"/config/pools") },
|
||||
{ "key", base64_encode(parent->cli->st_cli->etcd_prefix+"/config/pools") },
|
||||
{ "result", "LESS" },
|
||||
{ "mod_revision", new_pools_mod_rev+1 },
|
||||
}
|
||||
@@ -269,7 +269,7 @@ resume_6:
|
||||
{ "success", json11::Json::array {
|
||||
json11::Json::object {
|
||||
{ "request_put", json11::Json::object {
|
||||
{ "key", base64_encode(parent->cli->st_cli.etcd_prefix+"/config/pools") },
|
||||
{ "key", base64_encode(parent->cli->st_cli->etcd_prefix+"/config/pools") },
|
||||
{ "value", base64_encode(new_pools.dump()) },
|
||||
} },
|
||||
},
|
||||
@@ -307,9 +307,9 @@ resume_8:
|
||||
parent->waiting++;
|
||||
parent->epmgr->tfd->set_timer(create_check.interval, false, [this](int timer_id)
|
||||
{
|
||||
if (parent->cli->st_cli.pool_config.find(new_id) != parent->cli->st_cli.pool_config.end())
|
||||
if (parent->cli->st_cli->pool_config.find(new_id) != parent->cli->st_cli->pool_config.end())
|
||||
{
|
||||
auto & pool_cfg = parent->cli->st_cli.pool_config[new_id];
|
||||
auto & pool_cfg = parent->cli->st_cli->pool_config[new_id];
|
||||
create_check.passed = pool_cfg.real_pg_count > 0;
|
||||
for (auto pg_it = pool_cfg.pg_config.begin(); pg_it != pool_cfg.pg_config.end(); pg_it++)
|
||||
{
|
||||
@@ -459,7 +459,7 @@ resume_8:
|
||||
osd_bs = UINT32_MAX;
|
||||
}
|
||||
}
|
||||
if (osd_bs && osd_bs != UINT32_MAX && osd_bs != parent->cli->st_cli.global_block_size)
|
||||
if (osd_bs && osd_bs != UINT32_MAX && osd_bs != parent->cli->st_cli->global_block_size)
|
||||
{
|
||||
fprintf(stderr, "Auto-selecting block_size=%s because all pool OSDs use it\n", format_size(osd_bs, false, true).c_str());
|
||||
upd["block_size"] = osd_bs;
|
||||
@@ -478,7 +478,7 @@ resume_8:
|
||||
osd_bg = UINT32_MAX;
|
||||
}
|
||||
}
|
||||
if (osd_bg && osd_bg != UINT32_MAX && osd_bg != parent->cli->st_cli.global_bitmap_granularity)
|
||||
if (osd_bg && osd_bg != UINT32_MAX && osd_bg != parent->cli->st_cli->global_bitmap_granularity)
|
||||
{
|
||||
fprintf(stderr, "Auto-selecting bitmap_granularity=%s because all pool OSDs use it\n", format_size(osd_bg, false, true).c_str());
|
||||
upd["bitmap_granularity"] = osd_bg;
|
||||
@@ -498,7 +498,7 @@ resume_8:
|
||||
osd_imm = UINT32_MAX-1;
|
||||
}
|
||||
}
|
||||
if (osd_imm < UINT32_MAX-1 && osd_imm != parent->cli->st_cli.global_immediate_commit)
|
||||
if (osd_imm < UINT32_MAX-1 && osd_imm != parent->cli->st_cli->global_immediate_commit)
|
||||
{
|
||||
const char *imm_str = osd_imm == IMMEDIATE_NONE ? "none" : (osd_imm == IMMEDIATE_ALL ? "all" : "small");
|
||||
fprintf(stderr, "Auto-selecting immediate_commit=%s because all pool OSDs use it\n", imm_str);
|
||||
@@ -530,13 +530,13 @@ resume_8:
|
||||
|
||||
block_size = cfg["block_size"].uint64_value()
|
||||
? cfg["block_size"].uint64_value()
|
||||
: parent->cli->st_cli.global_block_size;
|
||||
: parent->cli->st_cli->global_block_size;
|
||||
bitmap_granularity = cfg["bitmap_granularity"].uint64_value()
|
||||
? cfg["bitmap_granularity"].uint64_value()
|
||||
: parent->cli->st_cli.global_bitmap_granularity;
|
||||
: parent->cli->st_cli->global_bitmap_granularity;
|
||||
immediate_commit = cfg["immediate_commit"].is_string()
|
||||
? etcd_state_client_t::parse_immediate_commit(cfg["immediate_commit"].string_value(), IMMEDIATE_ALL)
|
||||
: parent->cli->st_cli.global_immediate_commit;
|
||||
: parent->cli->st_cli->global_immediate_commit;
|
||||
|
||||
for (auto osd_num_json: state_node_tree["osds"].array_items())
|
||||
{
|
||||
|
||||
+14
-14
@@ -63,37 +63,37 @@ struct pool_lister_t
|
||||
json11::Json::object {
|
||||
{ "request_range", json11::Json::object {
|
||||
{ "key", base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+"/pool/stats/"
|
||||
parent->cli->st_cli->etcd_prefix+"/pool/stats/"
|
||||
) },
|
||||
{ "range_end", base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+"/pool/stats0"
|
||||
parent->cli->st_cli->etcd_prefix+"/pool/stats0"
|
||||
) },
|
||||
} },
|
||||
},
|
||||
json11::Json::object {
|
||||
{ "request_range", json11::Json::object {
|
||||
{ "key", base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+"/osd/stats/"
|
||||
parent->cli->st_cli->etcd_prefix+"/osd/stats/"
|
||||
) },
|
||||
{ "range_end", base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+"/osd/stats0"
|
||||
parent->cli->st_cli->etcd_prefix+"/osd/stats0"
|
||||
) },
|
||||
} },
|
||||
},
|
||||
json11::Json::object {
|
||||
{ "request_range", json11::Json::object {
|
||||
{ "key", base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+"/config/pools"
|
||||
parent->cli->st_cli->etcd_prefix+"/config/pools"
|
||||
) },
|
||||
} },
|
||||
},
|
||||
json11::Json::object {
|
||||
{ "request_range", json11::Json::object {
|
||||
{ "key", base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+"/config/osd/"
|
||||
parent->cli->st_cli->etcd_prefix+"/config/osd/"
|
||||
) },
|
||||
{ "range_end", base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+"/config/osd0"
|
||||
parent->cli->st_cli->etcd_prefix+"/config/osd0"
|
||||
) },
|
||||
} },
|
||||
},
|
||||
@@ -113,7 +113,7 @@ resume_1:
|
||||
auto config_pools = space_info["responses"][2]["response_range"]["kvs"][0];
|
||||
if (!config_pools.is_null())
|
||||
{
|
||||
config_pools = parent->cli->st_cli.parse_etcd_kv(config_pools).value;
|
||||
config_pools = parent->cli->st_cli->parse_etcd_kv(config_pools).value;
|
||||
}
|
||||
parent->iterate_kvs_1(space_info["responses"][0]["response_range"]["kvs"], "/pool/stats/", [&](uint64_t pool_id, json11::Json value)
|
||||
{
|
||||
@@ -134,7 +134,7 @@ resume_1:
|
||||
}
|
||||
});
|
||||
// Calculate max_avail for each pool
|
||||
for (auto & pp: parent->cli->st_cli.pool_config)
|
||||
for (auto & pp: parent->cli->st_cli->pool_config)
|
||||
{
|
||||
auto & pool_cfg = pp.second;
|
||||
uint64_t pool_avail = UINT64_MAX;
|
||||
@@ -238,10 +238,10 @@ resume_1:
|
||||
json11::Json::object {
|
||||
{ "request_range", json11::Json::object {
|
||||
{ "key", base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+"/pgstats/"
|
||||
parent->cli->st_cli->etcd_prefix+"/pgstats/"
|
||||
) },
|
||||
{ "range_end", base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+"/pgstats0"
|
||||
parent->cli->st_cli->etcd_prefix+"/pgstats0"
|
||||
) },
|
||||
} },
|
||||
},
|
||||
@@ -289,10 +289,10 @@ resume_1:
|
||||
json11::Json::object {
|
||||
{ "request_range", json11::Json::object {
|
||||
{ "key", base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+"/inode/stats/"
|
||||
parent->cli->st_cli->etcd_prefix+"/inode/stats/"
|
||||
) },
|
||||
{ "range_end", base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+"/inode/stats0"
|
||||
parent->cli->st_cli->etcd_prefix+"/inode/stats0"
|
||||
) },
|
||||
} },
|
||||
},
|
||||
@@ -478,7 +478,7 @@ resume_3:
|
||||
auto total = st["object_count"].uint64_value();
|
||||
auto obj_size = st["block_size"].uint64_value();
|
||||
if (!obj_size)
|
||||
obj_size = parent->cli->st_cli.global_block_size;
|
||||
obj_size = parent->cli->st_cli->global_block_size;
|
||||
if (st["scheme"] == "ec")
|
||||
obj_size *= st["pg_size"].uint64_value() - st["parity_chunks"].uint64_value();
|
||||
else if (st["scheme"] == "xor")
|
||||
|
||||
@@ -56,7 +56,7 @@ resume_0:
|
||||
{ "success", json11::Json::array {
|
||||
json11::Json::object {
|
||||
{ "request_range", json11::Json::object {
|
||||
{ "key", base64_encode(parent->cli->st_cli.etcd_prefix+"/config/pools") },
|
||||
{ "key", base64_encode(parent->cli->st_cli->etcd_prefix+"/config/pools") },
|
||||
} }
|
||||
},
|
||||
} },
|
||||
@@ -73,7 +73,7 @@ resume_1:
|
||||
}
|
||||
{
|
||||
// Parse received pools from etcd
|
||||
auto kv = parent->cli->st_cli.parse_etcd_kv(parent->etcd_result["responses"][0]["response_range"]["kvs"][0]);
|
||||
auto kv = parent->cli->st_cli->parse_etcd_kv(parent->etcd_result["responses"][0]["response_range"]["kvs"][0]);
|
||||
|
||||
// Get pool by name or ID
|
||||
old_cfg = json11::Json();
|
||||
@@ -103,8 +103,8 @@ resume_1:
|
||||
|
||||
// Update pool
|
||||
new_cfg = cfg;
|
||||
result.text = validate_pool_config(new_cfg, old_cfg, parent->cli->st_cli.global_block_size,
|
||||
parent->cli->st_cli.global_bitmap_granularity, force);
|
||||
result.text = validate_pool_config(new_cfg, old_cfg, parent->cli->st_cli->global_block_size,
|
||||
parent->cli->st_cli->global_bitmap_granularity, force);
|
||||
if (result.text != "")
|
||||
{
|
||||
result.err = EINVAL;
|
||||
@@ -115,8 +115,8 @@ resume_1:
|
||||
if (new_cfg.find("used_for_app") != new_cfg.end() && !force)
|
||||
{
|
||||
// Check that pool doesn't have images
|
||||
auto img_it = parent->cli->st_cli.inode_config.lower_bound(INODE_WITH_POOL(pool_id, 0));
|
||||
if (img_it != parent->cli->st_cli.inode_config.end() &&
|
||||
auto img_it = parent->cli->st_cli->inode_config.lower_bound(INODE_WITH_POOL(pool_id, 0));
|
||||
if (img_it != parent->cli->st_cli->inode_config.end() &&
|
||||
INODE_POOL(img_it->first) == pool_id &&
|
||||
new_cfg["used_for_app"].string_value().substr(0, 3) == "fs:" &&
|
||||
img_it->second.name == new_cfg["used_for_app"].string_value().substr(3))
|
||||
@@ -124,7 +124,7 @@ resume_1:
|
||||
// Only allow metadata image to exist in the FS pool
|
||||
img_it++;
|
||||
}
|
||||
if (img_it != parent->cli->st_cli.inode_config.end() && INODE_POOL(img_it->first) == pool_id)
|
||||
if (img_it != parent->cli->st_cli->inode_config.end() && INODE_POOL(img_it->first) == pool_id)
|
||||
{
|
||||
result = (cli_result_t){ .err = ENOENT, .text = "Pool "+pool_name+" has block images, delete them before using it for VitastorFS, S3 or another app" };
|
||||
state = 100;
|
||||
@@ -145,7 +145,7 @@ resume_1:
|
||||
{ "compare", json11::Json::array {
|
||||
json11::Json::object {
|
||||
{ "target", "MOD" },
|
||||
{ "key", base64_encode(parent->cli->st_cli.etcd_prefix+"/config/pools") },
|
||||
{ "key", base64_encode(parent->cli->st_cli->etcd_prefix+"/config/pools") },
|
||||
{ "result", "LESS" },
|
||||
{ "mod_revision", pools_mod_rev+1 },
|
||||
}
|
||||
@@ -153,7 +153,7 @@ resume_1:
|
||||
{ "success", json11::Json::array {
|
||||
json11::Json::object {
|
||||
{ "request_put", json11::Json::object {
|
||||
{ "key", base64_encode(parent->cli->st_cli.etcd_prefix+"/config/pools") },
|
||||
{ "key", base64_encode(parent->cli->st_cli->etcd_prefix+"/config/pools") },
|
||||
{ "value", base64_encode(new_pools.dump()) },
|
||||
} },
|
||||
},
|
||||
|
||||
@@ -56,7 +56,7 @@ struct pool_remover_t
|
||||
// Get pool id by name (if name given)
|
||||
if (pool_name != "")
|
||||
{
|
||||
for (auto & ic: parent->cli->st_cli.pool_config)
|
||||
for (auto & ic: parent->cli->st_cli->pool_config)
|
||||
{
|
||||
if (ic.second.name == pool_name)
|
||||
{
|
||||
@@ -73,7 +73,7 @@ struct pool_remover_t
|
||||
pool_name = "id " + std::to_string(pool_id);
|
||||
|
||||
// Look-up pool id in pool_config
|
||||
if (parent->cli->st_cli.pool_config.find(pool_id) != parent->cli->st_cli.pool_config.end())
|
||||
if (parent->cli->st_cli->pool_config.find(pool_id) != parent->cli->st_cli->pool_config.end())
|
||||
{
|
||||
pool_valid = 1;
|
||||
}
|
||||
@@ -92,7 +92,7 @@ struct pool_remover_t
|
||||
{
|
||||
std::string images;
|
||||
|
||||
for (auto & ic: parent->cli->st_cli.inode_config)
|
||||
for (auto & ic: parent->cli->st_cli->inode_config)
|
||||
{
|
||||
if (pool_id && INODE_POOL(ic.second.num) != pool_id)
|
||||
{
|
||||
@@ -124,7 +124,7 @@ resume_1:
|
||||
{ "success", json11::Json::array {
|
||||
json11::Json::object {
|
||||
{ "request_range", json11::Json::object {
|
||||
{ "key", base64_encode(parent->cli->st_cli.etcd_prefix+"/config/pools") },
|
||||
{ "key", base64_encode(parent->cli->st_cli->etcd_prefix+"/config/pools") },
|
||||
} }
|
||||
},
|
||||
} },
|
||||
@@ -141,7 +141,7 @@ resume_2:
|
||||
}
|
||||
{
|
||||
// Parse received pools from etcd
|
||||
auto kv = parent->cli->st_cli.parse_etcd_kv(parent->etcd_result["responses"][0]["response_range"]["kvs"][0]);
|
||||
auto kv = parent->cli->st_cli->parse_etcd_kv(parent->etcd_result["responses"][0]["response_range"]["kvs"][0]);
|
||||
|
||||
// Remove pool
|
||||
auto p = kv.value.object_items();
|
||||
@@ -166,7 +166,7 @@ resume_2:
|
||||
{ "compare", json11::Json::array {
|
||||
json11::Json::object {
|
||||
{ "target", "MOD" },
|
||||
{ "key", base64_encode(parent->cli->st_cli.etcd_prefix+"/config/pools") },
|
||||
{ "key", base64_encode(parent->cli->st_cli->etcd_prefix+"/config/pools") },
|
||||
{ "result", "LESS" },
|
||||
{ "mod_revision", pools_mod_rev+1 },
|
||||
}
|
||||
@@ -174,7 +174,7 @@ resume_2:
|
||||
{ "success", json11::Json::array {
|
||||
json11::Json::object {
|
||||
{ "request_put", json11::Json::object {
|
||||
{ "key", base64_encode(parent->cli->st_cli.etcd_prefix+"/config/pools") },
|
||||
{ "key", base64_encode(parent->cli->st_cli->etcd_prefix+"/config/pools") },
|
||||
{ "value", base64_encode(new_pools.dump()) },
|
||||
} },
|
||||
},
|
||||
|
||||
@@ -82,8 +82,8 @@ struct cli_raw_ls_t
|
||||
}
|
||||
if (!pg_count || !pg_stripe_size || !osds.size())
|
||||
{
|
||||
auto pool_it = parent->cli->st_cli.pool_config.find(pool_id);
|
||||
if (pool_it == parent->cli->st_cli.pool_config.end())
|
||||
auto pool_it = parent->cli->st_cli->pool_config.find(pool_id);
|
||||
if (pool_it == parent->cli->st_cli->pool_config.end())
|
||||
{
|
||||
result = (cli_result_t){ .err = EINVAL, .text = "pg_count, pg_stripe_size and osds are required if the pool does not exist" };
|
||||
state = 100;
|
||||
@@ -127,7 +127,7 @@ struct cli_raw_ls_t
|
||||
for (; osd_pos < osd_list.size() && parent->waiting < parent->parallel_osds; osd_pos++)
|
||||
{
|
||||
uint64_t osd_num = osd_list[osd_pos];
|
||||
if (parent->cli->st_cli.peer_states[osd_num].is_null())
|
||||
if (parent->cli->st_cli->peer_states[osd_num].is_null())
|
||||
{
|
||||
fprintf(stderr, "OSD %ju is unavailable, skipping\n", osd_num);
|
||||
continue;
|
||||
|
||||
+41
-41
@@ -129,7 +129,7 @@ resume_1:
|
||||
{
|
||||
if (merge_children[current_child] == inverse_child)
|
||||
continue;
|
||||
rebased_images.push_back(parent->cli->st_cli.inode_config.at(merge_children[current_child]).name);
|
||||
rebased_images.push_back(parent->cli->st_cli->inode_config.at(merge_children[current_child]).name);
|
||||
start_merge_child(merge_children[current_child], merge_children[current_child]);
|
||||
resume_2:
|
||||
while (!wait_result(2))
|
||||
@@ -176,8 +176,8 @@ resume_6:
|
||||
if (chain_list[current_child] == inverse_parent)
|
||||
continue;
|
||||
{
|
||||
auto parent_it = parent->cli->st_cli.inode_config.find(chain_list[current_child]);
|
||||
if (parent_it != parent->cli->st_cli.inode_config.end())
|
||||
auto parent_it = parent->cli->st_cli->inode_config.find(chain_list[current_child]);
|
||||
if (parent_it != parent->cli->st_cli->inode_config.end())
|
||||
deleted_images.push_back(parent_it->second.name);
|
||||
deleted_ids.push_back(chain_list[current_child]);
|
||||
}
|
||||
@@ -264,8 +264,8 @@ resume_100:
|
||||
chain_list.push_back(cur->num);
|
||||
while (cur->num != from_cfg->num && cur->parent_id != 0)
|
||||
{
|
||||
auto it = parent->cli->st_cli.inode_config.find(cur->parent_id);
|
||||
if (it == parent->cli->st_cli.inode_config.end())
|
||||
auto it = parent->cli->st_cli->inode_config.find(cur->parent_id);
|
||||
if (it == parent->cli->st_cli->inode_config.end())
|
||||
{
|
||||
char buf[1024];
|
||||
snprintf(buf, 1024, "Parent inode of layer %s (id 0x%jx) not found", cur->name.c_str(), cur->parent_id);
|
||||
@@ -288,7 +288,7 @@ resume_100:
|
||||
{
|
||||
sources[item] = i--;
|
||||
}
|
||||
for (auto & ic: parent->cli->st_cli.inode_config)
|
||||
for (auto & ic: parent->cli->st_cli->inode_config)
|
||||
{
|
||||
if (!ic.second.parent_id)
|
||||
{
|
||||
@@ -319,7 +319,7 @@ resume_100:
|
||||
reads.push_back(json11::Json::object {
|
||||
{ "request_range", json11::Json::object {
|
||||
{ "key", base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+
|
||||
parent->cli->st_cli->etcd_prefix+
|
||||
"/inode/stats/"+std::to_string(INODE_POOL(inode))+
|
||||
"/"+std::to_string(INODE_NO_POOL(inode))
|
||||
) },
|
||||
@@ -332,7 +332,7 @@ resume_100:
|
||||
reads.push_back(json11::Json::object {
|
||||
{ "request_range", json11::Json::object {
|
||||
{ "key", base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+
|
||||
parent->cli->st_cli->etcd_prefix+
|
||||
"/inode/stats/"+std::to_string(INODE_POOL(inode))+
|
||||
"/"+std::to_string(INODE_NO_POOL(inode))
|
||||
) },
|
||||
@@ -340,7 +340,7 @@ resume_100:
|
||||
});
|
||||
}
|
||||
parent->waiting++;
|
||||
parent->cli->st_cli.etcd_txn_slow(json11::Json::object {
|
||||
parent->cli->st_cli->etcd_txn_slow(json11::Json::object {
|
||||
{ "success", reads },
|
||||
}, [this](std::string err, json11::Json data)
|
||||
{
|
||||
@@ -357,19 +357,19 @@ resume_100:
|
||||
{
|
||||
continue;
|
||||
}
|
||||
auto kv = parent->cli->st_cli.parse_etcd_kv(inode_result["response_range"]["kvs"][0]);
|
||||
auto kv = parent->cli->st_cli->parse_etcd_kv(inode_result["response_range"]["kvs"][0]);
|
||||
pool_id_t pool_id = 0;
|
||||
inode_t inode = 0;
|
||||
char null_byte = 0;
|
||||
int scanned = sscanf(kv.key.c_str() + parent->cli->st_cli.etcd_prefix.length()+13, "%u/%ju%c", &pool_id, &inode, &null_byte);
|
||||
int scanned = sscanf(kv.key.c_str() + parent->cli->st_cli->etcd_prefix.length()+13, "%u/%ju%c", &pool_id, &inode, &null_byte);
|
||||
if (scanned != 2 || !inode)
|
||||
{
|
||||
result = (cli_result_t){ .err = EIO, .text = "Bad key returned from etcd: "+kv.key };
|
||||
state = 100;
|
||||
return;
|
||||
}
|
||||
auto pool_cfg_it = parent->cli->st_cli.pool_config.find(pool_id);
|
||||
if (pool_cfg_it == parent->cli->st_cli.pool_config.end())
|
||||
auto pool_cfg_it = parent->cli->st_cli->pool_config.find(pool_id);
|
||||
if (pool_cfg_it == parent->cli->st_cli->pool_config.end())
|
||||
{
|
||||
result = (cli_result_t){ .err = ENOENT, .text = "Pool "+std::to_string(pool_id)+" does not exist" };
|
||||
state = 100;
|
||||
@@ -412,8 +412,8 @@ resume_100:
|
||||
|
||||
void rename_inverse_parent()
|
||||
{
|
||||
auto child_it = parent->cli->st_cli.inode_config.find(inverse_child);
|
||||
if (child_it == parent->cli->st_cli.inode_config.end())
|
||||
auto child_it = parent->cli->st_cli->inode_config.find(inverse_child);
|
||||
if (child_it == parent->cli->st_cli->inode_config.end())
|
||||
{
|
||||
char buf[1024];
|
||||
snprintf(buf, 1024, "Inode 0x%jx disappeared", inverse_child);
|
||||
@@ -421,8 +421,8 @@ resume_100:
|
||||
state = 100;
|
||||
return;
|
||||
}
|
||||
auto target_it = parent->cli->st_cli.inode_config.find(inverse_parent);
|
||||
if (target_it == parent->cli->st_cli.inode_config.end())
|
||||
auto target_it = parent->cli->st_cli->inode_config.find(inverse_parent);
|
||||
if (target_it == parent->cli->st_cli->inode_config.end())
|
||||
{
|
||||
char buf[1024];
|
||||
snprintf(buf, 1024, "Inode 0x%jx disappeared", inverse_parent);
|
||||
@@ -435,17 +435,17 @@ resume_100:
|
||||
inverse_child_name = child_cfg->name;
|
||||
inverse_parent_name = target_cfg->name;
|
||||
std::string child_cfg_key = base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+
|
||||
parent->cli->st_cli->etcd_prefix+
|
||||
"/config/inode/"+std::to_string(INODE_POOL(inverse_child))+
|
||||
"/"+std::to_string(INODE_NO_POOL(inverse_child))
|
||||
);
|
||||
std::string target_cfg_key = base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+
|
||||
parent->cli->st_cli->etcd_prefix+
|
||||
"/config/inode/"+std::to_string(INODE_POOL(inverse_parent))+
|
||||
"/"+std::to_string(INODE_NO_POOL(inverse_parent))
|
||||
);
|
||||
std::string target_idx_key = base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+"/index/image/"+inverse_parent_name
|
||||
parent->cli->st_cli->etcd_prefix+"/index/image/"+inverse_parent_name
|
||||
);
|
||||
// Fill new configuration
|
||||
inode_config_t new_cfg = *child_cfg;
|
||||
@@ -480,12 +480,12 @@ resume_100:
|
||||
json11::Json::object {
|
||||
{ "request_put", json11::Json::object {
|
||||
{ "key", target_cfg_key },
|
||||
{ "value", base64_encode(json11::Json(parent->cli->st_cli.serialize_inode_cfg(&new_cfg)).dump()) },
|
||||
{ "value", base64_encode(json11::Json(parent->cli->st_cli->serialize_inode_cfg(&new_cfg)).dump()) },
|
||||
} },
|
||||
},
|
||||
json11::Json::object {
|
||||
{ "request_put", json11::Json::object {
|
||||
{ "key", base64_encode(parent->cli->st_cli.etcd_prefix+"/index/image/"+child_cfg->name) },
|
||||
{ "key", base64_encode(parent->cli->st_cli->etcd_prefix+"/index/image/"+child_cfg->name) },
|
||||
{ "value", base64_encode(json11::Json({
|
||||
{ "id", INODE_NO_POOL(inverse_parent) },
|
||||
{ "pool_id", (uint64_t)INODE_POOL(inverse_parent) },
|
||||
@@ -494,14 +494,14 @@ resume_100:
|
||||
},
|
||||
};
|
||||
// Reparent children of inverse_child
|
||||
for (auto & cp: parent->cli->st_cli.inode_config)
|
||||
for (auto & cp: parent->cli->st_cli->inode_config)
|
||||
{
|
||||
if (cp.second.parent_id == child_cfg->num)
|
||||
{
|
||||
auto cp_cfg = cp.second;
|
||||
cp_cfg.parent_id = inverse_parent;
|
||||
auto cp_key = base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+
|
||||
parent->cli->st_cli->etcd_prefix+
|
||||
"/config/inode/"+std::to_string(INODE_POOL(cp.second.num))+
|
||||
"/"+std::to_string(INODE_NO_POOL(cp.second.num))
|
||||
);
|
||||
@@ -514,13 +514,13 @@ resume_100:
|
||||
txn.push_back(json11::Json::object {
|
||||
{ "request_put", json11::Json::object {
|
||||
{ "key", cp_key },
|
||||
{ "value", base64_encode(json11::Json(parent->cli->st_cli.serialize_inode_cfg(&cp_cfg)).dump()) },
|
||||
{ "value", base64_encode(json11::Json(parent->cli->st_cli->serialize_inode_cfg(&cp_cfg)).dump()) },
|
||||
} },
|
||||
});
|
||||
}
|
||||
}
|
||||
parent->waiting++;
|
||||
parent->cli->st_cli.etcd_txn_slow(json11::Json::object {
|
||||
parent->cli->st_cli->etcd_txn_slow(json11::Json::object {
|
||||
{ "compare", cmp },
|
||||
{ "success", txn },
|
||||
}, [this](std::string err, json11::Json res)
|
||||
@@ -550,8 +550,8 @@ resume_100:
|
||||
|
||||
void delete_inode_config(inode_t cur)
|
||||
{
|
||||
auto cur_cfg_it = parent->cli->st_cli.inode_config.find(cur);
|
||||
if (cur_cfg_it == parent->cli->st_cli.inode_config.end())
|
||||
auto cur_cfg_it = parent->cli->st_cli->inode_config.find(cur);
|
||||
if (cur_cfg_it == parent->cli->st_cli->inode_config.end())
|
||||
{
|
||||
char buf[1024];
|
||||
snprintf(buf, 1024, "Inode 0x%jx disappeared", cur);
|
||||
@@ -562,12 +562,12 @@ resume_100:
|
||||
inode_config_t *cur_cfg = &cur_cfg_it->second;
|
||||
std::string cur_name = cur_cfg->name;
|
||||
std::string cur_cfg_key = base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+
|
||||
parent->cli->st_cli->etcd_prefix+
|
||||
"/config/inode/"+std::to_string(INODE_POOL(cur))+
|
||||
"/"+std::to_string(INODE_NO_POOL(cur))
|
||||
);
|
||||
parent->waiting++;
|
||||
parent->cli->st_cli.etcd_txn_slow(json11::Json::object {
|
||||
parent->cli->st_cli->etcd_txn_slow(json11::Json::object {
|
||||
{ "compare", json11::Json::array {
|
||||
json11::Json::object {
|
||||
{ "target", "MOD" },
|
||||
@@ -584,7 +584,7 @@ resume_100:
|
||||
},
|
||||
json11::Json::object {
|
||||
{ "request_delete_range", json11::Json::object {
|
||||
{ "key", base64_encode(parent->cli->st_cli.etcd_prefix+"/index/image/"+cur_name) },
|
||||
{ "key", base64_encode(parent->cli->st_cli->etcd_prefix+"/index/image/"+cur_name) },
|
||||
} },
|
||||
},
|
||||
} },
|
||||
@@ -604,8 +604,8 @@ resume_100:
|
||||
return;
|
||||
}
|
||||
// Modify inode_config for library users to be able to take it from there immediately
|
||||
parent->cli->st_cli.inode_by_name.erase(cur_name);
|
||||
parent->cli->st_cli.inode_config.erase(cur);
|
||||
parent->cli->st_cli->inode_by_name.erase(cur_name);
|
||||
parent->cli->st_cli->inode_config.erase(cur);
|
||||
if (parent->progress)
|
||||
printf("Layer %s deleted\n", cur_name.c_str());
|
||||
parent->ringloop->wakeup();
|
||||
@@ -614,8 +614,8 @@ resume_100:
|
||||
|
||||
void start_merge_child(inode_t child_inode, inode_t target_inode)
|
||||
{
|
||||
auto child_it = parent->cli->st_cli.inode_config.find(child_inode);
|
||||
if (child_it == parent->cli->st_cli.inode_config.end())
|
||||
auto child_it = parent->cli->st_cli->inode_config.find(child_inode);
|
||||
if (child_it == parent->cli->st_cli->inode_config.end())
|
||||
{
|
||||
char buf[1024];
|
||||
snprintf(buf, 1024, "Inode 0x%jx disappeared", child_inode);
|
||||
@@ -623,8 +623,8 @@ resume_100:
|
||||
state = 100;
|
||||
return;
|
||||
}
|
||||
auto target_it = parent->cli->st_cli.inode_config.find(target_inode);
|
||||
if (target_it == parent->cli->st_cli.inode_config.end())
|
||||
auto target_it = parent->cli->st_cli->inode_config.find(target_inode);
|
||||
if (target_it == parent->cli->st_cli->inode_config.end())
|
||||
{
|
||||
char buf[1024];
|
||||
snprintf(buf, 1024, "Inode 0x%jx disappeared", target_inode);
|
||||
@@ -644,8 +644,8 @@ resume_100:
|
||||
|
||||
void start_mark_deleted(inode_t inode)
|
||||
{
|
||||
auto ino_it = parent->cli->st_cli.inode_config.find(inode);
|
||||
if (ino_it == parent->cli->st_cli.inode_config.end())
|
||||
auto ino_it = parent->cli->st_cli->inode_config.find(inode);
|
||||
if (ino_it == parent->cli->st_cli->inode_config.end())
|
||||
{
|
||||
char buf[1024];
|
||||
snprintf(buf, 1024, "Inode 0x%jx disappeared", inode);
|
||||
@@ -665,8 +665,8 @@ resume_100:
|
||||
|
||||
void start_delete_source(inode_t inode)
|
||||
{
|
||||
auto source = parent->cli->st_cli.inode_config.find(inode);
|
||||
if (source == parent->cli->st_cli.inode_config.end())
|
||||
auto source = parent->cli->st_cli->inode_config.find(inode);
|
||||
if (source == parent->cli->st_cli->inode_config.end())
|
||||
{
|
||||
char buf[1024];
|
||||
snprintf(buf, 1024, "Inode 0x%jx disappeared", inode);
|
||||
|
||||
@@ -44,8 +44,8 @@ struct rm_inode_t
|
||||
|
||||
void start_delete()
|
||||
{
|
||||
auto pool_it = parent->cli->st_cli.pool_config.find(pool_id);
|
||||
if (pool_it == parent->cli->st_cli.pool_config.end())
|
||||
auto pool_it = parent->cli->st_cli->pool_config.find(pool_id);
|
||||
if (pool_it == parent->cli->st_cli->pool_config.end())
|
||||
{
|
||||
result = (cli_result_t){ .err = EINVAL, .text = "Pool does not exist" };
|
||||
state = 100;
|
||||
@@ -196,8 +196,8 @@ struct rm_inode_t
|
||||
{
|
||||
fprintf(stderr, "Warning: some OSDs don't indicate left_on_dead PG OSDs"
|
||||
" in delete replies, falling back to simpler checks\n");
|
||||
auto pool_it = parent->cli->st_cli.pool_config.find(pool_id);
|
||||
if (pool_it != parent->cli->st_cli.pool_config.end())
|
||||
auto pool_it = parent->cli->st_cli->pool_config.find(pool_id);
|
||||
if (pool_it != parent->cli->st_cli->pool_config.end())
|
||||
{
|
||||
std::set<osd_num_t> all_peers;
|
||||
for (auto pg_num: fallback_pgs)
|
||||
@@ -217,7 +217,7 @@ struct rm_inode_t
|
||||
all_peers.erase(0);
|
||||
for (auto peer_osd: all_peers)
|
||||
{
|
||||
if (parent->cli->st_cli.peer_states[peer_osd].is_null())
|
||||
if (parent->cli->st_cli->peer_states[peer_osd].is_null())
|
||||
inactive_osds.insert(peer_osd);
|
||||
}
|
||||
}
|
||||
|
||||
+12
-12
@@ -68,14 +68,14 @@ struct rm_osd_t
|
||||
// Check if OSDs are still up
|
||||
for (auto osd_id: to_remove)
|
||||
{
|
||||
if (parent->cli->st_cli.peer_states.find(osd_id) != parent->cli->st_cli.peer_states.end())
|
||||
if (parent->cli->st_cli->peer_states.find(osd_id) != parent->cli->st_cli->peer_states.end())
|
||||
{
|
||||
is_warning = !allow_up;
|
||||
still_up.push_back(osd_id);
|
||||
}
|
||||
}
|
||||
// Check if OSDs are still used in data distribution
|
||||
for (auto & pp: parent->cli->st_cli.pool_config)
|
||||
for (auto & pp: parent->cli->st_cli->pool_config)
|
||||
{
|
||||
// Will OSD deletion make pool incomplete / down / degraded?
|
||||
bool pool_incomplete = false, pool_down = false, pool_degraded = false;
|
||||
@@ -189,14 +189,14 @@ struct rm_osd_t
|
||||
json11::Json::object {
|
||||
{ "request_range", json11::Json::object {
|
||||
{ "key", base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+"/pg/config"
|
||||
parent->cli->st_cli->etcd_prefix+"/pg/config"
|
||||
) },
|
||||
} },
|
||||
},
|
||||
json11::Json::object {
|
||||
{ "request_range", json11::Json::object {
|
||||
{ "key", base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+"/history/last_clean_pgs"
|
||||
parent->cli->st_cli->etcd_prefix+"/history/last_clean_pgs"
|
||||
) },
|
||||
} },
|
||||
},
|
||||
@@ -212,10 +212,10 @@ struct rm_osd_t
|
||||
return;
|
||||
}
|
||||
{
|
||||
auto kv = parent->cli->st_cli.parse_etcd_kv(parent->etcd_result["responses"][0]["response_range"]["kvs"][0]);
|
||||
auto kv = parent->cli->st_cli->parse_etcd_kv(parent->etcd_result["responses"][0]["response_range"]["kvs"][0]);
|
||||
new_pgs = remove_osds_from_pgs(kv);
|
||||
new_pgs_mod_rev = kv.mod_revision;
|
||||
kv = parent->cli->st_cli.parse_etcd_kv(parent->etcd_result["responses"][1]["response_range"]["kvs"][0]);
|
||||
kv = parent->cli->st_cli->parse_etcd_kv(parent->etcd_result["responses"][1]["response_range"]["kvs"][0]);
|
||||
new_clean_pgs = remove_osds_from_pgs(kv);
|
||||
new_clean_pgs_mod_rev = kv.mod_revision;
|
||||
}
|
||||
@@ -235,14 +235,14 @@ struct rm_osd_t
|
||||
rm_items[i] = json11::Json::object {
|
||||
{ "request_delete_range", json11::Json::object {
|
||||
{ "key", base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+rm_items[i].string_value()
|
||||
parent->cli->st_cli->etcd_prefix+rm_items[i].string_value()
|
||||
) },
|
||||
} },
|
||||
};
|
||||
}
|
||||
if (!new_pgs.is_null())
|
||||
{
|
||||
auto pgs_key = base64_encode(parent->cli->st_cli.etcd_prefix+"/pg/config");
|
||||
auto pgs_key = base64_encode(parent->cli->st_cli->etcd_prefix+"/pg/config");
|
||||
rm_items.push_back(json11::Json::object {
|
||||
{ "request_put", json11::Json::object {
|
||||
{ "key", pgs_key },
|
||||
@@ -258,7 +258,7 @@ struct rm_osd_t
|
||||
}
|
||||
if (!new_clean_pgs.is_null())
|
||||
{
|
||||
auto pgs_key = base64_encode(parent->cli->st_cli.etcd_prefix+"/history/last_clean_pgs");
|
||||
auto pgs_key = base64_encode(parent->cli->st_cli->etcd_prefix+"/history/last_clean_pgs");
|
||||
rm_items.push_back(json11::Json::object {
|
||||
{ "request_put", json11::Json::object {
|
||||
{ "key", pgs_key },
|
||||
@@ -375,7 +375,7 @@ struct rm_osd_t
|
||||
goto resume_0;
|
||||
history_updates.clear();
|
||||
history_checks.clear();
|
||||
for (auto & pp: parent->cli->st_cli.pool_config)
|
||||
for (auto & pp: parent->cli->st_cli->pool_config)
|
||||
{
|
||||
bool update_pg_history = false;
|
||||
auto & pool_cfg = pp.second;
|
||||
@@ -420,7 +420,7 @@ struct rm_osd_t
|
||||
if (update_pg_history)
|
||||
{
|
||||
std::string history_key = base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+"/pg/history/"+
|
||||
parent->cli->st_cli->etcd_prefix+"/pg/history/"+
|
||||
std::to_string(pool_cfg.id)+"/"+std::to_string(pg_num)
|
||||
);
|
||||
auto hist = json11::Json::object {
|
||||
@@ -440,7 +440,7 @@ struct rm_osd_t
|
||||
{ "target", "MOD" },
|
||||
{ "key", history_key },
|
||||
{ "result", "LESS" },
|
||||
{ "mod_revision", parent->cli->st_cli.etcd_watch_revision_pg+1 },
|
||||
{ "mod_revision", parent->cli->st_cli->etcd_watch_revision_pg+1 },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ struct wildcard_remover_t
|
||||
{
|
||||
auto child_id = ino_it->first;
|
||||
auto parent_id = ino_it->second;
|
||||
auto & parent_cfg = parent->cli->st_cli.inode_config.at(parent_id);
|
||||
auto & parent_cfg = parent->cli->st_cli->inode_config.at(parent_id);
|
||||
if (parent_cfg.parent_id)
|
||||
{
|
||||
auto chain_it = chains.find(parent_cfg.parent_id);
|
||||
@@ -71,7 +71,7 @@ struct wildcard_remover_t
|
||||
std::vector<inode_rev_t> ver_chain;
|
||||
do
|
||||
{
|
||||
auto & inode_cfg = parent->cli->st_cli.inode_config.at(child_id);
|
||||
auto & inode_cfg = parent->cli->st_cli->inode_config.at(child_id);
|
||||
ver_chain.push_back((inode_rev_t){ .inode_num = child_id, .meta_rev = inode_cfg.mod_revision });
|
||||
if (child_id == parent_id)
|
||||
break;
|
||||
@@ -89,7 +89,7 @@ struct wildcard_remover_t
|
||||
do
|
||||
{
|
||||
rank++;
|
||||
cur_id = parent->cli->st_cli.inode_config.at(cur_id).parent_id;
|
||||
cur_id = parent->cli->st_cli->inode_config.at(cur_id).parent_id;
|
||||
} while (cur_id && cur_id != parent_id);
|
||||
ranks[parent_id] = rank;
|
||||
}
|
||||
@@ -111,7 +111,7 @@ struct wildcard_remover_t
|
||||
state = 0;
|
||||
chains.clear();
|
||||
// Select images to delete
|
||||
for (auto & ic: parent->cli->st_cli.inode_config)
|
||||
for (auto & ic: parent->cli->st_cli->inode_config)
|
||||
{
|
||||
for (auto & glob: globs)
|
||||
{
|
||||
@@ -131,11 +131,11 @@ struct wildcard_remover_t
|
||||
// Check for parallel changes
|
||||
for (auto & irev: versioned_chains[i])
|
||||
{
|
||||
auto inode_it = parent->cli->st_cli.inode_config.find(irev.inode_num);
|
||||
if (inode_it == parent->cli->st_cli.inode_config.end() ||
|
||||
auto inode_it = parent->cli->st_cli->inode_config.find(irev.inode_num);
|
||||
if (inode_it == parent->cli->st_cli->inode_config.end() ||
|
||||
inode_it->second.mod_revision > irev.meta_rev)
|
||||
{
|
||||
if (inode_it != parent->cli->st_cli.inode_config.end())
|
||||
if (inode_it != parent->cli->st_cli->inode_config.end())
|
||||
fprintf(stderr, "Warning: image %s modified by someone else during deletion, restarting wildcard deletion\n", inode_it->second.name.c_str());
|
||||
else
|
||||
fprintf(stderr, "Warning: inode %jx modified by someone else during deletion, retrying wildcard deletion\n", irev.inode_num);
|
||||
@@ -144,8 +144,8 @@ struct wildcard_remover_t
|
||||
}
|
||||
// Delete
|
||||
{
|
||||
auto from_cfg = parent->cli->st_cli.inode_config.at(versioned_chains[i].back().inode_num);
|
||||
auto to_cfg = parent->cli->st_cli.inode_config.at(versioned_chains[i].front().inode_num);
|
||||
auto from_cfg = parent->cli->st_cli->inode_config.at(versioned_chains[i].back().inode_num);
|
||||
auto to_cfg = parent->cli->st_cli->inode_config.at(versioned_chains[i].front().inode_num);
|
||||
sub_cfg = cfg.object_items();
|
||||
sub_cfg.erase("globs");
|
||||
sub_cfg.erase("exact");
|
||||
|
||||
+16
-16
@@ -37,14 +37,14 @@ struct status_printer_t
|
||||
goto resume_2;
|
||||
// etcd states
|
||||
{
|
||||
auto addrs = parent->cli->st_cli.get_addresses();
|
||||
auto addrs = parent->cli->st_cli->get_addresses();
|
||||
etcd_states.resize(addrs.size());
|
||||
for (int i = 0; i < etcd_states.size(); i++)
|
||||
{
|
||||
parent->waiting++;
|
||||
parent->cli->st_cli.etcd_call_oneshot(
|
||||
parent->cli->st_cli->etcd_call_oneshot(
|
||||
addrs[i], "/maintenance/status", json11::Json::object(),
|
||||
parent->cli->st_cli.etcd_quick_timeout, [this, i](std::string err, json11::Json res)
|
||||
parent->cli->st_cli->etcd_quick_timeout, [this, i](std::string err, json11::Json res)
|
||||
{
|
||||
parent->waiting--;
|
||||
etcd_states[i] = err != "" ? json11::Json::object{ { "error", err } } : res;
|
||||
@@ -62,23 +62,23 @@ resume_1:
|
||||
{ "success", json11::Json::array {
|
||||
json11::Json::object {
|
||||
{ "request_range", json11::Json::object {
|
||||
{ "key", base64_encode(parent->cli->st_cli.etcd_prefix+"/mon/") },
|
||||
{ "range_end", base64_encode(parent->cli->st_cli.etcd_prefix+"/mon0") },
|
||||
{ "key", base64_encode(parent->cli->st_cli->etcd_prefix+"/mon/") },
|
||||
{ "range_end", base64_encode(parent->cli->st_cli->etcd_prefix+"/mon0") },
|
||||
} },
|
||||
},
|
||||
json11::Json::object {
|
||||
{ "request_range", json11::Json::object {
|
||||
{ "key", base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+"/osd/stats/"
|
||||
parent->cli->st_cli->etcd_prefix+"/osd/stats/"
|
||||
) },
|
||||
{ "range_end", base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+"/osd/stats0"
|
||||
parent->cli->st_cli->etcd_prefix+"/osd/stats0"
|
||||
) },
|
||||
} },
|
||||
},
|
||||
json11::Json::object {
|
||||
{ "request_range", json11::Json::object {
|
||||
{ "key", base64_encode(parent->cli->st_cli.etcd_prefix+"/stats") },
|
||||
{ "key", base64_encode(parent->cli->st_cli->etcd_prefix+"/stats") },
|
||||
} },
|
||||
},
|
||||
} },
|
||||
@@ -97,7 +97,7 @@ resume_2:
|
||||
auto osd_stats = parent->etcd_result["responses"][1]["response_range"]["kvs"];
|
||||
if (parent->etcd_result["responses"][2]["response_range"]["kvs"].array_items().size() > 0)
|
||||
{
|
||||
agg_stats = parent->cli->st_cli.parse_etcd_kv(parent->etcd_result["responses"][2]["response_range"]["kvs"][0]).value;
|
||||
agg_stats = parent->cli->st_cli->parse_etcd_kv(parent->etcd_result["responses"][2]["response_range"]["kvs"][0]).value;
|
||||
}
|
||||
int etcd_alive = 0;
|
||||
uint64_t etcd_db_size = 0;
|
||||
@@ -120,8 +120,8 @@ resume_2:
|
||||
std::string mon_master;
|
||||
for (int i = 0; i < mon_members.size(); i++)
|
||||
{
|
||||
auto kv = parent->cli->st_cli.parse_etcd_kv(mon_members[i]);
|
||||
kv.key = kv.key.substr(parent->cli->st_cli.etcd_prefix.size());
|
||||
auto kv = parent->cli->st_cli->parse_etcd_kv(mon_members[i]);
|
||||
kv.key = kv.key.substr(parent->cli->st_cli->etcd_prefix.size());
|
||||
if (kv.key.substr(0, 12) == "/mon/member/")
|
||||
mon_count++;
|
||||
else if (kv.key == "/mon/master")
|
||||
@@ -153,8 +153,8 @@ resume_2:
|
||||
osds_nearfull++;
|
||||
}
|
||||
}
|
||||
auto peer_it = parent->cli->st_cli.peer_states.find(stat_osd_num);
|
||||
if (peer_it != parent->cli->st_cli.peer_states.end())
|
||||
auto peer_it = parent->cli->st_cli->peer_states.find(stat_osd_num);
|
||||
if (peer_it != parent->cli->st_cli->peer_states.end())
|
||||
{
|
||||
osd_up++;
|
||||
if (value["slow_ops_primary"].uint64_value() > 0)
|
||||
@@ -177,7 +177,7 @@ resume_2:
|
||||
std::string backfillfull_pool_names;
|
||||
std::map<std::string, int> pgs_by_state;
|
||||
std::string pgs_by_state_str;
|
||||
for (auto & pool_pair: parent->cli->st_cli.pool_config)
|
||||
for (auto & pool_pair: parent->cli->st_cli->pool_config)
|
||||
{
|
||||
auto & pool_cfg = pool_pair.second;
|
||||
bool active = pool_cfg.real_pg_count > 0;
|
||||
@@ -262,7 +262,7 @@ resume_2:
|
||||
std::string str(obj_states[i]);
|
||||
uint64_t obj_n = agg_stats["object_bytes"][str].uint64_value();
|
||||
if (!obj_n)
|
||||
obj_n = agg_stats["object_counts"][str].uint64_value() * parent->cli->st_cli.global_block_size;
|
||||
obj_n = agg_stats["object_counts"][str].uint64_value() * parent->cli->st_cli->global_block_size;
|
||||
json_status[str+"_data"] = obj_n;
|
||||
}
|
||||
printf("%s\n", json11::Json(json_status).dump().c_str());
|
||||
@@ -275,7 +275,7 @@ resume_2:
|
||||
std::string str(obj_states[i]);
|
||||
uint64_t obj_n = agg_stats["object_bytes"][str].uint64_value();
|
||||
if (!obj_n)
|
||||
obj_n = agg_stats["object_counts"][str].uint64_value() * parent->cli->st_cli.global_block_size;
|
||||
obj_n = agg_stats["object_counts"][str].uint64_value() * parent->cli->st_cli->global_block_size;
|
||||
if (!i || obj_n > 0)
|
||||
more_states += format_size(obj_n)+" "+str+", ";
|
||||
}
|
||||
|
||||
+1
-1
@@ -527,7 +527,7 @@ void kv_cli_t::handle_cmd(const std::vector<std::string> & cmd, std::function<vo
|
||||
{
|
||||
inode_id = 0;
|
||||
name = trim(name);
|
||||
for (auto & ic: cli->st_cli.inode_config)
|
||||
for (auto & ic: cli->st_cli->inode_config)
|
||||
{
|
||||
if (ic.second.name == name)
|
||||
{
|
||||
|
||||
+2
-2
@@ -510,8 +510,8 @@ void kv_db_t::open(inode_t inode_id, json11::Json cfg, std::function<void(int)>
|
||||
cb(-EINVAL);
|
||||
return;
|
||||
}
|
||||
auto pool_it = cli->st_cli.pool_config.find(INODE_POOL(inode_id));
|
||||
if (pool_it == cli->st_cli.pool_config.end())
|
||||
auto pool_it = cli->st_cli->pool_config.find(INODE_POOL(inode_id));
|
||||
if (pool_it == cli->st_cli->pool_config.end())
|
||||
{
|
||||
cb(-EINVAL);
|
||||
return;
|
||||
|
||||
+26
-26
@@ -61,7 +61,7 @@ static fattr3 get_dir_attributes(nfs_client_t *self, std::string dir)
|
||||
|
||||
static fattr3 get_file_attributes(nfs_client_t *self, inode_t inode_num)
|
||||
{
|
||||
auto & inode_cfg = self->parent->cli->st_cli.inode_config.at(inode_num);
|
||||
auto & inode_cfg = self->parent->cli->st_cli->inode_config.at(inode_num);
|
||||
uint64_t used = 0;
|
||||
auto st_it = self->parent->inode_stats.find(inode_num);
|
||||
if (st_it != self->parent->inode_stats.end())
|
||||
@@ -125,8 +125,8 @@ static int block_nfs3_getattr_proc(void *opaque, rpc_op_t *rop)
|
||||
auto inode_num_it = self->parent->blockfs->inode_by_hash.find(dirhash);
|
||||
if (inode_num_it != self->parent->blockfs->inode_by_hash.end())
|
||||
inode_num = inode_num_it->second;
|
||||
auto inode_it = self->parent->cli->st_cli.inode_config.find(inode_num);
|
||||
if (inode_num && inode_it != self->parent->cli->st_cli.inode_config.end())
|
||||
auto inode_it = self->parent->cli->st_cli->inode_config.find(inode_num);
|
||||
if (inode_num && inode_it != self->parent->cli->st_cli->inode_config.end())
|
||||
{
|
||||
// File info
|
||||
auto & inode_cfg = inode_it->second;
|
||||
@@ -191,7 +191,7 @@ static int block_nfs3_setattr_proc(void *opaque, rpc_op_t *rop)
|
||||
}
|
||||
if (args->new_attributes.size.set_it)
|
||||
{
|
||||
auto & inode_cfg = self->parent->cli->st_cli.inode_config.at(ino_it->second);
|
||||
auto & inode_cfg = self->parent->cli->st_cli->inode_config.at(ino_it->second);
|
||||
self->parent->cmd->loop_and_wait(self->parent->cmd->start_modify(json11::Json::object {
|
||||
{ "image", inode_cfg.name },
|
||||
{ "resize", (uint64_t)args->new_attributes.size.size },
|
||||
@@ -219,7 +219,7 @@ static int block_nfs3_lookup_proc(void *opaque, rpc_op_t *rop)
|
||||
if (full_name != "")
|
||||
{
|
||||
std::string fh = "S"+base64_encode(sha256(full_name));
|
||||
for (auto & ic: self->parent->cli->st_cli.inode_config)
|
||||
for (auto & ic: self->parent->cli->st_cli->inode_config)
|
||||
{
|
||||
if (ic.second.name == full_name)
|
||||
{
|
||||
@@ -304,9 +304,9 @@ static int block_nfs3_read_proc(void *opaque, rpc_op_t *rop)
|
||||
rpc_queue_reply(rop);
|
||||
return 0;
|
||||
}
|
||||
uint64_t alignment = self->parent->cli->st_cli.global_bitmap_granularity;
|
||||
auto pool_cfg = self->parent->cli->st_cli.pool_config.find(INODE_POOL(ino_it->second));
|
||||
if (pool_cfg != self->parent->cli->st_cli.pool_config.end())
|
||||
uint64_t alignment = self->parent->cli->st_cli->global_bitmap_granularity;
|
||||
auto pool_cfg = self->parent->cli->st_cli->pool_config.find(INODE_POOL(ino_it->second));
|
||||
if (pool_cfg != self->parent->cli->st_cli->pool_config.end())
|
||||
{
|
||||
alignment = pool_cfg->second.bitmap_granularity;
|
||||
}
|
||||
@@ -380,9 +380,9 @@ static int block_nfs3_write_proc(void *opaque, rpc_op_t *rop)
|
||||
return 0;
|
||||
}
|
||||
uint64_t count = args->count > args->data.size ? args->data.size : args->count;
|
||||
uint64_t alignment = self->parent->cli->st_cli.global_bitmap_granularity;
|
||||
auto pool_cfg = self->parent->cli->st_cli.pool_config.find(INODE_POOL(ino_it->second));
|
||||
if (pool_cfg != self->parent->cli->st_cli.pool_config.end())
|
||||
uint64_t alignment = self->parent->cli->st_cli->global_bitmap_granularity;
|
||||
auto pool_cfg = self->parent->cli->st_cli->pool_config.find(INODE_POOL(ino_it->second));
|
||||
if (pool_cfg != self->parent->cli->st_cli->pool_config.end())
|
||||
{
|
||||
alignment = pool_cfg->second.bitmap_granularity;
|
||||
}
|
||||
@@ -495,8 +495,8 @@ static void extend_inode(nfs_client_t *self, uint64_t inode, uint64_t new_size)
|
||||
// Send an extend request
|
||||
auto & ext = self->parent->blockfs->extends[inode];
|
||||
ext.cur_extend = new_size;
|
||||
auto inode_it = self->parent->cli->st_cli.inode_config.find(inode);
|
||||
if (inode_it != self->parent->cli->st_cli.inode_config.end() &&
|
||||
auto inode_it = self->parent->cli->st_cli->inode_config.find(inode);
|
||||
if (inode_it != self->parent->cli->st_cli->inode_config.end() &&
|
||||
inode_it->second.size < new_size)
|
||||
{
|
||||
self->parent->cmd->loop_and_wait(self->parent->cmd->start_modify(json11::Json::object {
|
||||
@@ -561,8 +561,8 @@ static void nfs_do_write(nfs_client_t *self, std::multimap<extend_size_t, extend
|
||||
static void nfs_resize_write(nfs_client_t *self, rpc_op_t *rop, uint64_t inode, uint64_t new_size, uint64_t offset, uint64_t count, void *buf)
|
||||
{
|
||||
// Check if we have to resize the inode during write
|
||||
auto inode_it = self->parent->cli->st_cli.inode_config.find(inode);
|
||||
if (inode_it != self->parent->cli->st_cli.inode_config.end() &&
|
||||
auto inode_it = self->parent->cli->st_cli->inode_config.find(inode);
|
||||
if (inode_it != self->parent->cli->st_cli->inode_config.end() &&
|
||||
inode_it->second.size < new_size)
|
||||
{
|
||||
auto ewr_it = self->parent->blockfs->extend_writes.emplace((extend_size_t){
|
||||
@@ -618,7 +618,7 @@ static int block_nfs3_create_proc(void *opaque, rpc_op_t *rop)
|
||||
*reply = (CREATE3res){ .status = vitastor_nfs_map_err(r.err) };
|
||||
if (!r.err)
|
||||
{
|
||||
auto inode_num = self->parent->cli->st_cli.inode_by_name.at(full_name);
|
||||
auto inode_num = self->parent->cli->st_cli->inode_by_name.at(full_name);
|
||||
reply->resok = (CREATE3resok){
|
||||
.obj = {
|
||||
.handle_follows = 1,
|
||||
@@ -655,8 +655,8 @@ static int block_nfs3_mkdir_proc(void *opaque, rpc_op_t *rop)
|
||||
rpc_queue_reply(rop);
|
||||
return 0;
|
||||
}
|
||||
auto inode_it = self->parent->cli->st_cli.inode_by_name.find(full_name);
|
||||
if (inode_it != self->parent->cli->st_cli.inode_by_name.end())
|
||||
auto inode_it = self->parent->cli->st_cli->inode_by_name.find(full_name);
|
||||
if (inode_it != self->parent->cli->st_cli->inode_by_name.end())
|
||||
{
|
||||
*reply = (MKDIR3res){ .status = NFS3ERR_EXIST };
|
||||
rpc_queue_reply(rop);
|
||||
@@ -765,7 +765,7 @@ static int block_nfs3_rmdir_proc(void *opaque, rpc_op_t *rop)
|
||||
return 0;
|
||||
}
|
||||
std::string prefix = full_name+"/";
|
||||
for (auto & ic: self->parent->cli->st_cli.inode_config)
|
||||
for (auto & ic: self->parent->cli->st_cli->inode_config)
|
||||
{
|
||||
if (prefix != "" && ic.second.name.substr(0, prefix.size()) == prefix)
|
||||
{
|
||||
@@ -795,7 +795,7 @@ static int continue_dir_rename(nfs_dir_rename_state *rename_st)
|
||||
if (!rename_st->items.size())
|
||||
{
|
||||
std::string old_prefix = rename_st->old_name+"/";
|
||||
for (auto & ic: self->parent->cli->st_cli.inode_config)
|
||||
for (auto & ic: self->parent->cli->st_cli->inode_config)
|
||||
{
|
||||
if (ic.second.name.substr(0, old_prefix.size()) == old_prefix)
|
||||
rename_st->items.push_back(ic.second.name);
|
||||
@@ -862,7 +862,7 @@ static int block_nfs3_rename_proc(void *opaque, rpc_op_t *rop)
|
||||
bool old_is_dir = self->parent->blockfs->dir_info.find(old_name) != self->parent->blockfs->dir_info.end();
|
||||
bool new_is_dir = self->parent->blockfs->dir_info.find(new_name) != self->parent->blockfs->dir_info.end();
|
||||
bool old_is_file = false, new_is_file = false;
|
||||
for (auto & ic: self->parent->cli->st_cli.inode_config)
|
||||
for (auto & ic: self->parent->cli->st_cli->inode_config)
|
||||
{
|
||||
if (ic.second.name == new_name)
|
||||
new_is_file = true;
|
||||
@@ -1000,7 +1000,7 @@ static void block_nfs3_readdir_common(void *opaque, rpc_op_t *rop, bool is_plus)
|
||||
}
|
||||
std::string prefix = dir.size() ? dir+"/" : self->parent->blockfs->name_prefix;
|
||||
std::map<std::string, struct entryplus3> entries;
|
||||
for (auto & ic: self->parent->cli->st_cli.inode_config)
|
||||
for (auto & ic: self->parent->cli->st_cli->inode_config)
|
||||
{
|
||||
auto & inode_cfg = ic.second;
|
||||
if (prefix != "" && inode_cfg.name.substr(0, prefix.size()) != prefix)
|
||||
@@ -1190,11 +1190,11 @@ void block_fs_state_t::init(nfs_proxy_t *proxy, json11::Json cfg)
|
||||
.mod_rev = 0,
|
||||
};
|
||||
clock_gettime(CLOCK_REALTIME, &dir_info[""].mtime);
|
||||
assert(proxy->cli->st_cli.on_inode_change_hook == NULL);
|
||||
proxy->cli->st_cli.on_inode_change_hook = [this, proxy](inode_t changed_inode, bool removed)
|
||||
assert(proxy->cli->st_cli->on_inode_change_hook == NULL);
|
||||
proxy->cli->st_cli->on_inode_change_hook = [this, proxy](inode_t changed_inode, bool removed)
|
||||
{
|
||||
auto inode_cfg_it = proxy->cli->st_cli.inode_config.find(changed_inode);
|
||||
if (inode_cfg_it == proxy->cli->st_cli.inode_config.end())
|
||||
auto inode_cfg_it = proxy->cli->st_cli->inode_config.find(changed_inode);
|
||||
if (inode_cfg_it == proxy->cli->st_cli->inode_config.end())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
+7
-7
@@ -219,7 +219,7 @@ void nfs_kv_procs(nfs_client_t *self)
|
||||
void kv_fs_state_t::init(nfs_proxy_t *proxy, json11::Json cfg)
|
||||
{
|
||||
this->proxy = proxy;
|
||||
auto & pool_cfg = proxy->cli->st_cli.pool_config.at(proxy->default_pool_id);
|
||||
auto & pool_cfg = proxy->cli->st_cli->pool_config.at(proxy->default_pool_id);
|
||||
fs_kv_inode = cfg["fs"].uint64_value();
|
||||
if (fs_kv_inode)
|
||||
{
|
||||
@@ -231,7 +231,7 @@ void kv_fs_state_t::init(nfs_proxy_t *proxy, json11::Json cfg)
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto & ic: proxy->cli->st_cli.inode_config)
|
||||
for (auto & ic: proxy->cli->st_cli->inode_config)
|
||||
{
|
||||
if (ic.second.name == cfg["fs"].string_value())
|
||||
{
|
||||
@@ -245,9 +245,9 @@ void kv_fs_state_t::init(nfs_proxy_t *proxy, json11::Json cfg)
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
if (proxy->cli->st_cli.inode_config.find(fs_kv_inode) != proxy->cli->st_cli.inode_config.end())
|
||||
if (proxy->cli->st_cli->inode_config.find(fs_kv_inode) != proxy->cli->st_cli->inode_config.end())
|
||||
{
|
||||
auto & name = proxy->cli->st_cli.inode_config.at(fs_kv_inode).name;
|
||||
auto & name = proxy->cli->st_cli->inode_config.at(fs_kv_inode).name;
|
||||
if (pool_cfg.used_for_app != "fs:"+name)
|
||||
{
|
||||
fprintf(stderr, "Please mark pool as used for this file system with `vitastor-cli modify-pool --used-for-app fs:%s %s`\n",
|
||||
@@ -255,11 +255,11 @@ void kv_fs_state_t::init(nfs_proxy_t *proxy, json11::Json cfg)
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
auto img_it = proxy->cli->st_cli.inode_config.lower_bound(INODE_WITH_POOL(proxy->default_pool_id+1, 0));
|
||||
if (img_it != proxy->cli->st_cli.inode_config.begin())
|
||||
auto img_it = proxy->cli->st_cli->inode_config.lower_bound(INODE_WITH_POOL(proxy->default_pool_id+1, 0));
|
||||
if (img_it != proxy->cli->st_cli->inode_config.begin())
|
||||
{
|
||||
img_it--;
|
||||
if (img_it != proxy->cli->st_cli.inode_config.begin() && INODE_POOL(img_it->first) == proxy->default_pool_id)
|
||||
if (img_it != proxy->cli->st_cli->inode_config.begin() && INODE_POOL(img_it->first) == proxy->default_pool_id)
|
||||
{
|
||||
idgen[proxy->default_pool_id].min_id = INODE_NO_POOL(img_it->first) + 1;
|
||||
}
|
||||
|
||||
@@ -260,8 +260,8 @@ void kv_fs_defrag_t::handle_read()
|
||||
// Linear read all object headers, check which of them are still alive, move them away
|
||||
void kv_fs_state_t::defrag_volume(inode_t ino, bool no_rm, bool dry_run, std::function<void(int, uint64_t, uint64_t, uint64_t)> cb)
|
||||
{
|
||||
auto pool_it = proxy->cli->st_cli.pool_config.find(INODE_POOL(ino));
|
||||
if (pool_it == proxy->cli->st_cli.pool_config.end())
|
||||
auto pool_it = proxy->cli->st_cli->pool_config.find(INODE_POOL(ino));
|
||||
if (pool_it == proxy->cli->st_cli->pool_config.end())
|
||||
{
|
||||
fprintf(stderr, "Volume 0x%jx references a non-existing pool with ID %u, skipping\n", ino, INODE_POOL(ino));
|
||||
cb(0, 0, 0, 0);
|
||||
|
||||
+24
-24
@@ -451,21 +451,21 @@ void nfs_proxy_t::run_server(json11::Json cfg)
|
||||
|
||||
void nfs_proxy_t::watch_stats()
|
||||
{
|
||||
assert(cli->st_cli.on_start_watcher_hook == NULL);
|
||||
cli->st_cli.on_start_watcher_hook = [this](http_co_t *etcd_watch_ws)
|
||||
assert(cli->st_cli->on_start_watcher_hook == NULL);
|
||||
cli->st_cli->on_start_watcher_hook = [this](http_co_t *etcd_watch_ws)
|
||||
{
|
||||
cli->st_cli.etcd_txn_slow(json11::Json::object {
|
||||
cli->st_cli->etcd_txn_slow(json11::Json::object {
|
||||
{ "success", json11::Json::array {
|
||||
json11::Json::object {
|
||||
{ "request_range", json11::Json::object {
|
||||
{ "key", base64_encode(cli->st_cli.etcd_prefix+"/inode/stats/") },
|
||||
{ "range_end", base64_encode(cli->st_cli.etcd_prefix+"/inode/stats0") },
|
||||
{ "key", base64_encode(cli->st_cli->etcd_prefix+"/inode/stats/") },
|
||||
{ "range_end", base64_encode(cli->st_cli->etcd_prefix+"/inode/stats0") },
|
||||
} }
|
||||
},
|
||||
json11::Json::object {
|
||||
{ "request_range", json11::Json::object {
|
||||
{ "key", base64_encode(cli->st_cli.etcd_prefix+"/pool/stats/") },
|
||||
{ "range_end", base64_encode(cli->st_cli.etcd_prefix+"/pool/stats0") },
|
||||
{ "key", base64_encode(cli->st_cli->etcd_prefix+"/pool/stats/") },
|
||||
{ "range_end", base64_encode(cli->st_cli->etcd_prefix+"/pool/stats0") },
|
||||
} }
|
||||
},
|
||||
} },
|
||||
@@ -475,26 +475,26 @@ void nfs_proxy_t::watch_stats()
|
||||
{
|
||||
for (auto & item: rsp["response_range"]["kvs"].array_items())
|
||||
{
|
||||
etcd_kv_t kv = cli->st_cli.parse_etcd_kv(item);
|
||||
etcd_kv_t kv = cli->st_cli->parse_etcd_kv(item);
|
||||
parse_stats(kv);
|
||||
}
|
||||
}
|
||||
if (cli->st_cli.etcd_watch_ws)
|
||||
if (cli->st_cli->etcd_watch_ws)
|
||||
{
|
||||
auto watch_rev = res["header"]["revision"].uint64_value()+1;
|
||||
http_post_message(cli->st_cli.etcd_watch_ws, WS_TEXT, json11::Json(json11::Json::object {
|
||||
http_post_message(cli->st_cli->etcd_watch_ws, WS_TEXT, json11::Json(json11::Json::object {
|
||||
{ "create_request", json11::Json::object {
|
||||
{ "key", base64_encode(cli->st_cli.etcd_prefix+"/inode/stats/") },
|
||||
{ "range_end", base64_encode(cli->st_cli.etcd_prefix+"/inode/stats0") },
|
||||
{ "key", base64_encode(cli->st_cli->etcd_prefix+"/inode/stats/") },
|
||||
{ "range_end", base64_encode(cli->st_cli->etcd_prefix+"/inode/stats0") },
|
||||
{ "start_revision", watch_rev },
|
||||
{ "watch_id", ETCD_INODE_STATS_WATCH_ID },
|
||||
{ "progress_notify", true },
|
||||
} }
|
||||
}).dump());
|
||||
http_post_message(cli->st_cli.etcd_watch_ws, WS_TEXT, json11::Json(json11::Json::object {
|
||||
http_post_message(cli->st_cli->etcd_watch_ws, WS_TEXT, json11::Json(json11::Json::object {
|
||||
{ "create_request", json11::Json::object {
|
||||
{ "key", base64_encode(cli->st_cli.etcd_prefix+"/pool/stats/") },
|
||||
{ "range_end", base64_encode(cli->st_cli.etcd_prefix+"/pool/stats0") },
|
||||
{ "key", base64_encode(cli->st_cli->etcd_prefix+"/pool/stats/") },
|
||||
{ "range_end", base64_encode(cli->st_cli->etcd_prefix+"/pool/stats0") },
|
||||
{ "start_revision", watch_rev },
|
||||
{ "watch_id", ETCD_POOL_STATS_WATCH_ID },
|
||||
{ "progress_notify", true },
|
||||
@@ -503,7 +503,7 @@ void nfs_proxy_t::watch_stats()
|
||||
}
|
||||
});
|
||||
};
|
||||
cli->st_cli.on_change_hook = [this, old_hook = cli->st_cli.on_change_hook](std::map<std::string, etcd_kv_t> & changes)
|
||||
cli->st_cli->on_change_hook = [this, old_hook = cli->st_cli->on_change_hook](std::map<std::string, etcd_kv_t> & changes)
|
||||
{
|
||||
for (auto & p: changes)
|
||||
{
|
||||
@@ -515,12 +515,12 @@ void nfs_proxy_t::watch_stats()
|
||||
void nfs_proxy_t::parse_stats(etcd_kv_t & kv)
|
||||
{
|
||||
auto & key = kv.key;
|
||||
if (key.substr(0, cli->st_cli.etcd_prefix.length()+13) == cli->st_cli.etcd_prefix+"/inode/stats/")
|
||||
if (key.substr(0, cli->st_cli->etcd_prefix.length()+13) == cli->st_cli->etcd_prefix+"/inode/stats/")
|
||||
{
|
||||
pool_id_t pool_id = 0;
|
||||
inode_t inode_num = 0;
|
||||
char null_byte = 0;
|
||||
int scanned = sscanf(key.c_str() + cli->st_cli.etcd_prefix.length()+13, "%u/%ju%c", &pool_id, &inode_num, &null_byte);
|
||||
int scanned = sscanf(key.c_str() + cli->st_cli->etcd_prefix.length()+13, "%u/%ju%c", &pool_id, &inode_num, &null_byte);
|
||||
if (scanned != 2 || !pool_id || pool_id >= POOL_ID_MAX)
|
||||
{
|
||||
fprintf(stderr, "Bad etcd key %s, ignoring\n", key.c_str());
|
||||
@@ -530,11 +530,11 @@ void nfs_proxy_t::parse_stats(etcd_kv_t & kv)
|
||||
inode_stats[INODE_WITH_POOL(pool_id, inode_num)] = kv.value;
|
||||
}
|
||||
}
|
||||
else if (key.substr(0, cli->st_cli.etcd_prefix.length()+12) == cli->st_cli.etcd_prefix+"/pool/stats/")
|
||||
else if (key.substr(0, cli->st_cli->etcd_prefix.length()+12) == cli->st_cli->etcd_prefix+"/pool/stats/")
|
||||
{
|
||||
pool_id_t pool_id = 0;
|
||||
char null_byte = 0;
|
||||
int scanned = 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 (scanned != 1 || !pool_id || pool_id >= POOL_ID_MAX)
|
||||
{
|
||||
fprintf(stderr, "Bad etcd key %s, ignoring\n", key.c_str());
|
||||
@@ -550,21 +550,21 @@ void nfs_proxy_t::check_default_pool()
|
||||
{
|
||||
if (default_pool == "")
|
||||
{
|
||||
if (cli->st_cli.pool_config.size() == 1)
|
||||
if (cli->st_cli->pool_config.size() == 1)
|
||||
{
|
||||
auto pool_it = cli->st_cli.pool_config.begin();
|
||||
auto pool_it = cli->st_cli->pool_config.begin();
|
||||
default_pool_id = pool_it->first;
|
||||
default_pool = pool_it->second.name;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "There are %zu pools. Please select default pool with --pool option\n", cli->st_cli.pool_config.size());
|
||||
fprintf(stderr, "There are %zu pools. Please select default pool with --pool option\n", cli->st_cli->pool_config.size());
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto & p: cli->st_cli.pool_config)
|
||||
for (auto & p: cli->st_cli->pool_config)
|
||||
{
|
||||
if (p.second.name == default_pool)
|
||||
{
|
||||
|
||||
+2
-2
@@ -116,7 +116,7 @@ void osd_t::init_blockstore(std::function<void()> on_init)
|
||||
auto bs_cfg = json_to_string_map(this->config);
|
||||
this->bs = blockstore_i::create(bs_cfg, ringloop, tfd);
|
||||
// Pre-configure pool PG shards
|
||||
for (auto & pool_item: st_cli.pool_config)
|
||||
for (auto & pool_item: st_cli->pool_config)
|
||||
{
|
||||
auto st = bs->reshard_start(pool_item.first, pool_item.second.pg_count, pool_item.second.pg_stripe_size, 0);
|
||||
assert(!st);
|
||||
@@ -164,7 +164,7 @@ void osd_t::parse_config(bool init)
|
||||
auto bs_cfg = json_to_string_map(config);
|
||||
bs->parse_config(bs_cfg);
|
||||
}
|
||||
st_cli.parse_config(config);
|
||||
st_cli->parse_config(config);
|
||||
msgr.parse_config(config);
|
||||
if (init)
|
||||
{
|
||||
|
||||
+3
-3
@@ -152,7 +152,7 @@ class osd_t
|
||||
|
||||
// cluster state
|
||||
|
||||
etcd_state_client_t st_cli;
|
||||
std::unique_ptr<etcd_state_client_t> st_cli;
|
||||
osd_messenger_t msgr;
|
||||
int etcd_failed_attempts = 0;
|
||||
std::string etcd_lease_id;
|
||||
@@ -383,8 +383,8 @@ class osd_t
|
||||
|
||||
inline pg_num_t map_to_pg(object_id oid)
|
||||
{
|
||||
auto pool_it = st_cli.pool_config.find(INODE_POOL(oid.inode));
|
||||
if (pool_it == st_cli.pool_config.end())
|
||||
auto pool_it = st_cli->pool_config.find(INODE_POOL(oid.inode));
|
||||
if (pool_it == st_cli->pool_config.end())
|
||||
return 1;
|
||||
return (oid.stripe / pool_it->second.applied_pg_stripe_size) % pool_it->second.applied_pg_count + 1;
|
||||
}
|
||||
|
||||
+71
-70
@@ -16,7 +16,8 @@
|
||||
// Peer connection is lost -> Reload connection data -> Try to reconnect
|
||||
void osd_t::init_cluster()
|
||||
{
|
||||
if (!st_cli.address_count())
|
||||
st_cli = std::make_unique<etcd_state_client_t>();
|
||||
if (!st_cli->address_count())
|
||||
{
|
||||
init_blockstore(NULL);
|
||||
if (run_primary)
|
||||
@@ -30,7 +31,7 @@ void osd_t::init_cluster()
|
||||
parse_test_peer(pos < 0 ? peerstr : peerstr.substr(0, pos));
|
||||
peerstr = pos < 0 ? std::string("") : peerstr.substr(pos+1);
|
||||
}
|
||||
if (st_cli.peer_states.size() < 2)
|
||||
if (st_cli->peer_states.size() < 2)
|
||||
{
|
||||
throw std::runtime_error("run_primary requires at least 2 peers");
|
||||
}
|
||||
@@ -46,7 +47,7 @@ void osd_t::init_cluster()
|
||||
.target_set = { 1, 2, 3 },
|
||||
.cur_set = { 0, 0, 0 },
|
||||
};
|
||||
st_cli.pool_config[1] = (pool_config_t){
|
||||
st_cli->pool_config[1] = (pool_config_t){
|
||||
.exists = true,
|
||||
.id = 1,
|
||||
.name = "testpool",
|
||||
@@ -64,19 +65,19 @@ void osd_t::init_cluster()
|
||||
}
|
||||
else
|
||||
{
|
||||
st_cli.tfd = tfd;
|
||||
st_cli.log_level = log_level;
|
||||
st_cli.on_change_osd_state_hook = [this](osd_num_t peer_osd) { on_change_osd_state_hook(peer_osd); };
|
||||
st_cli.on_change_pool_config_hook = [this]() { on_change_pool_config_hook(); };
|
||||
st_cli.on_change_backfillfull_hook = [this](pool_id_t pool_id) { on_change_backfillfull_hook(pool_id); };
|
||||
st_cli.on_change_pg_history_hook = [this](pool_id_t pool_id, pg_num_t pg_num) { on_change_pg_history_hook(pool_id, pg_num); };
|
||||
st_cli.on_change_hook = [this](std::map<std::string, etcd_kv_t> & changes) { on_change_etcd_state_hook(changes); };
|
||||
st_cli.on_load_config_hook = [this](json11::Json::object & cfg) { on_load_config_hook(cfg); };
|
||||
st_cli.load_pgs_checks_hook = [this]() { return on_load_pgs_checks_hook(); };
|
||||
st_cli.on_load_pgs_hook = [this](bool success) { on_load_pgs_hook(success); };
|
||||
st_cli.on_reload_hook = [this]() { st_cli.load_global_config(); };
|
||||
st_cli->tfd = tfd;
|
||||
st_cli->log_level = log_level;
|
||||
st_cli->on_change_osd_state_hook = [this](osd_num_t peer_osd) { on_change_osd_state_hook(peer_osd); };
|
||||
st_cli->on_change_pool_config_hook = [this]() { on_change_pool_config_hook(); };
|
||||
st_cli->on_change_backfillfull_hook = [this](pool_id_t pool_id) { on_change_backfillfull_hook(pool_id); };
|
||||
st_cli->on_change_pg_history_hook = [this](pool_id_t pool_id, pg_num_t pg_num) { on_change_pg_history_hook(pool_id, pg_num); };
|
||||
st_cli->on_change_hook = [this](std::map<std::string, etcd_kv_t> & changes) { on_change_etcd_state_hook(changes); };
|
||||
st_cli->on_load_config_hook = [this](json11::Json::object & cfg) { on_load_config_hook(cfg); };
|
||||
st_cli->load_pgs_checks_hook = [this]() { return on_load_pgs_checks_hook(); };
|
||||
st_cli->on_load_pgs_hook = [this](bool success) { on_load_pgs_hook(success); };
|
||||
st_cli->on_reload_hook = [this]() { st_cli->load_global_config(); };
|
||||
peering_state = OSD_LOADING_PGS;
|
||||
st_cli.load_global_config();
|
||||
st_cli->load_global_config();
|
||||
}
|
||||
if (run_primary && autosync_interval > 0)
|
||||
{
|
||||
@@ -100,17 +101,17 @@ void osd_t::parse_test_peer(std::string peer)
|
||||
osd_num_t peer_osd = strtoull(osd_num_str.c_str(), NULL, 10);
|
||||
if (!peer_osd)
|
||||
throw new std::runtime_error("Could not parse OSD peer osd_num");
|
||||
else if (st_cli.peer_states.find(peer_osd) != st_cli.peer_states.end())
|
||||
else if (st_cli->peer_states.find(peer_osd) != st_cli->peer_states.end())
|
||||
throw std::runtime_error("Same osd number "+std::to_string(peer_osd)+" specified twice in peers");
|
||||
int port = strtoull(port_str.c_str(), NULL, 10);
|
||||
if (!port)
|
||||
throw new std::runtime_error("Could not parse OSD peer port");
|
||||
st_cli.peer_states[peer_osd] = json11::Json::object {
|
||||
st_cli->peer_states[peer_osd] = json11::Json::object {
|
||||
{ "state", "up" },
|
||||
{ "addresses", json11::Json::array { addr } },
|
||||
{ "port", port },
|
||||
};
|
||||
msgr.connect_peer(peer_osd, st_cli.peer_states[peer_osd]);
|
||||
msgr.connect_peer(peer_osd, st_cli->peer_states[peer_osd]);
|
||||
}
|
||||
|
||||
bool osd_t::check_peer_config(osd_client_t *cl, json11::Json conf)
|
||||
@@ -349,19 +350,19 @@ void osd_t::report_statistics()
|
||||
json11::Json::array txn = {
|
||||
json11::Json::object {
|
||||
{ "request_put", json11::Json::object {
|
||||
{ "key", base64_encode(st_cli.etcd_prefix+"/osd/stats/"+std::to_string(osd_num)) },
|
||||
{ "key", base64_encode(st_cli->etcd_prefix+"/osd/stats/"+std::to_string(osd_num)) },
|
||||
{ "value", base64_encode(get_statistics().dump()) },
|
||||
} },
|
||||
},
|
||||
json11::Json::object {
|
||||
{ "request_put", json11::Json::object {
|
||||
{ "key", base64_encode(st_cli.etcd_prefix+"/osd/space/"+std::to_string(osd_num)) },
|
||||
{ "key", base64_encode(st_cli->etcd_prefix+"/osd/space/"+std::to_string(osd_num)) },
|
||||
{ "value", base64_encode(json11::Json(inode_space).dump()) },
|
||||
} },
|
||||
},
|
||||
json11::Json::object {
|
||||
{ "request_put", json11::Json::object {
|
||||
{ "key", base64_encode(st_cli.etcd_prefix+"/osd/inodestats/"+std::to_string(osd_num)) },
|
||||
{ "key", base64_encode(st_cli->etcd_prefix+"/osd/inodestats/"+std::to_string(osd_num)) },
|
||||
{ "value", base64_encode(json11::Json(inode_ops).dump()) },
|
||||
} },
|
||||
},
|
||||
@@ -385,19 +386,19 @@ void osd_t::report_statistics()
|
||||
pg_stats["write_osd_set"] = pg.cur_set;
|
||||
txn.push_back(json11::Json::object {
|
||||
{ "request_put", json11::Json::object {
|
||||
{ "key", base64_encode(st_cli.etcd_prefix+"/pgstats/"+std::to_string(pg.pool_id)+"/"+std::to_string(pg.pg_num)) },
|
||||
{ "key", base64_encode(st_cli->etcd_prefix+"/pgstats/"+std::to_string(pg.pool_id)+"/"+std::to_string(pg.pg_num)) },
|
||||
{ "value", base64_encode(json11::Json(pg_stats).dump()) },
|
||||
} }
|
||||
});
|
||||
}
|
||||
st_cli.etcd_txn_slow(json11::Json::object { { "success", txn } }, [this](std::string err, json11::Json res)
|
||||
st_cli->etcd_txn_slow(json11::Json::object { { "success", txn } }, [this](std::string err, json11::Json res)
|
||||
{
|
||||
etcd_reporting_stats = false;
|
||||
if (err != "")
|
||||
{
|
||||
printf("[OSD %ju] Error reporting state to etcd: %s\n", this->osd_num, err.c_str());
|
||||
// Retry indefinitely
|
||||
tfd->set_timer(st_cli.etcd_slow_timeout, false, [this](int timer_id)
|
||||
tfd->set_timer(st_cli->etcd_slow_timeout, false, [this](int timer_id)
|
||||
{
|
||||
report_statistics();
|
||||
});
|
||||
@@ -412,13 +413,13 @@ void osd_t::report_statistics()
|
||||
|
||||
void osd_t::on_change_osd_state_hook(osd_num_t peer_osd)
|
||||
{
|
||||
if (st_cli.peer_states[peer_osd].is_null())
|
||||
if (st_cli->peer_states[peer_osd].is_null())
|
||||
{
|
||||
repeer_pgs(peer_osd);
|
||||
}
|
||||
else if (msgr.wanted_peers.find(peer_osd) != msgr.wanted_peers.end())
|
||||
{
|
||||
msgr.connect_peer(peer_osd, st_cli.peer_states[peer_osd]);
|
||||
msgr.connect_peer(peer_osd, st_cli->peer_states[peer_osd]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -434,8 +435,8 @@ void osd_t::apply_pg_locks_localize_only()
|
||||
{
|
||||
for (auto & pp: pgs)
|
||||
{
|
||||
auto pool_it = st_cli.pool_config.find(pp.first.pool_id);
|
||||
if (pool_it == st_cli.pool_config.end())
|
||||
auto pool_it = st_cli->pool_config.find(pp.first.pool_id);
|
||||
if (pool_it == st_cli->pool_config.end())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -464,19 +465,19 @@ void osd_t::on_change_backfillfull_hook(pool_id_t pool_id)
|
||||
|
||||
void osd_t::on_change_etcd_state_hook(std::map<std::string, etcd_kv_t> & changes)
|
||||
{
|
||||
if (changes.find(st_cli.etcd_prefix+"/config/global") != changes.end())
|
||||
if (changes.find(st_cli->etcd_prefix+"/config/global") != changes.end())
|
||||
{
|
||||
etcd_global_config = changes[st_cli.etcd_prefix+"/config/global"].value.object_items();
|
||||
etcd_global_config = changes[st_cli->etcd_prefix+"/config/global"].value.object_items();
|
||||
parse_config(false);
|
||||
}
|
||||
bool pools = changes.find(st_cli.etcd_prefix+"/config/pools") != changes.end();
|
||||
bool pools = changes.find(st_cli->etcd_prefix+"/config/pools") != changes.end();
|
||||
if (pools)
|
||||
{
|
||||
apply_no_inode_stats();
|
||||
}
|
||||
if (run_primary)
|
||||
{
|
||||
bool pgs = changes.find(st_cli.etcd_prefix+"/pg/config") != changes.end();
|
||||
bool pgs = changes.find(st_cli->etcd_prefix+"/pg/config") != changes.end();
|
||||
if (pools || pgs)
|
||||
{
|
||||
apply_pg_count();
|
||||
@@ -489,7 +490,7 @@ void osd_t::on_load_config_hook(json11::Json::object & global_config)
|
||||
{
|
||||
etcd_global_config = global_config;
|
||||
parse_config(true);
|
||||
st_cli.on_load_config_hook = [this](json11::Json::object & cfg) { on_reload_config_hook(cfg); };
|
||||
st_cli->on_load_config_hook = [this](json11::Json::object & cfg) { on_reload_config_hook(cfg); };
|
||||
etcd_global_config_loaded = true;
|
||||
init_blockstore([this]()
|
||||
{
|
||||
@@ -511,14 +512,14 @@ void osd_t::acquire_lease()
|
||||
// Apply no_inode_stats before the first statistics report
|
||||
apply_no_inode_stats();
|
||||
// Maximum lease TTL is (report interval) + retries * (timeout + repeat interval)
|
||||
st_cli.etcd_call("/lease/grant", json11::Json::object {
|
||||
{ "TTL", etcd_report_interval+(st_cli.max_etcd_attempts*(2*st_cli.etcd_quick_timeout)+999)/1000 }
|
||||
}, st_cli.etcd_quick_timeout, 0, 0, [this](std::string err, json11::Json data)
|
||||
st_cli->etcd_call("/lease/grant", json11::Json::object {
|
||||
{ "TTL", etcd_report_interval+(st_cli->max_etcd_attempts*(2*st_cli->etcd_quick_timeout)+999)/1000 }
|
||||
}, st_cli->etcd_quick_timeout, 0, 0, [this](std::string err, json11::Json data)
|
||||
{
|
||||
if (err != "" || data["ID"].string_value() == "")
|
||||
{
|
||||
printf("Error acquiring a lease from etcd: %s, retrying\n", err.c_str());
|
||||
tfd->set_timer(st_cli.etcd_quick_timeout, false, [this](int timer_id)
|
||||
tfd->set_timer(st_cli->etcd_quick_timeout, false, [this](int timer_id)
|
||||
{
|
||||
acquire_lease();
|
||||
});
|
||||
@@ -546,9 +547,9 @@ void osd_t::acquire_lease()
|
||||
// Do it first to allow "monitors" check it when moving PGs
|
||||
void osd_t::create_osd_state()
|
||||
{
|
||||
std::string state_key = base64_encode(st_cli.etcd_prefix+"/osd/state/"+std::to_string(osd_num));
|
||||
std::string state_key = base64_encode(st_cli->etcd_prefix+"/osd/state/"+std::to_string(osd_num));
|
||||
self_state = get_osd_state();
|
||||
st_cli.etcd_txn(json11::Json::object {
|
||||
st_cli->etcd_txn(json11::Json::object {
|
||||
// Check that the state key does not exist
|
||||
{ "compare", json11::Json::array {
|
||||
json11::Json::object {
|
||||
@@ -573,19 +574,19 @@ void osd_t::create_osd_state()
|
||||
} }
|
||||
},
|
||||
} },
|
||||
}, st_cli.etcd_quick_timeout, 0, 0, [this](std::string err, json11::Json data)
|
||||
}, st_cli->etcd_quick_timeout, 0, 0, [this](std::string err, json11::Json data)
|
||||
{
|
||||
if (err != "")
|
||||
{
|
||||
etcd_failed_attempts++;
|
||||
printf("Error creating OSD state key: %s\n", err.c_str());
|
||||
if (etcd_failed_attempts > st_cli.max_etcd_attempts)
|
||||
if (etcd_failed_attempts > st_cli->max_etcd_attempts)
|
||||
{
|
||||
// Die
|
||||
throw std::runtime_error("Cluster connection failed");
|
||||
}
|
||||
// Retry
|
||||
tfd->set_timer(st_cli.etcd_quick_timeout, false, [this](int timer_id)
|
||||
tfd->set_timer(st_cli->etcd_quick_timeout, false, [this](int timer_id)
|
||||
{
|
||||
create_osd_state();
|
||||
});
|
||||
@@ -594,7 +595,7 @@ void osd_t::create_osd_state()
|
||||
if (!data["succeeded"].bool_value())
|
||||
{
|
||||
// OSD is already up
|
||||
auto kv = st_cli.parse_etcd_kv(data["responses"][0]["response_range"]["kvs"][0]);
|
||||
auto kv = st_cli->parse_etcd_kv(data["responses"][0]["response_range"]["kvs"][0]);
|
||||
printf("Key %s already exists in etcd, OSD %ju is still up\n", kv.key.c_str(), this->osd_num);
|
||||
int64_t port = kv.value["port"].int64_value();
|
||||
for (auto & addr: kv.value["addresses"].array_items())
|
||||
@@ -606,7 +607,7 @@ void osd_t::create_osd_state()
|
||||
}
|
||||
if (run_primary)
|
||||
{
|
||||
st_cli.load_pgs();
|
||||
st_cli->load_pgs();
|
||||
}
|
||||
report_statistics();
|
||||
});
|
||||
@@ -615,9 +616,9 @@ void osd_t::create_osd_state()
|
||||
// Renew lease
|
||||
void osd_t::renew_lease(bool reload)
|
||||
{
|
||||
st_cli.etcd_call("/lease/keepalive", json11::Json::object {
|
||||
st_cli->etcd_call("/lease/keepalive", json11::Json::object {
|
||||
{ "ID", etcd_lease_id }
|
||||
}, st_cli.etcd_quick_timeout, 0, 0, [this, reload](std::string err, json11::Json data)
|
||||
}, st_cli->etcd_quick_timeout, 0, 0, [this, reload](std::string err, json11::Json data)
|
||||
{
|
||||
if (err == "" && data["result"]["TTL"].uint64_value() == 0)
|
||||
{
|
||||
@@ -629,14 +630,14 @@ void osd_t::renew_lease(bool reload)
|
||||
{
|
||||
etcd_failed_attempts++;
|
||||
printf("Error renewing etcd lease: %s\n", err.c_str());
|
||||
if (etcd_failed_attempts > st_cli.max_etcd_attempts)
|
||||
if (etcd_failed_attempts > st_cli->max_etcd_attempts)
|
||||
{
|
||||
// Die
|
||||
fprintf(stderr, "Cluster connection failed\n");
|
||||
force_stop(1);
|
||||
}
|
||||
// Retry
|
||||
tfd->set_timer(st_cli.etcd_quick_timeout, false, [this, reload](int timer_id)
|
||||
tfd->set_timer(st_cli->etcd_quick_timeout, false, [this, reload](int timer_id)
|
||||
{
|
||||
renew_lease(reload);
|
||||
});
|
||||
@@ -647,7 +648,7 @@ void osd_t::renew_lease(bool reload)
|
||||
// Reload PGs
|
||||
if (reload && run_primary)
|
||||
{
|
||||
st_cli.load_pgs();
|
||||
st_cli->load_pgs();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -657,9 +658,9 @@ void osd_t::force_stop(int exitcode)
|
||||
{
|
||||
if (etcd_lease_id != "")
|
||||
{
|
||||
st_cli.etcd_call("/kv/lease/revoke", json11::Json::object {
|
||||
st_cli->etcd_call("/kv/lease/revoke", json11::Json::object {
|
||||
{ "ID", etcd_lease_id }
|
||||
}, st_cli.etcd_quick_timeout, st_cli.max_etcd_attempts, 0, [this, exitcode](std::string err, json11::Json data)
|
||||
}, st_cli->etcd_quick_timeout, st_cli->max_etcd_attempts, 0, [this, exitcode](std::string err, json11::Json data)
|
||||
{
|
||||
if (err != "")
|
||||
{
|
||||
@@ -682,7 +683,7 @@ json11::Json osd_t::on_load_pgs_checks_hook()
|
||||
json11::Json::object {
|
||||
{ "target", "LEASE" },
|
||||
{ "lease", etcd_lease_id },
|
||||
{ "key", base64_encode(st_cli.etcd_prefix+"/osd/state/"+std::to_string(osd_num)) },
|
||||
{ "key", base64_encode(st_cli->etcd_prefix+"/osd/state/"+std::to_string(osd_num)) },
|
||||
}
|
||||
};
|
||||
return checks;
|
||||
@@ -714,7 +715,7 @@ void osd_t::apply_no_inode_stats()
|
||||
return;
|
||||
}
|
||||
std::vector<uint64_t> no_inode_stats;
|
||||
for (auto & pool_item: st_cli.pool_config)
|
||||
for (auto & pool_item: st_cli->pool_config)
|
||||
{
|
||||
if (!pool_item.second.used_for_app.empty())
|
||||
{
|
||||
@@ -726,7 +727,7 @@ void osd_t::apply_no_inode_stats()
|
||||
|
||||
void osd_t::apply_pg_count()
|
||||
{
|
||||
for (auto & pool_item: st_cli.pool_config)
|
||||
for (auto & pool_item: st_cli->pool_config)
|
||||
{
|
||||
auto & pool_cfg = pool_item.second;
|
||||
if (pool_cfg.real_pg_count == 0)
|
||||
@@ -802,8 +803,8 @@ void osd_t::reshard_continue()
|
||||
{
|
||||
again:
|
||||
auto pool_id = reshard_pools[0];
|
||||
auto pool_it = st_cli.pool_config.find(pool_id);
|
||||
if (pool_it == st_cli.pool_config.end() || !pool_it->second.reshard_state)
|
||||
auto pool_it = st_cli->pool_config.find(pool_id);
|
||||
if (pool_it == st_cli->pool_config.end() || !pool_it->second.reshard_state)
|
||||
{
|
||||
reshard_pools.erase(reshard_pools.begin());
|
||||
goto again;
|
||||
@@ -843,7 +844,7 @@ again:
|
||||
void osd_t::apply_pg_config()
|
||||
{
|
||||
bool all_applied = true;
|
||||
for (auto & pool_item: st_cli.pool_config)
|
||||
for (auto & pool_item: st_cli->pool_config)
|
||||
{
|
||||
auto & pool_cfg = pool_item.second;
|
||||
if (pool_cfg.reshard_state)
|
||||
@@ -993,7 +994,7 @@ void osd_t::apply_pg_config()
|
||||
{
|
||||
if (pg_osd != this->osd_num && msgr.osd_peers.find(pg_osd) == msgr.osd_peers.end())
|
||||
{
|
||||
msgr.connect_peer(pg_osd, st_cli.peer_states[pg_osd]);
|
||||
msgr.connect_peer(pg_osd, st_cli->peer_states[pg_osd]);
|
||||
}
|
||||
}
|
||||
start_pg_peering(pg);
|
||||
@@ -1018,7 +1019,7 @@ struct reporting_pg_t
|
||||
|
||||
void osd_t::report_pg_states()
|
||||
{
|
||||
if (etcd_reporting_pg_state || !this->pg_state_dirty.size() || !st_cli.address_count())
|
||||
if (etcd_reporting_pg_state || !this->pg_state_dirty.size() || !st_cli->address_count())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -1035,12 +1036,12 @@ void osd_t::report_pg_states()
|
||||
}
|
||||
auto & pg = pg_it->second;
|
||||
reporting_pgs.push_back((reporting_pg_t){ *it, pg.history_changed });
|
||||
std::string state_key_base64 = base64_encode(st_cli.etcd_prefix+"/pg/state/"+std::to_string(pg.pool_id)+"/"+std::to_string(pg.pg_num));
|
||||
std::string state_key_base64 = base64_encode(st_cli->etcd_prefix+"/pg/state/"+std::to_string(pg.pool_id)+"/"+std::to_string(pg.pg_num));
|
||||
bool pg_state_exists = false;
|
||||
if (pg.state != PG_STARTING)
|
||||
{
|
||||
auto pool_it = st_cli.pool_config.find(pg.pool_id);
|
||||
if (pool_it != st_cli.pool_config.end())
|
||||
auto pool_it = st_cli->pool_config.find(pg.pool_id);
|
||||
if (pool_it != st_cli->pool_config.end())
|
||||
{
|
||||
auto pg_it = pool_it->second.pg_config.find(pg.pg_num);
|
||||
if (pg_it != pool_it->second.pg_config.end() &&
|
||||
@@ -1054,7 +1055,7 @@ void osd_t::report_pg_states()
|
||||
{ "target", "MOD" },
|
||||
{ "key", state_key_base64 },
|
||||
{ "result", "LESS" },
|
||||
{ "mod_revision", st_cli.etcd_watch_revision_pg+1 },
|
||||
{ "mod_revision", st_cli->etcd_watch_revision_pg+1 },
|
||||
});
|
||||
continue;
|
||||
}
|
||||
@@ -1113,7 +1114,7 @@ void osd_t::report_pg_states()
|
||||
{
|
||||
// Prevent race conditions (for the case when the monitor is updating this key at the same time)
|
||||
pg.history_changed = false;
|
||||
std::string history_key = base64_encode(st_cli.etcd_prefix+"/pg/history/"+std::to_string(pg.pool_id)+"/"+std::to_string(pg.pg_num));
|
||||
std::string history_key = base64_encode(st_cli->etcd_prefix+"/pg/history/"+std::to_string(pg.pool_id)+"/"+std::to_string(pg.pg_num));
|
||||
json11::Json::object history_value = {
|
||||
{ "epoch", pg.epoch },
|
||||
{ "all_peers", pg.all_peers },
|
||||
@@ -1125,7 +1126,7 @@ void osd_t::report_pg_states()
|
||||
{ "target", "MOD" },
|
||||
{ "key", history_key },
|
||||
{ "result", "LESS" },
|
||||
{ "mod_revision", st_cli.etcd_watch_revision_pg+1 },
|
||||
{ "mod_revision", st_cli->etcd_watch_revision_pg+1 },
|
||||
});
|
||||
success.push_back(json11::Json::object {
|
||||
{ "request_put", json11::Json::object {
|
||||
@@ -1143,9 +1144,9 @@ void osd_t::report_pg_states()
|
||||
}
|
||||
pg_state_dirty.clear();
|
||||
etcd_reporting_pg_state = true;
|
||||
st_cli.etcd_txn(json11::Json::object {
|
||||
st_cli->etcd_txn(json11::Json::object {
|
||||
{ "compare", checks }, { "success", success }, { "failure", failure }
|
||||
}, st_cli.etcd_quick_timeout, 0, 0, [this, reporting_pgs](std::string err, json11::Json data)
|
||||
}, st_cli->etcd_quick_timeout, 0, 0, [this, reporting_pgs](std::string err, json11::Json data)
|
||||
{
|
||||
etcd_reporting_pg_state = false;
|
||||
if (!data["succeeded"].bool_value())
|
||||
@@ -1173,13 +1174,13 @@ void osd_t::report_pg_states()
|
||||
{
|
||||
if (res["response_range"]["kvs"].array_items().size())
|
||||
{
|
||||
auto kv = st_cli.parse_etcd_kv(res["response_range"]["kvs"][0]);
|
||||
if (kv.key.substr(0, st_cli.etcd_prefix.length()+10) == st_cli.etcd_prefix+"/pg/state/")
|
||||
auto kv = st_cli->parse_etcd_kv(res["response_range"]["kvs"][0]);
|
||||
if (kv.key.substr(0, st_cli->etcd_prefix.length()+10) == st_cli->etcd_prefix+"/pg/state/")
|
||||
{
|
||||
pool_id_t pool_id = 0;
|
||||
pg_num_t pg_num = 0;
|
||||
char null_byte = 0;
|
||||
int scanned = 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 (scanned == 2)
|
||||
{
|
||||
auto pg_it = pgs.find({ .pool_id = pool_id, .pg_num = pg_num });
|
||||
|
||||
@@ -243,8 +243,8 @@ bool osd_t::pick_next_recovery(osd_recovery_op_t &op)
|
||||
auto & src = recovery_last_degraded ? pg_it->second.degraded_objects : pg_it->second.misplaced_objects;
|
||||
if ((pg_it->second.state & mask) == check && src.size() > 0)
|
||||
{
|
||||
auto pool_it = st_cli.pool_config.find(pg_it->first.pool_id);
|
||||
if (pool_it != st_cli.pool_config.end() && pool_it->second.backfillfull)
|
||||
auto pool_it = st_cli->pool_config.find(pg_it->first.pool_id);
|
||||
if (pool_it != st_cli->pool_config.end() && pool_it->second.backfillfull)
|
||||
{
|
||||
// Skip the pool
|
||||
recovery_last_pg.pool_id++;
|
||||
|
||||
@@ -208,8 +208,8 @@ void osd_t::start_pg_peering(pg_t & pg)
|
||||
msgr.osd_peers.find(pg_osd) == msgr.osd_peers.end())
|
||||
{
|
||||
if (msgr.wanted_peers.find(pg_osd) == msgr.wanted_peers.end())
|
||||
msgr.connect_peer(pg_osd, st_cli.peer_states[pg_osd]);
|
||||
if (!st_cli.peer_states[pg_osd].is_null())
|
||||
msgr.connect_peer(pg_osd, st_cli->peer_states[pg_osd]);
|
||||
if (!st_cli->peer_states[pg_osd].is_null())
|
||||
all_connected = false;
|
||||
}
|
||||
}
|
||||
@@ -525,7 +525,7 @@ void osd_t::relock_pg(pg_t & pg)
|
||||
|
||||
void osd_t::submit_list_subop(osd_num_t role_osd, pg_peering_state_t *ps)
|
||||
{
|
||||
auto & pool_cfg = st_cli.pool_config.at(ps->pool_id);
|
||||
auto & pool_cfg = st_cli->pool_config.at(ps->pool_id);
|
||||
if (role_osd == this->osd_num)
|
||||
{
|
||||
// Self
|
||||
@@ -706,7 +706,7 @@ void osd_t::report_pg_state(pg_t & pg)
|
||||
std::sort(pg.all_peers.begin(), pg.all_peers.end());
|
||||
pg.cur_peers = pg.target_set;
|
||||
// Change pg_config at the same time, otherwise our PG reconciling loop may try to apply the old metadata
|
||||
auto & pg_cfg = st_cli.pool_config[pg.pool_id].pg_config[pg.pg_num];
|
||||
auto & pg_cfg = st_cli->pool_config[pg.pool_id].pg_config[pg.pg_num];
|
||||
pg_cfg.target_history = pg.target_history;
|
||||
pg_cfg.all_peers = pg.all_peers;
|
||||
}
|
||||
@@ -748,7 +748,7 @@ void osd_t::report_pg_state(pg_t & pg)
|
||||
pg.cur_peers.push_back(pg_osd);
|
||||
}
|
||||
}
|
||||
auto & pg_cfg = st_cli.pool_config[pg.pool_id].pg_config[pg.pg_num];
|
||||
auto & pg_cfg = st_cli->pool_config[pg.pool_id].pg_config[pg.pg_num];
|
||||
pg_cfg.target_history = pg.target_history;
|
||||
pg_cfg.all_peers = pg.all_peers;
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@ bool osd_t::prepare_primary_rw(osd_op_t *cur_op)
|
||||
// K = (pg_size-parity_chunks) in case of EC/XOR, or 1 for replicated pools
|
||||
pool_id_t pool_id = INODE_POOL(cur_op->req.rw.inode);
|
||||
// Note: We read pool config here, so we must NOT change it when PGs are active
|
||||
auto pool_cfg_it = st_cli.pool_config.find(pool_id);
|
||||
if (pool_cfg_it == st_cli.pool_config.end())
|
||||
auto pool_cfg_it = st_cli->pool_config.find(pool_id);
|
||||
if (pool_cfg_it == st_cli->pool_config.end())
|
||||
{
|
||||
// Pool config is not loaded yet
|
||||
finish_op(cur_op, -EPIPE);
|
||||
@@ -78,7 +78,7 @@ bool osd_t::prepare_primary_rw(osd_op_t *cur_op)
|
||||
{
|
||||
// Chained read
|
||||
// FIXME: Introduce an explicit opcode for chained reads
|
||||
auto inode_it = st_cli.inode_config.find(cur_op->req.rw.inode);
|
||||
auto inode_it = st_cli->inode_config.find(cur_op->req.rw.inode);
|
||||
if (inode_it->second.mod_revision != cur_op->req.rw.meta_revision)
|
||||
{
|
||||
// Client view of the metadata differs from OSD's view
|
||||
@@ -87,14 +87,14 @@ bool osd_t::prepare_primary_rw(osd_op_t *cur_op)
|
||||
return false;
|
||||
}
|
||||
// Find parents from the same pool. Optimized reads only work within pools
|
||||
while (inode_it != st_cli.inode_config.end() &&
|
||||
while (inode_it != st_cli->inode_config.end() &&
|
||||
inode_it->second.parent_id &&
|
||||
INODE_POOL(inode_it->second.parent_id) == pool_cfg.id)
|
||||
{
|
||||
// Check for loops - FIXME check it in etcd_state_client
|
||||
if (inode_it->second.parent_id == cur_op->req.rw.inode ||
|
||||
inode_it->second.parent_id == inode_it->second.num ||
|
||||
chain_size > st_cli.inode_config.size())
|
||||
chain_size > st_cli->inode_config.size())
|
||||
{
|
||||
printf("Inode %ju from pool %u has a parent_id loop, returning EINVAL in response to read\n",
|
||||
INODE_NO_POOL(cur_op->req.rw.inode), INODE_POOL(cur_op->req.rw.inode));
|
||||
@@ -102,7 +102,7 @@ bool osd_t::prepare_primary_rw(osd_op_t *cur_op)
|
||||
return false;
|
||||
}
|
||||
chain_size++;
|
||||
inode_it = st_cli.inode_config.find(inode_it->second.parent_id);
|
||||
inode_it = st_cli->inode_config.find(inode_it->second.parent_id);
|
||||
}
|
||||
if (chain_size)
|
||||
{
|
||||
@@ -162,15 +162,15 @@ bool osd_t::prepare_primary_rw(osd_op_t *cur_op)
|
||||
op_data->read_chain[chain_num] = cur_op->req.rw.inode;
|
||||
op_data->chain_states[chain_num] = NULL;
|
||||
chain_num++;
|
||||
auto inode_it = st_cli.inode_config.find(cur_op->req.rw.inode);
|
||||
while (inode_it != st_cli.inode_config.end() && inode_it->second.parent_id &&
|
||||
auto inode_it = st_cli->inode_config.find(cur_op->req.rw.inode);
|
||||
while (inode_it != st_cli->inode_config.end() && inode_it->second.parent_id &&
|
||||
INODE_POOL(inode_it->second.parent_id) == pool_cfg.id &&
|
||||
// Check for loops
|
||||
inode_it->second.parent_id != cur_op->req.rw.inode)
|
||||
{
|
||||
op_data->read_chain[chain_num] = inode_it->second.parent_id;
|
||||
op_data->chain_states[chain_num] = NULL;
|
||||
inode_it = st_cli.inode_config.find(inode_it->second.parent_id);
|
||||
inode_it = st_cli->inode_config.find(inode_it->second.parent_id);
|
||||
chain_num++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,14 +153,14 @@ static void add_primary_list(btree::btree_map<object_id, pg_osd_set_state_t*> &
|
||||
|
||||
void osd_t::continue_primary_list(osd_op_t *cur_op)
|
||||
{
|
||||
auto pool_cfg_it = st_cli.pool_config.find(INODE_POOL(cur_op->req.sec_list.min_inode));
|
||||
auto pool_cfg_it = st_cli->pool_config.find(INODE_POOL(cur_op->req.sec_list.min_inode));
|
||||
// Validate the request
|
||||
if (!cur_op->req.sec_list.list_pg ||
|
||||
!INODE_POOL(cur_op->req.sec_list.min_inode) ||
|
||||
INODE_NO_POOL(cur_op->req.sec_list.min_inode) != INODE_NO_POOL(cur_op->req.sec_list.max_inode) ||
|
||||
INODE_POOL(cur_op->req.sec_list.max_inode) != INODE_POOL(cur_op->req.sec_list.min_inode) ||
|
||||
cur_op->req.sec_list.stable_limit ||
|
||||
pool_cfg_it == st_cli.pool_config.end() ||
|
||||
pool_cfg_it == st_cli->pool_config.end() ||
|
||||
(cur_op->req.sec_list.pg_stripe_size != 0 && cur_op->req.sec_list.pg_stripe_size != pool_cfg_it->second.pg_stripe_size) ||
|
||||
(cur_op->req.sec_list.pg_count != 0 && cur_op->req.sec_list.pg_count != pool_cfg_it->second.real_pg_count))
|
||||
{
|
||||
|
||||
@@ -431,9 +431,9 @@ void osd_t::on_change_pg_history_hook(pool_id_t pool_id, pg_num_t pg_num)
|
||||
}
|
||||
auto & pg = pg_it->second;
|
||||
if (pg.epoch > pg.reported_epoch &&
|
||||
st_cli.pool_config[pool_id].pg_config[pg_num].epoch >= pg.epoch)
|
||||
st_cli->pool_config[pool_id].pg_config[pg_num].epoch >= pg.epoch)
|
||||
{
|
||||
pg.reported_epoch = st_cli.pool_config[pool_id].pg_config[pg_num].epoch;
|
||||
pg.reported_epoch = st_cli->pool_config[pool_id].pg_config[pg_num].epoch;
|
||||
std::vector<object_id> resume_oids;
|
||||
for (auto & op: pg.write_queue)
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ void osd_t::scrub_list(pool_pg_num_t pg_id, osd_num_t role_osd, object_id min_oi
|
||||
{
|
||||
pool_id_t pool_id = pg_id.pool_id;
|
||||
pg_num_t pg_num = pg_id.pg_num;
|
||||
auto & pool_cfg = st_cli.pool_config.at(pool_id);
|
||||
auto & pool_cfg = st_cli->pool_config.at(pool_id);
|
||||
assert(!scrub_list_op);
|
||||
if (role_osd == this->osd_num)
|
||||
{
|
||||
@@ -327,7 +327,7 @@ void osd_t::plan_scrub(pg_t & pg, bool report_state)
|
||||
{
|
||||
timespec tv_now;
|
||||
clock_gettime(CLOCK_REALTIME, &tv_now);
|
||||
auto & pool_cfg = st_cli.pool_config.at(pg.pool_id);
|
||||
auto & pool_cfg = st_cli->pool_config.at(pg.pool_id);
|
||||
auto interval = pool_cfg.scrub_interval ? pool_cfg.scrub_interval : global_scrub_interval;
|
||||
if (pg.next_scrub != tv_now.tv_sec + interval)
|
||||
{
|
||||
|
||||
@@ -82,8 +82,8 @@ void osd_t::exec_secondary(osd_op_t *op)
|
||||
bool osd_t::sec_check_pg_lock(osd_num_t primary_osd, const object_id &oid, uint32_t flags)
|
||||
{
|
||||
pool_id_t pool_id = INODE_POOL(oid.inode);
|
||||
auto pool_cfg_it = st_cli.pool_config.find(pool_id);
|
||||
if (pool_cfg_it == st_cli.pool_config.end())
|
||||
auto pool_cfg_it = st_cli->pool_config.find(pool_id);
|
||||
if (pool_cfg_it == st_cli->pool_config.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -286,8 +286,8 @@ void osd_t::exec_sec_lock(osd_op_t *cur_op)
|
||||
return;
|
||||
}
|
||||
auto ppg = (pool_pg_num_t){ .pool_id = (pool_id_t)cur_op->req.sec_lock.pool_id, .pg_num = (pg_num_t)cur_op->req.sec_lock.pg_num };
|
||||
auto pool_cfg_it = st_cli.pool_config.find(ppg.pool_id);
|
||||
if (pool_cfg_it == st_cli.pool_config.end() ||
|
||||
auto pool_cfg_it = st_cli->pool_config.find(ppg.pool_id);
|
||||
if (pool_cfg_it == st_cli->pool_config.end() ||
|
||||
pool_cfg_it->second.real_pg_count < cur_op->req.sec_lock.pg_num)
|
||||
{
|
||||
finish_op(cur_op, -ENOENT);
|
||||
@@ -354,7 +354,7 @@ void osd_t::exec_show_config(osd_op_t *cur_op)
|
||||
{ "readonly", readonly },
|
||||
{ "immediate_commit", (immediate_commit == IMMEDIATE_ALL ? "all" :
|
||||
(immediate_commit == IMMEDIATE_SMALL ? "small" : "none")) },
|
||||
{ "lease_timeout", etcd_report_interval+(st_cli.max_etcd_attempts*(2*st_cli.etcd_quick_timeout)+999)/1000 },
|
||||
{ "lease_timeout", etcd_report_interval+(st_cli->max_etcd_attempts*(2*st_cli->etcd_quick_timeout)+999)/1000 },
|
||||
{ "features", json11::Json::object{ { "pg_locks", true } } },
|
||||
};
|
||||
#ifdef WITH_RDMA
|
||||
|
||||
@@ -17,7 +17,7 @@ public:
|
||||
|
||||
void configure_single_pg_pool(cluster_client_t *cli)
|
||||
{
|
||||
cli->st_cli.parse_state((etcd_kv_t){
|
||||
cli->st_cli->parse_state((etcd_kv_t){
|
||||
.key = "/config/pools",
|
||||
.value = json11::Json::object {
|
||||
{ "1", json11::Json::object {
|
||||
@@ -30,7 +30,7 @@ void configure_single_pg_pool(cluster_client_t *cli)
|
||||
} }
|
||||
},
|
||||
});
|
||||
cli->st_cli.parse_state((etcd_kv_t){
|
||||
cli->st_cli->parse_state((etcd_kv_t){
|
||||
.key = "/pg/config",
|
||||
.value = json11::Json::object {
|
||||
{ "items", json11::Json::object {
|
||||
@@ -43,7 +43,7 @@ void configure_single_pg_pool(cluster_client_t *cli)
|
||||
} }
|
||||
},
|
||||
});
|
||||
cli->st_cli.parse_state((etcd_kv_t){
|
||||
cli->st_cli->parse_state((etcd_kv_t){
|
||||
.key = "/pg/state/1/1",
|
||||
.value = json11::Json::object {
|
||||
{ "peers", json11::Json::array { 1, 2 } },
|
||||
@@ -51,8 +51,8 @@ void configure_single_pg_pool(cluster_client_t *cli)
|
||||
{ "state", json11::Json::array { "active" } },
|
||||
},
|
||||
});
|
||||
cli->st_cli.on_load_pgs_hook(true);
|
||||
cli->st_cli.on_change_pool_config_hook();
|
||||
cli->st_cli->on_load_pgs_hook(true);
|
||||
cli->st_cli->on_change_pool_config_hook();
|
||||
}
|
||||
|
||||
int *test_write(cluster_client_t *cli, uint64_t offset, uint64_t len, uint8_t c, std::function<void()> cb = NULL, bool instant = false)
|
||||
|
||||
Reference in New Issue
Block a user