diff options
author | Sage Weil <sage@inktank.com> | 2013-09-24 15:26:03 -0700 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2013-09-24 15:27:54 -0700 |
commit | 94548b4b67cca37366c7d8719209a6d2e7956811 (patch) | |
tree | f7aaa436527c55ca08b2594e2415f2d3092c768e | |
parent | 00ff7f5c20e13869d0694379739ba4e61d44b97c (diff) | |
download | ceph-94548b4b67cca37366c7d8719209a6d2e7956811.tar.gz |
mon/OSDMonitor: fix 'ceph osd crush reweight ...'
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)
-rwxr-xr-x | qa/workunits/mon/crush_ops.sh | 9 | ||||
-rw-r--r-- | src/mon/OSDMonitor.cc | 2 |
2 files changed, 10 insertions, 1 deletions
diff --git a/qa/workunits/mon/crush_ops.sh b/qa/workunits/mon/crush_ops.sh index 09e49acfbf6..c2744fa279d 100755 --- a/qa/workunits/mon/crush_ops.sh +++ b/qa/workunits/mon/crush_ops.sh @@ -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 diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 0185ca4d67e..68dab0a59d5 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -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 |