From: Sage Weil Date: Thu, 15 Aug 2013 22:06:38 +0000 (-0700) Subject: osd: do not return data payload for successful writes X-Git-Tag: v0.68~64^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=610dc016e917b5dbb5b9f01112b58cd641c01b6d;p=ceph.git osd: do not return data payload for successful writes We were somewhat inadvertantly returning a data payload for write operations. This was a side-effect of the OpContext::ops field being a reference to MOSDOp::ops: the return data would end up there, and then the MOSDOpReply ctor would copy it. Fix this by breaking the ref, and making the do_op() logic also claim return result data for error values (so that errors can return data to the caller). Signed-off-by: Sage Weil --- diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index ab9c8099a44e..25f807342a3a 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -1037,14 +1037,16 @@ void ReplicatedPG::do_op(OpRequestRef op) // possible to construct an operation that does a read, does a guard // check (e.g., CMPXATTR), and then a write. Then we either succeed // with the write, or return a CMPXATTR and the read value. - if (ctx->op_t.empty() && !ctx->modify) { + if ((ctx->op_t.empty() && !ctx->modify) || result < 0) { // read. ctx->reply->claim_op_out_data(ctx->ops); ctx->reply->get_header().data_off = ctx->data_off; } else { // write. normalize the result code. - if (result > 0) + if (result > 0) { + dout(20) << " zeroing write result code " << result << dendl; result = 0; + } } ctx->reply->set_result(result); diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h index 41c8106ea000..4525ce13f55a 100644 --- a/src/osd/ReplicatedPG.h +++ b/src/osd/ReplicatedPG.h @@ -259,7 +259,7 @@ public: struct OpContext { OpRequestRef op; osd_reqid_t reqid; - vector& ops; + vector ops; const ObjectState *obs; // Old objectstate const SnapSet *snapset; // Old snapset