]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: apply new 'destroyed' status to 'osd tree' filter
authorxie xingguo <xie.xingguo@zte.com.cn>
Fri, 21 Jul 2017 07:08:44 +0000 (15:08 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Wed, 26 Jul 2017 07:13:32 +0000 (15:13 +0800)
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
qa/workunits/cephtool/test.sh
src/mon/MonCommands.h
src/mon/OSDMonitor.cc
src/osd/OSDMap.cc
src/osd/OSDMap.h

index 84fd9cc97398ff98cba8b976074ffb5cb86e092c..e6e84e08e3b31795c64522d1d499f8ef8496fdde 100755 (executable)
@@ -1618,12 +1618,16 @@ function test_mon_osd()
   ceph osd tree down
   ceph osd tree in
   ceph osd tree out
+  ceph osd tree destroyed
   ceph osd tree up in
   ceph osd tree up out
   ceph osd tree down in
   ceph osd tree down out
   ceph osd tree out down
   expect_false ceph osd tree up down
+  expect_false ceph osd tree up destroyed
+  expect_false ceph osd tree down destroyed
+  expect_false ceph osd tree up down destroyed
   expect_false ceph osd tree in out
   expect_false ceph osd tree up foo
 
index e5152928c17bc3209edf6626686508c8d09fdeee..41e3f79f1175a7e6f3ccb170ae50183b91d8f929 100644 (file)
@@ -460,7 +460,7 @@ COMMAND("osd dump " \
        "print summary of OSD map", "osd", "r", "cli,rest")
 COMMAND("osd tree " \
        "name=epoch,type=CephInt,range=0,req=false " \
-       "name=states,type=CephChoices,strings=up|down|in|out,n=N,req=false", \
+       "name=states,type=CephChoices,strings=up|down|in|out|destroyed,n=N,req=false", \
        "print OSD tree", "osd", "r", "cli,rest")
 COMMAND("osd ls " \
        "name=epoch,type=CephInt,range=0,req=false", \
index 86f70cf09946247528ce3b3ee0a21d17d2c994a0..94b0e5b7936c14edd420472658102b6bdd7fe015 100644 (file)
@@ -4137,6 +4137,8 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op)
          filter |= OSDMap::DUMP_IN;
        } else if (s == "out") {
          filter |= OSDMap::DUMP_OUT;
+       } else if (s == "destroyed") {
+         filter |= OSDMap::DUMP_DESTROYED;
        } else {
          ss << "unrecognized state '" << s << "'";
          r = -EINVAL;
@@ -4144,10 +4146,18 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op)
        }
       }
       if ((filter & (OSDMap::DUMP_IN|OSDMap::DUMP_OUT)) ==
-         (OSDMap::DUMP_IN|OSDMap::DUMP_OUT) ||
-         (filter & (OSDMap::DUMP_UP|OSDMap::DUMP_DOWN)) ==
-         (OSDMap::DUMP_UP|OSDMap::DUMP_DOWN)) {
-       ss << "cannot specify both up and down or both in and out";
+         (OSDMap::DUMP_IN|OSDMap::DUMP_OUT)) {
+        ss << "cannot specify both 'in' and 'out'";
+        r = -EINVAL;
+        goto reply;
+      }
+      if (((filter & (OSDMap::DUMP_UP|OSDMap::DUMP_DOWN)) ==
+          (OSDMap::DUMP_UP|OSDMap::DUMP_DOWN)) ||
+           ((filter & (OSDMap::DUMP_UP|OSDMap::DUMP_DESTROYED)) ==
+           (OSDMap::DUMP_UP|OSDMap::DUMP_DESTROYED)) ||
+           ((filter & (OSDMap::DUMP_DOWN|OSDMap::DUMP_DESTROYED)) ==
+           (OSDMap::DUMP_DOWN|OSDMap::DUMP_DESTROYED))) {
+       ss << "can specify only one of 'up', 'down' and 'destroyed'";
        r = -EINVAL;
        goto reply;
       }
index d3cc2774a03a5c6e3be34f64aa92fe9d06fe833d..57035c4c8ea8e704597a7afeb75a905b562e5e6c 100644 (file)
@@ -3056,13 +3056,17 @@ public:
     : Parent(crush, osdmap_->get_pool_names()), osdmap(osdmap_), filter(f) { }
 
   bool should_dump_leaf(int i) const override {
-    if (((filter & OSDMap::DUMP_UP) && !osdmap->is_up(i)) ||
-       ((filter & OSDMap::DUMP_DOWN) && !osdmap->is_down(i)) ||
-       ((filter & OSDMap::DUMP_IN) && !osdmap->is_in(i)) ||
-       ((filter & OSDMap::DUMP_OUT) && !osdmap->is_out(i))) {
-      return false;
+    if (!filter) {
+      return true; // normal case
+    }
+    if (((filter & OSDMap::DUMP_UP) && osdmap->is_up(i)) ||
+       ((filter & OSDMap::DUMP_DOWN) && osdmap->is_down(i)) ||
+       ((filter & OSDMap::DUMP_IN) && osdmap->is_in(i)) ||
+       ((filter & OSDMap::DUMP_OUT) && osdmap->is_out(i)) ||
+        ((filter & OSDMap::DUMP_DESTROYED) && osdmap->is_destroyed(i))) {
+      return true;
     }
-    return true;
+    return false;
   }
 
   bool should_dump_empty_bucket() const override {
@@ -3142,13 +3146,17 @@ public:
     : Parent(crush, osdmap_->get_pool_names()), osdmap(osdmap_), filter(f) { }
 
   bool should_dump_leaf(int i) const override {
-    if (((filter & OSDMap::DUMP_UP) && !osdmap->is_up(i)) ||
-       ((filter & OSDMap::DUMP_DOWN) && !osdmap->is_down(i)) ||
-       ((filter & OSDMap::DUMP_IN) && !osdmap->is_in(i)) ||
-       ((filter & OSDMap::DUMP_OUT) && !osdmap->is_out(i))) {
-      return false;
+    if (!filter) {
+      return true; // normal case
+    }
+    if (((filter & OSDMap::DUMP_UP) && osdmap->is_up(i)) ||
+        ((filter & OSDMap::DUMP_DOWN) && osdmap->is_down(i)) ||
+        ((filter & OSDMap::DUMP_IN) && osdmap->is_in(i)) ||
+        ((filter & OSDMap::DUMP_OUT) && osdmap->is_out(i)) ||
+        ((filter & OSDMap::DUMP_DESTROYED) && osdmap->is_destroyed(i))) {
+      return true;
     }
-    return true;
+    return false;
   }
 
   bool should_dump_empty_bucket() const override {
index aeda1813fc8b5d4dc752511faf927be8d35209fd..268c420152ec10694e459323654fb9f58a16f189 100644 (file)
@@ -1345,10 +1345,11 @@ public:
   void print_oneline_summary(ostream& out) const;
 
   enum {
-    DUMP_IN = 1,     // only 'in' osds
-    DUMP_OUT = 2,    // only 'out' osds
-    DUMP_UP = 4,     // only 'up' osds
-    DUMP_DOWN = 8,   // only 'down' osds
+    DUMP_IN = 1,         // only 'in' osds
+    DUMP_OUT = 2,        // only 'out' osds
+    DUMP_UP = 4,         // only 'up' osds
+    DUMP_DOWN = 8,       // only 'down' osds
+    DUMP_DESTROYED = 16, // only 'destroyed' osds
   };
   void print_tree(Formatter *f, ostream *out, unsigned dump_flags=0) const;