]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: set cluster flags based on osd flags (luminous)
authorSage Weil <sage@redhat.com>
Thu, 23 Feb 2017 21:31:21 +0000 (16:31 -0500)
committerSage Weil <sage@redhat.com>
Mon, 6 Mar 2017 22:21:22 +0000 (17:21 -0500)
For luminous, set cluster flags based on osd flags.  Until
require_luminous is set, stick with the old pgmap-based behavior.
Move the new check to encode_pending so that the cluster flag is
set in the same epoch that the osd state(s) change.

Signed-off-by: Sage Weil <sage@redhat.com>
src/mon/OSDMonitor.cc

index 1ef0dd9834cb2806fa8e82e9e91937a8ffe93f60..ce35491888e0236475c06bab14e0acaeb91c126d 100644 (file)
@@ -1185,6 +1185,41 @@ void OSDMonitor::encode_pending(MonitorDBStore::TransactionRef t)
 
   bufferlist bl;
 
+  // set or clear full/nearfull?
+  {
+    OSDMap tmp;
+    tmp.deepish_copy_from(osdmap);
+    tmp.apply_incremental(pending_inc);
+
+    if (tmp.test_flag(CEPH_OSDMAP_REQUIRE_LUMINOUS)) {
+      int full, nearfull;
+      tmp.count_full_nearfull_osds(&full, &nearfull);
+      if (full > 0) {
+       if (!tmp.test_flag(CEPH_OSDMAP_FULL)) {
+         dout(10) << __func__ << " setting full flag" << dendl;
+         add_flag(CEPH_OSDMAP_FULL);
+         remove_flag(CEPH_OSDMAP_NEARFULL);
+       }
+      } else {
+       if (tmp.test_flag(CEPH_OSDMAP_FULL)) {
+         dout(10) << __func__ << " clearing full flag" << dendl;
+         remove_flag(CEPH_OSDMAP_FULL);
+       }
+       if (nearfull > 0) {
+         if (!tmp.test_flag(CEPH_OSDMAP_NEARFULL)) {
+           dout(10) << __func__ << " setting nearfull flag" << dendl;
+           add_flag(CEPH_OSDMAP_NEARFULL);
+         }
+       } else {
+         if (tmp.test_flag(CEPH_OSDMAP_NEARFULL)) {
+           dout(10) << __func__ << " clearing nearfull flag" << dendl;
+           remove_flag(CEPH_OSDMAP_NEARFULL);
+         }
+       }
+      }
+    }
+  }
+
   // tell me about it
   for (map<int32_t,uint8_t>::iterator i = pending_inc.new_state.begin();
        i != pending_inc.new_state.end();
@@ -3020,8 +3055,10 @@ void OSDMonitor::tick()
     }
   }
 
-  //if map full setting has changed, get that info out there!
-  if (mon->pgmon()->is_readable()) {
+  // if map full setting has changed, get that info out there!
+  if (!osdmap.test_flag(CEPH_OSDMAP_REQUIRE_LUMINOUS) &&
+      mon->pgmon()->is_readable()) {
+    // for pre-luminous compat only!
     if (!mon->pgmon()->pg_map.full_osds.empty()) {
       dout(5) << "There are full osds, setting full flag" << dendl;
       add_flag(CEPH_OSDMAP_FULL);