From aea329eb9a35289c7da6ce27cf675b8c4aee2263 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sat, 7 Apr 2018 14:35:36 -0500 Subject: [PATCH] mon/OSDMonitor: set CREATING flag for force-create-pg In order to recreate a lost PG, we need to set the CREATING flag for the pool. This prevents pg_num from changing in future OSDMap epochs until *after* the PG has successfully been instantiated. Note that a pg_num change in *this* epoch is fine; the recreated PG will instantiate in *this* epoch, which is /after/ the split a pg_num in this epoch would describe. Signed-off-by: Sage Weil --- src/mon/OSDMonitor.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index d30b5078987a3..aa1c5a4d01519 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -12005,6 +12005,13 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, } if (creating_now) { ss << "pg " << pgidstr << " now creating, ok"; + // set the pool's CREATING flag so that (1) the osd won't ignore our + // create message and (2) we won't propose any future pg_num changes + // until after the PG has been instantiated. + if (pending_inc.new_pools.count(pgid.pool()) == 0) { + pending_inc.new_pools[pgid.pool()] = *osdmap.get_pg_pool(pgid.pool()); + } + pending_inc.new_pools[pgid.pool()].flags |= pg_pool_t::FLAG_CREATING; err = 0; goto update; } else { -- 2.39.5