Skip to content

Commit

Permalink
Merge remote-tracking branch 'gh/wip-osd-write'
Browse files Browse the repository at this point in the history
Reviewed-by: Josh Durgin <[email protected]>
  • Loading branch information
liewegas committed Feb 21, 2012
2 parents 55a6065 + 27c8a3f commit 04c8e01
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
19 changes: 17 additions & 2 deletions src/osd/ReplicatedPG.cc
Original file line number Diff line number Diff line change
Expand Up @@ -768,8 +768,23 @@ void ReplicatedPG::do_op(OpRequest *op)

// prepare the reply
ctx->reply = new MOSDOpReply(m, 0, get_osdmap()->get_epoch(), 0);
ctx->reply->claim_op_out_data(ctx->ops);
ctx->reply->get_header().data_off = ctx->data_off;

// Write operations aren't allowed to return a data payload because
// we can't do so reliably. If the client has to resend the request
// and it has already been applied, we will return 0 with no
// payload. Non-deterministic behavior is no good. However, it is
// 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) {
// 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)
result = 0;
}
ctx->reply->set_result(result);

if (result >= 0)
Expand Down
2 changes: 1 addition & 1 deletion src/test/rados-api/misc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ TEST(LibRadosMisc, Operate1PP) {
o2.cmpxattr("key1", CEPH_OSD_CMPXATTR_OP_EQ, bl);
o2.rmxattr("key1");
}
ASSERT_EQ(1, ioctx.operate("foo", &o2));
ASSERT_EQ(0, ioctx.operate("foo", &o2));
ObjectWriteOperation o3;
{
bufferlist bl;
Expand Down

0 comments on commit 04c8e01

Please sign in to comment.