Merge remote-tracking branch 'gh/wip-osd-write'

Reviewed-by: Josh Durgin <josh.durgin@dreamhost.com>
This commit is contained in:
Sage Weil 2012-02-21 14:44:44 -08:00
commit 04c8e01d80
2 changed files with 18 additions and 3 deletions

View File

@ -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)

View File

@ -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;