]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: do not return data payload for successful writes
authorSage Weil <sage@inktank.com>
Thu, 15 Aug 2013 22:06:38 +0000 (15:06 -0700)
committerSage Weil <sage@inktank.com>
Fri, 16 Aug 2013 00:21:11 +0000 (17:21 -0700)
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 <sage@inktank.com>
src/osd/ReplicatedPG.cc
src/osd/ReplicatedPG.h

index ab9c8099a44e0e279e888276a8c3d436fb5264c3..25f807342a3a4ba0f6ccd49ff8d53d283e2dea4f 100644 (file)
@@ -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);
 
index 41c8106ea000933fb79b6dcbf469bb9646679dd0..4525ce13f55ace218e56fa1defd22ddec4a0d212 100644 (file)
@@ -259,7 +259,7 @@ public:
   struct OpContext {
     OpRequestRef op;
     osd_reqid_t reqid;
-    vector<OSDOp>& ops;
+    vector<OSDOp> ops;
 
     const ObjectState *obs; // Old objectstate
     const SnapSet *snapset; // Old snapset