From 6561d4e040dfa85723e71ac9bad31d65119b3071 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Fri, 30 Oct 2020 01:02:32 +0300 Subject: [PATCH] Validate pool ID before executing the operation Reply -EPIPE for non-existing pools because we assume that it means that pool config isn't loaded yet. Previously OSD crashed on such operations --- osd_primary.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/osd_primary.cpp b/osd_primary.cpp index 381eed1e..b4280b2f 100644 --- a/osd_primary.cpp +++ b/osd_primary.cpp @@ -18,7 +18,14 @@ bool osd_t::prepare_primary_rw(osd_op_t *cur_op) // Our EC scheme stores data in fixed chunks equal to (K*block size) // K = pg_minsize in case of EC/XOR, or 1 for replicated pools pool_id_t pool_id = INODE_POOL(cur_op->req.rw.inode); - auto & pool_cfg = st_cli.pool_config[pool_id]; + 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); + return false; + } + auto & pool_cfg = pool_cfg_it->second; uint64_t pg_block_size = bs_block_size * (pool_cfg.scheme == POOL_SCHEME_REPLICATED ? 1 : pool_cfg.pg_minsize); object_id oid = { .inode = cur_op->req.rw.inode,