Fix possible FPE in osd_primary

This commit is contained in:
Vitaliy Filippov
2026-01-23 02:11:16 +03:00
parent 73f9c7293f
commit 8380d4c6a6
+9 -1
View File
@@ -35,7 +35,15 @@ bool osd_t::prepare_primary_rw(osd_op_t *cur_op)
// oid.stripe = starting offset of the parity stripe
.stripe = (cur_op->req.rw.offset/pg_block_size)*pg_block_size,
};
pg_num_t pg_num = (oid.stripe/pool_cfg.pg_stripe_size) % pg_counts[pool_id] + 1; // like map_to_pg()
// FIXME: pg_counts should be stored in pool_config, not in a separate map
auto pg_count = pg_counts[pool_id];
if (!pg_count)
{
// Pool config is not loaded yet
finish_op(cur_op, -EPIPE);
return false;
}
pg_num_t pg_num = (oid.stripe/pool_cfg.pg_stripe_size) % pg_count + 1; // like map_to_pg()
auto pg_it = pgs.find({ .pool_id = pool_id, .pg_num = pg_num });
if (pg_it == pgs.end() || pg_it->second.state == PG_OFFLINE)
{