forked from vitalif/vitastor
Shuffle PGs for better data device utilisation
parent
a48e2bbf18
commit
75a6a556b5
|
@ -104,6 +104,17 @@ async function optimize_initial({ osd_tree, pg_count, pg_size = 3, pg_minsize =
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function shuffle(array)
|
||||||
|
{
|
||||||
|
for (let i = array.length - 1, j, x; i > 0; i--)
|
||||||
|
{
|
||||||
|
j = Math.floor(Math.random() * (i + 1));
|
||||||
|
x = array[i];
|
||||||
|
array[i] = array[j];
|
||||||
|
array[j] = x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function make_int_pgs(weights, pg_count)
|
function make_int_pgs(weights, pg_count)
|
||||||
{
|
{
|
||||||
const total_weight = Object.values(weights).reduce((a, c) => Number(a) + Number(c), 0);
|
const total_weight = Object.values(weights).reduce((a, c) => Number(a) + Number(c), 0);
|
||||||
|
@ -120,6 +131,7 @@ function make_int_pgs(weights, pg_count)
|
||||||
weight_left -= weights[pg_name];
|
weight_left -= weights[pg_name];
|
||||||
pg_left -= n;
|
pg_left -= n;
|
||||||
}
|
}
|
||||||
|
shuffle(int_pgs);
|
||||||
return int_pgs;
|
return int_pgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
36
mon/mon.js
36
mon/mon.js
|
@ -848,7 +848,7 @@ class Mon
|
||||||
{
|
{
|
||||||
// Take configuration and state, check it against the stored configuration hash
|
// Take configuration and state, check it against the stored configuration hash
|
||||||
// Recalculate PGs and save them to etcd if the configuration is changed
|
// Recalculate PGs and save them to etcd if the configuration is changed
|
||||||
// FIXME: Also do not change anything if the distribution is good enough and no PGs are degraded
|
// FIXME: Do not change anything if the distribution is good and random enough and no PGs are degraded
|
||||||
const { up_osds, levels, osd_tree } = this.get_osd_tree();
|
const { up_osds, levels, osd_tree } = this.get_osd_tree();
|
||||||
const tree_cfg = {
|
const tree_cfg = {
|
||||||
osd_tree,
|
osd_tree,
|
||||||
|
@ -907,7 +907,14 @@ class Mon
|
||||||
prev_pgs[pg-1] = this.state.history.last_clean_pgs.items[pool_id][pg].osd_set;
|
prev_pgs[pg-1] = this.state.history.last_clean_pgs.items[pool_id][pg].osd_set;
|
||||||
}
|
}
|
||||||
prev_pgs = JSON.parse(JSON.stringify(prev_pgs.length ? prev_pgs : real_prev_pgs));
|
prev_pgs = JSON.parse(JSON.stringify(prev_pgs.length ? prev_pgs : real_prev_pgs));
|
||||||
const old_pg_count = prev_pgs.length;
|
const old_pg_count = real_prev_pgs.length;
|
||||||
|
const optimize_cfg = {
|
||||||
|
osd_tree: pool_tree,
|
||||||
|
pg_count: pool_cfg.pg_count,
|
||||||
|
pg_size: pool_cfg.pg_size,
|
||||||
|
pg_minsize: pool_cfg.pg_minsize,
|
||||||
|
max_combinations: pool_cfg.max_osd_combinations,
|
||||||
|
};
|
||||||
let optimize_result;
|
let optimize_result;
|
||||||
if (old_pg_count > 0)
|
if (old_pg_count > 0)
|
||||||
{
|
{
|
||||||
|
@ -934,24 +941,23 @@ class Mon
|
||||||
pg.pop();
|
pg.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
optimize_result = await LPOptimizer.optimize_change({
|
if (!this.state.config.pgs.hash)
|
||||||
prev_pgs,
|
{
|
||||||
osd_tree: pool_tree,
|
// Re-shuffle PGs
|
||||||
pg_size: pool_cfg.pg_size,
|
optimize_result = await LPOptimizer.optimize_initial(optimize_cfg);
|
||||||
pg_minsize: pool_cfg.pg_minsize,
|
|
||||||
max_combinations: pool_cfg.max_osd_combinations,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
optimize_result = await LPOptimizer.optimize_initial({
|
optimize_result = await LPOptimizer.optimize_change({
|
||||||
osd_tree: pool_tree,
|
prev_pgs,
|
||||||
pg_count: pool_cfg.pg_count,
|
...optimize_cfg,
|
||||||
pg_size: pool_cfg.pg_size,
|
|
||||||
pg_minsize: pool_cfg.pg_minsize,
|
|
||||||
max_combinations: pool_cfg.max_osd_combinations,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
optimize_result = await LPOptimizer.optimize_initial(optimize_cfg);
|
||||||
|
}
|
||||||
if (old_pg_count != optimize_result.int_pgs.length)
|
if (old_pg_count != optimize_result.int_pgs.length)
|
||||||
{
|
{
|
||||||
console.log(
|
console.log(
|
||||||
|
|
Loading…
Reference in New Issue