]> 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:27:54 +0000 (15:27 -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>
(cherry picked from commit 3de32562b55c6ece3a6ed783c36f8b9f21460339)

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 0185ca4d67ed7b8830753c2af02c98804cde9704..68dab0a59d541d94612f2cb6b07b785663b2449e 100644 (file)
@@ -2947,7 +2947,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