From 41c38559db31f4800fca6748860fbf329c2cba60 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 6 Apr 2018 21:39:14 -0500 Subject: [PATCH] mon/OSDMonitor: set POOL_CREATING flag until initial pool pgs are created Set the flag when the pool is created, and clear it when the initial set of PGs have been created by the mon. Move the update_creating_pgs() block so that we can process the pgid removal from the creating list and the pool flag removal in the same epoch; otherwise we might remove the pgid but have no cluster activity to roll over another osdmap epoch to allow the pool flag to be removed. Signed-off-by: Sage Weil --- src/mon/CreatingPGs.h | 11 +++++++++++ src/mon/OSDMonitor.cc | 27 +++++++++++++++++++++------ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/mon/CreatingPGs.h b/src/mon/CreatingPGs.h index cc2d4f0da001e..51bc9902c5cf4 100644 --- a/src/mon/CreatingPGs.h +++ b/src/mon/CreatingPGs.h @@ -47,6 +47,17 @@ struct creating_pgs_t { /// pools that exist in the osdmap for which at least one pg has been created std::set created_pools; + bool still_creating_pool(int64_t poolid) { + for (auto& i : pgs) { + if (i.first.pool() == poolid) { + return true; + } + } + if (queue.count(poolid)) { + return true; + } + return false; + } bool create_pool(int64_t poolid, uint32_t pg_num, epoch_t created, utime_t modified) { if (created_pools.count(poolid) == 0) { diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 3a816024fa32e..ea84caeab7930 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -1069,6 +1069,26 @@ void OSDMonitor::encode_pending(MonitorDBStore::TransactionRef t) tmp.deepish_copy_from(osdmap); tmp.apply_incremental(pending_inc); + // update creating pgs first so that we can remove the created pgid and + // process the pool flag removal below in the same osdmap epoch. + auto pending_creatings = update_pending_pgs(pending_inc, tmp); + bufferlist creatings_bl; + encode(pending_creatings, creatings_bl); + t->put(OSD_PG_CREATING_PREFIX, "creating", creatings_bl); + + // remove any old POOL_CREATING flags + for (auto& i : tmp.get_pools()) { + if (i.second.has_flag(pg_pool_t::FLAG_CREATING) && + !pending_creatings.still_creating_pool(i.first)) { + dout(10) << __func__ << " done creating pool " << i.first + << ", clearing CREATING flag" << dendl; + if (pending_inc.new_pools.count(i.first) == 0) { + pending_inc.new_pools[i.first] = i.second; + } + pending_inc.new_pools[i.first].flags &= ~pg_pool_t::FLAG_CREATING; + } + } + // remove any legacy osdmap nearfull/full flags { if (tmp.test_flag(CEPH_OSDMAP_FULL | CEPH_OSDMAP_NEARFULL)) { @@ -1417,12 +1437,6 @@ void OSDMonitor::encode_pending(MonitorDBStore::TransactionRef t) pending_metadata.clear(); pending_metadata_rm.clear(); - // and pg creating, also! - auto pending_creatings = update_pending_pgs(pending_inc, tmp); - bufferlist creatings_bl; - encode(pending_creatings, creatings_bl); - t->put(OSD_PG_CREATING_PREFIX, "creating", creatings_bl); - // removed_snaps if (tmp.require_osd_release >= CEPH_RELEASE_MIMIC) { for (auto& i : pending_inc.new_removed_snaps) { @@ -6651,6 +6665,7 @@ int OSDMonitor::prepare_new_pool(string& name, pi->set_flag(pg_pool_t::FLAG_NOPGCHANGE); if (g_conf()->osd_pool_default_flag_nosizechange) pi->set_flag(pg_pool_t::FLAG_NOSIZECHANGE); + pi->set_flag(pg_pool_t::FLAG_CREATING); if (g_conf()->osd_pool_use_gmt_hitset) pi->use_gmt_hitset = true; else -- 2.39.5