]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: 'osd crush reweight <name> <weight>'
authorSage Weil <sage@newdream.net>
Tue, 23 Aug 2011 19:40:14 +0000 (12:40 -0700)
committerSage Weil <sage@newdream.net>
Tue, 23 Aug 2011 19:40:14 +0000 (12:40 -0700)
Reweight a node in the crush map.

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

index 1045b4839f31db3dbe81704a8346787197c076ac..983e46e3fafda0650c69a8f901480aa0fc9e469a 100644 (file)
@@ -1486,6 +1486,39 @@ bool OSDMonitor::prepare_command(MMonCommand *m)
        }
       } while (false);
     }
+    else if (m->cmd[1] == "crush" && m->cmd[2] == "reweight" &&
+            m->cmd.size() > 4) {
+      do {
+       // osd crush reweight <name> <weight>
+       bufferlist bl;
+       if (pending_inc.crush.length())
+         bl = pending_inc.crush;
+       else
+         osdmap.crush.encode(bl);
+
+       CrushWrapper newcrush;
+       bufferlist::iterator p = bl.begin();
+       newcrush.decode(p);
+
+       int id = newcrush.get_item_id(m->cmd[3].c_str());
+       if (id < 0) {
+         ss << "device '" << m->cmd[3] << "' does not appear in the crush map";
+         break;
+       }
+       float w = atof(m->cmd[4].c_str());
+
+       err = newcrush.adjust_item_weightf(id, w);
+       if (err == 0) {
+         pending_inc.crush.clear();
+         newcrush.encode(pending_inc.crush);
+         ss << "reweighted item id " << id << " name '" << m->cmd[3] << "' to " << w
+            << " in crush map";
+         getline(ss, rs);
+         paxos->wait_for_commit(new Monitor::C_Command(mon, m, 0, rs, paxos->get_version()));
+         return true;
+       }
+      } while (false);
+    }
     else if (m->cmd[1] == "setmaxosd" && m->cmd.size() > 2) {
       int newmax = atoi(m->cmd[2].c_str());
       if (newmax < osdmap.crush.get_max_devices()) {