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:26:03 -0700 |
commit | 3de32562b55c6ece3a6ed783c36f8b9f21460339 (patch) | |
tree | 1ec4641f1d0738c4ad8b7be43f8adff1af835fb1 | |
parent | f6510c766592dbfa518e8667ed4d852d7e9319c0 (diff) | |
download | ceph-3de32562b55c6ece3a6ed783c36f8b9f21460339.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>
-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 d12ba22e462..351524efa81 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -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 |