a less-than-zero rval indicates an error, and should not be normalized
to 0 if allows_returnvec() evaluates to false. probably we need a better
way to return a negative error code which does not fall into any known
error. but at this moment, grab the last rval and return it if it is
less than zero, can be used as a short term solution.
Signed-off-by: Kefu Chai <kchai@redhat.com>
obc,
ox_deleter = std::move(ox),
rvec = op_info.allows_returnvec()] {
- auto result = m->ops.empty() || !rvec ? 0 : m->ops.back().rval.code;
+ // TODO: should stop at the first op which returns a negative retval,
+ // cmpext uses it for returning the index of first unmatched byte
+ int result = m->ops.empty() ? 0 : m->ops.back().rval.code;
+ if (result > 0 && !rvec) {
+ result = 0;
+ }
auto reply = make_message<MOSDOpReply>(m.get(),
result,
get_osdmap_epoch(),