]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: 'ceph osd crush add ...' to add a second link to an item
authorSage Weil <sage@inktank.com>
Wed, 20 Mar 2013 14:02:20 +0000 (07:02 -0700)
committerSage Weil <sage@inktank.com>
Fri, 22 Mar 2013 22:15:36 +0000 (15:15 -0700)
Signed-off-by: Sage Weil <sage@inktank.com>
src/mon/OSDMonitor.cc
src/test/cli/ceph/help.t
src/tools/ceph.cc

index 8c4d1a43c777114e69d6eabf1994a32de025bba1..47c6c1d8f69223805a8fc6b19c05bab54f883ebc 100644 (file)
@@ -2256,7 +2256,8 @@ bool OSDMonitor::prepare_command(MMonCommand *m)
       wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_version()));
       return true;
     }
-    else if (m->cmd.size() >= 5 && m->cmd[1] == "crush" && m->cmd[2] == "set") {
+    else if (m->cmd.size() >= 5 && m->cmd[1] == "crush" && (m->cmd[2] == "set" ||
+                                                           m->cmd[2] == "add")) {
       do {
        // osd crush set <osd-id> [<osd.* name>] <weight> <loc1> [<loc2> ...]
        int id = parse_osd_id(m->cmd[3].c_str(), &ss);
@@ -2297,16 +2298,22 @@ bool OSDMonitor::prepare_command(MMonCommand *m)
        bufferlist::iterator p = bl.begin();
        newcrush.decode(p);
 
-       err = newcrush.update_item(g_ceph_context, id, weight, name, loc);
+       if (m->cmd[2] == "set") {
+         err = newcrush.update_item(g_ceph_context, id, weight, name, loc);
+       } else {
+         err = newcrush.insert_item(g_ceph_context, id, weight, name, loc);
+         if (err == 0)
+           err = 1;
+       }
        if (err == 0) {
-         ss << "updated item id " << id << " name '" << name << "' weight " << weight
+         ss << m->cmd[2] << " item id " << id << " name '" << name << "' weight " << weight
             << " at location " << loc << " to crush map";
          break;
        }
        if (err > 0) {
          pending_inc.crush.clear();
          newcrush.encode(pending_inc.crush);
-         ss << "updated item id " << id << " name '" << name << "' weight " << weight
+         ss << m->cmd[2] << " item id " << id << " name '" << name << "' weight " << weight
             << " at location " << loc << " to crush map";
          getline(ss, rs);
          wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_version()));
index c2f9e2158bf966379b798d5bf47f1d4826dbe796..ca93dba39c43288df3ec75fcaefffcf9da4a871a 100644 (file)
@@ -45,6 +45,7 @@
     ceph osd getcrushmap -o <file>
     ceph osd getmap -o <file>
     ceph osd crush set <osd-id> <weight> <loc1> [<loc2> ...]
+    ceph osd crush add <osd-id> <weight> <loc1> [<loc2> ...]
     ceph osd crush move <bucketname> <loc1> [<loc2> ...]
     ceph osd crush create-or-move <osd-id> <initial-weight> <loc1> [<loc2> ...]
     ceph osd crush reweight <name> <weight>
index d17c2426c94df2bd7e080c99123c1d68ca87edcb..f93d445d61224f4a9386c4509376b0803d51f1a3 100644 (file)
@@ -88,6 +88,7 @@ static void usage()
   cout << "  ceph osd getcrushmap -o <file>\n";
   cout << "  ceph osd getmap -o <file>\n";
   cout << "  ceph osd crush set <osd-id> <weight> <loc1> [<loc2> ...]\n";
+  cout << "  ceph osd crush add <osd-id> <weight> <loc1> [<loc2> ...]\n";
   cout << "  ceph osd crush move <bucketname> <loc1> [<loc2> ...]\n";
   cout << "  ceph osd crush create-or-move <osd-id> <initial-weight> <loc1> [<loc2> ...]\n";
   cout << "  ceph osd crush reweight <name> <weight>\n";