]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd,mon: add norebalance osdmap flag
authorKefu Chai <kchai@redhat.com>
Wed, 4 Feb 2015 14:32:57 +0000 (22:32 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 5 Feb 2015 05:52:17 +0000 (13:52 +0800)
Fixes: #10559
Signed-off-by: Kefu Chai <kchai@redhat.com>
doc/man/8/ceph.rst
qa/workunits/cephtool/test.sh
src/include/rados.h
src/mon/MonCommands.h
src/mon/OSDMonitor.cc
src/osd/OSDMap.cc
src/osd/PG.cc
src/osd/ReplicatedPG.cc

index 223a998db1900d22beab39c45b6cb42f483a9bc4..5a3121feccb803f48e5f371e61605a8c546d172d 100644 (file)
@@ -820,8 +820,8 @@ Subcommand ``set`` sets <key>.
 
 Usage::
 
-       ceph osd set pause|noup|nodown|noout|noin|nobackfill|norecover|noscrub|
-       nodeep-scrub|notieragent
+       ceph osd set pause|noup|nodown|noout|noin|nobackfill|norebalance|norecover|
+       noscrub|nodeep-scrub|notieragent
 
 Subcommand ``setcrushmap`` sets crush map from input file.
 
@@ -906,8 +906,8 @@ Subcommand ``unset`` unsets <key>.
 
 Usage::
 
-       osd unset pause|noup|nodown|noout|noin|nobackfill|norecover|noscrub|
-       nodeep-scrub|notieragent
+       osd unset pause|noup|nodown|noout|noin|nobackfill|norebalance|norecover|
+       noscrub|nodeep-scrub|notieragent
 
 
 pg
index b333b4f5e1982cbb8d3b141ab74831651988de57..6251af1af272d8ed12ac3d4b305e7a7ee116aa99 100755 (executable)
@@ -879,7 +879,7 @@ function test_mon_osd()
   ceph osd deep-scrub 0
   ceph osd repair 0
 
-  for f in noup nodown noin noout noscrub nodeep-scrub nobackfill norecover notieragent full
+  for f in noup nodown noin noout noscrub nodeep-scrub nobackfill norebalance norecover notieragent full
   do
     ceph osd set $f
     ceph osd unset $f
index da166cd1604e23b12dc62aff834dee247f6dd108..3691a2ceadb02deeade133922b00a83e4abe6c77 100644 (file)
@@ -142,6 +142,7 @@ extern const char *ceph_osd_state_name(int s);
 #define CEPH_OSDMAP_NOSCRUB  (1<<11) /* block periodic scrub */
 #define CEPH_OSDMAP_NODEEP_SCRUB (1<<12) /* block periodic deep-scrub */
 #define CEPH_OSDMAP_NOTIERAGENT (1<<13) /* disable tiering agent */
+#define CEPH_OSDMAP_NOREBALANCE (1<<14) /* block osd backfill unless pg is degraded */
 
 /*
  * The error code to return when an OSD can't handle a write
index e11bc734b3652a5948b3fc9ba4695f97d577d6c2..b671e063fea25c6e1071213a873f5338275a6ae3 100644 (file)
@@ -518,10 +518,10 @@ COMMAND("osd erasure-code-profile ls", \
        "list all erasure code profiles", \
        "osd", "r", "cli,rest")
 COMMAND("osd set " \
-       "name=key,type=CephChoices,strings=full|pause|noup|nodown|noout|noin|nobackfill|norecover|noscrub|nodeep-scrub|notieragent", \
+       "name=key,type=CephChoices,strings=full|pause|noup|nodown|noout|noin|nobackfill|norebalance|norecover|noscrub|nodeep-scrub|notieragent", \
        "set <key>", "osd", "rw", "cli,rest")
 COMMAND("osd unset " \
-       "name=key,type=CephChoices,strings=full|pause|noup|nodown|noout|noin|nobackfill|norecover|noscrub|nodeep-scrub|notieragent", \
+       "name=key,type=CephChoices,strings=full|pause|noup|nodown|noout|noin|nobackfill|norebalance|norecover|noscrub|nodeep-scrub|notieragent", \
        "unset <key>", "osd", "rw", "cli,rest")
 COMMAND("osd cluster_snap", "take cluster snapshot (disabled)", \
        "osd", "r", "")
index 9b1f9801a16fa9985a33875af023f7e8caa2d4fb..3c118530f948cbb2287c93a175269a28d45da825 100644 (file)
@@ -2473,6 +2473,7 @@ void OSDMonitor::get_health(list<pair<health_status_t,string> >& summary,
                         CEPH_OSDMAP_NOIN |
                         CEPH_OSDMAP_NOOUT |
                         CEPH_OSDMAP_NOBACKFILL |
+                        CEPH_OSDMAP_NOREBALANCE |
                         CEPH_OSDMAP_NORECOVER |
                         CEPH_OSDMAP_NOSCRUB |
                         CEPH_OSDMAP_NODEEP_SCRUB |
@@ -5279,6 +5280,8 @@ bool OSDMonitor::prepare_command_impl(MMonCommand *m,
       return prepare_set_flag(m, CEPH_OSDMAP_NOIN);
     else if (key == "nobackfill")
       return prepare_set_flag(m, CEPH_OSDMAP_NOBACKFILL);
+    else if (key == "norebalance")
+      return prepare_set_flag(m, CEPH_OSDMAP_NOREBALANCE);
     else if (key == "norecover")
       return prepare_set_flag(m, CEPH_OSDMAP_NORECOVER);
     else if (key == "noscrub")
@@ -5309,6 +5312,8 @@ bool OSDMonitor::prepare_command_impl(MMonCommand *m,
       return prepare_unset_flag(m, CEPH_OSDMAP_NOIN);
     else if (key == "nobackfill")
       return prepare_unset_flag(m, CEPH_OSDMAP_NOBACKFILL);
+    else if (key == "norebalance")
+      return prepare_unset_flag(m, CEPH_OSDMAP_NOREBALANCE);
     else if (key == "norecover")
       return prepare_unset_flag(m, CEPH_OSDMAP_NORECOVER);
     else if (key == "noscrub")
index adc10a05631bf4d2f9c986f192adf1e5ddd95b28..d4c45110cd4a1c9d2f6cf6ed9adc6c1f7515c3b4 100644 (file)
@@ -2359,6 +2359,8 @@ string OSDMap::get_flag_string(unsigned f)
     s += ",noin";
   if (f & CEPH_OSDMAP_NOBACKFILL)
     s += ",nobackfill";
+  if (f & CEPH_OSDMAP_NOREBALANCE)
+    s += ",norebalance";
   if (f & CEPH_OSDMAP_NORECOVER)
     s += ",norecover";
   if (f & CEPH_OSDMAP_NOSCRUB)
index d7d2c7fe607bedb7d92c65678d6c904325b7c7b3..d1752e8fe085f381e5e0ff8571f7431b1b994019 100644 (file)
@@ -6413,7 +6413,8 @@ boost::statechart::result PG::RecoveryState::Active::react(const ActMap&)
   }
 
   if (!pg->is_clean() &&
-      !pg->get_osdmap()->test_flag(CEPH_OSDMAP_NOBACKFILL)) {
+      !pg->get_osdmap()->test_flag(CEPH_OSDMAP_NOBACKFILL) &&
+      (!pg->get_osdmap()->test_flag(CEPH_OSDMAP_NOREBALANCE) || pg->is_degraded())) {
     pg->osd->queue_for_recovery(pg);
   }
   return forward_event();
index 93f4f72b88d18afd9f73d766a0a7b462dcd3ead3..c1102ece015508d0021f47db860c942160205e18 100644 (file)
@@ -10661,6 +10661,10 @@ bool ReplicatedPG::start_recovery_ops(
     if (get_osdmap()->test_flag(CEPH_OSDMAP_NOBACKFILL)) {
       dout(10) << "deferring backfill due to NOBACKFILL" << dendl;
       deferred_backfill = true;
+    } else if (get_osdmap()->test_flag(CEPH_OSDMAP_NOREBALANCE) &&
+              !is_degraded())  {
+      dout(10) << "deferring backfill due to NOREBALANCE" << dendl;
+      deferred_backfill = true;
     } else if (!backfill_reserved) {
       dout(10) << "deferring backfill due to !backfill_reserved" << dendl;
       if (!backfill_reserving) {