From f81d2b0eaa473ccfc787663b143959d0babf8b05 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 13 Aug 2014 13:15:36 -0700 Subject: [PATCH] mon: fix divide by zero when pg_num adjusted and no osds Fixes: #9101 Backport: firefly, dumpling Signed-off-by: Sage Weil --- src/mon/OSDMonitor.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index e5e46e937a1bc..ade6081f68d11 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -3598,7 +3598,7 @@ int OSDMonitor::prepare_command_pool_set(map &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) { -- 2.39.5