mon: fix divide by zero when pg_num adjusted and no osds

Fixes: #9052
Backport: firefly, dumpling
Signed-off-by: Sage Weil <sage@redhat.com>
This commit is contained in:
Sage Weil 2014-08-13 13:31:10 -07:00
parent c5687b1310
commit 239401db7b

View File

@ -3592,7 +3592,7 @@ int OSDMonitor::prepare_command_pool_set(map<string,cmd_vartype> &cmdmap,
ss << "splits in cache pools must be followed by scrubs and leave sufficient free space to avoid overfilling. use --yes-i-really-mean-it to force.";
return -EPERM;
}
int expected_osds = MIN(p.get_pg_num(), osdmap.get_num_osds());
int expected_osds = MAX(1, MIN(p.get_pg_num(), osdmap.get_num_osds()));
int64_t new_pgs = n - p.get_pg_num();
int64_t pgs_per_osd = new_pgs / expected_osds;
if (pgs_per_osd > g_conf->mon_osd_max_split_count) {