]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: fix 'ceph osd crush reweight ...'
authorSage Weil <sage@inktank.com>
Tue, 24 Sep 2013 22:26:03 +0000 (15:26 -0700)
committerSage Weil <sage@inktank.com>
Tue, 24 Sep 2013 22:26:03 +0000 (15:26 -0700)
The adjust method returns a count of adjusted items.

Add a test.

Fixes: #6382
Backport: dumpling
Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Dan Mick <dan.mick@inktank.com>
qa/workunits/mon/crush_ops.sh
src/mon/OSDMonitor.cc

index 09e49acfbf6b2c1b51e1751dac33237df5528139..c2744fa279daa7707d56dcba50f6ca4c692f8c2e 100755 (executable)
@@ -68,4 +68,13 @@ ceph osd crush add-bucket foo host
 ceph osd crush move foo root=default rack=localrack
 ceph osd crush rm foo
 
+# test reweight
+o3=`ceph osd create`
+ceph osd crush add $o3 123 root=foo
+ceph osd tree | grep osd.$o3 | grep 123
+ceph osd crush reweight osd.$o3 113
+ceph osd tree | grep osd.$o3 | grep 113
+ceph osd crush rm osd.$o3
+ceph osd rm osd.$o3
+
 echo OK
index d12ba22e46260428945beba2e7c3f8f0418d776e..351524efa8133e926ec2d0bbc3c0eaea7a203d74 100644 (file)
@@ -2997,7 +2997,7 @@ bool OSDMonitor::prepare_command(MMonCommand *m)
       cmd_getval(g_ceph_context, cmdmap, "weight", w);
 
       err = newcrush.adjust_item_weightf(g_ceph_context, id, w);
-      if (err == 0) {
+      if (err >= 0) {
        pending_inc.crush.clear();
        newcrush.encode(pending_inc.crush);
        ss << "reweighted item id " << id << " name '" << name << "' to " << w