From: Sage Weil Date: Wed, 20 Mar 2013 15:40:37 +0000 (-0700) Subject: mon: add optional ancestor arg to 'ceph osd crush rm [ancestor]' X-Git-Tag: v0.62~177^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=751b4bf89fe97b58216d4f26996905d365c25cb0;p=ceph.git mon: add optional ancestor arg to 'ceph osd crush rm [ancestor]' Remove only instances of the item underneath a particular ancestor. Signed-off-by: Sage Weil --- diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 4f90345ec37..923692698ff 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -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 + // osd crush rm [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);