]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: set POOL_CREATING flag until initial pool pgs are created
authorSage Weil <sage@redhat.com>
Sat, 7 Apr 2018 02:39:14 +0000 (21:39 -0500)
committerSage Weil <sage@redhat.com>
Fri, 7 Sep 2018 17:08:40 +0000 (12:08 -0500)
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 <sage@redhat.com>
src/mon/CreatingPGs.h
src/mon/OSDMonitor.cc

index cc2d4f0da001e01064477a515c1a97f5e5e7bd3a..51bc9902c5cf4409c0623b669f82ed9b5ee35a1e 100644 (file)
@@ -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<int64_t> 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) {
index 3a816024fa32ef0245096e61ca135af427ff4f60..ea84caeab7930bdd86c3d9582ba0b37cb5157bd6 100644 (file)
@@ -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