]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: add optional ancestor arg to 'ceph osd crush rm <item> [ancestor]'
authorSage Weil <sage@inktank.com>
Wed, 20 Mar 2013 15:40:37 +0000 (08:40 -0700)
committerSage Weil <sage@inktank.com>
Fri, 22 Mar 2013 22:15:37 +0000 (15:15 -0700)
Remove only instances of the item underneath a particular ancestor.

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

index 4f90345ec37cb6fbc6bc010d7ed93d19509ca00e..923692698ff65b925b0c407257228d0ba132d76b 100644 (file)
@@ -2451,7 +2451,7 @@ bool OSDMonitor::prepare_command(MMonCommand *m)
     }
     else if (m->cmd.size() > 3 && m->cmd[1] == "crush" && (m->cmd[2] == "rm" || m->cmd[2] == "remove")) {
       do {
-       // osd crush rm <id>
+       // osd crush rm <id> [ancestor]
        bufferlist bl;
        if (pending_inc.crush.length())
          bl = pending_inc.crush;
@@ -2472,7 +2472,17 @@ bool OSDMonitor::prepare_command(MMonCommand *m)
          ss << "item '" << m->cmd[3] << "' is not a leaf in the crush map";
          break;
        }
-       err = newcrush.remove_item(g_ceph_context, id);
+       if (m->cmd.size() > 4) {
+         if (!newcrush.name_exists(m->cmd[4])) {
+           err = -ENOENT;
+           ss << "ancestor item '" << m->cmd[4] << "' does not appear in the crush map";
+           break;
+         }
+         int ancestor = newcrush.get_item_id(m->cmd[4]);
+         err = newcrush.remove_item_under(g_ceph_context, id, ancestor);
+       } else {
+         err = newcrush.remove_item(g_ceph_context, id);
+       }
        if (err == 0) {
          pending_inc.crush.clear();
          newcrush.encode(pending_inc.crush);