Fix online PG count change bugs

Vitaliy Filippov 2021-02-25 20:36:37 +03:00
parent 69c87009e9
commit 2d73b19a6c
3 changed files with 4 additions and 4 deletions

View File

@ -8,7 +8,7 @@ module.exports = {
function scale_pg_count(prev_pgs, prev_pg_history, new_pg_history, new_pg_count) function scale_pg_count(prev_pgs, prev_pg_history, new_pg_history, new_pg_count)
{ {
const old_pg_count = prev_pgs.length; const old_pg_count = prev_pgs.length;
// Add all possibly intersecting PGs into the history of new PGs // Add all possibly intersecting PGs to the history of new PGs
if (!(new_pg_count % old_pg_count)) if (!(new_pg_count % old_pg_count))
{ {
// New PG count is a multiple of the old PG count // New PG count is a multiple of the old PG count
@ -16,7 +16,7 @@ function scale_pg_count(prev_pgs, prev_pg_history, new_pg_history, new_pg_count)
for (let i = 0; i < new_pg_count; i++) for (let i = 0; i < new_pg_count; i++)
{ {
const old_i = Math.floor(new_pg_count / mul); const old_i = Math.floor(new_pg_count / mul);
new_pg_history[i] = JSON.parse(JSON.stringify(prev_pg_history[1+old_i])); new_pg_history[i] = prev_pg_history[old_i] ? JSON.parse(JSON.stringify(prev_pg_history[old_i])) : undefined;
} }
} }
else if (!(old_pg_count % new_pg_count)) else if (!(old_pg_count % new_pg_count))

View File

@ -840,7 +840,7 @@ class Mon
this.save_new_pgs_txn(etcd_request, pool_id, up_osds, prev_pgs, optimize_result.int_pgs, pg_history); this.save_new_pgs_txn(etcd_request, pool_id, up_osds, prev_pgs, optimize_result.int_pgs, pg_history);
} }
this.state.config.pgs.hash = tree_hash; this.state.config.pgs.hash = tree_hash;
await this.save_pg_config(); await this.save_pg_config(etcd_request);
} }
else else
{ {

View File

@ -802,11 +802,11 @@ void osd_t::report_pg_states()
if (pg_it->second.state == PG_OFFLINE) if (pg_it->second.state == PG_OFFLINE)
{ {
// Remove offline PGs after reporting their state // Remove offline PGs after reporting their state
this->pgs.erase(pg_it);
if (pg_it->second.scheme == POOL_SCHEME_JERASURE) if (pg_it->second.scheme == POOL_SCHEME_JERASURE)
{ {
use_jerasure(pg_it->second.pg_size, pg_it->second.pg_size-pg_it->second.parity_chunks, false); use_jerasure(pg_it->second.pg_size, pg_it->second.pg_size-pg_it->second.parity_chunks, false);
} }
this->pgs.erase(pg_it);
} }
} }
} }