diff options
author | Sage Weil <sage@inktank.com> | 2013-08-28 16:29:16 -0700 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2013-08-28 17:05:10 -0700 |
commit | c8dcd2ea715c5f838b6460f6aae77393e9df2954 (patch) | |
tree | 042f496a8a38146859a35fafed7bbc42c2ecadcd | |
parent | 9374dc8bf33229e847965a318bd6ef1e8690322f (diff) | |
download | ceph-c8dcd2ea715c5f838b6460f6aae77393e9df2954.tar.gz |
osd/ReplicatedPG: set version, user_version correctly on reads
Set the user version to the *current* object version, not the version
we would use if we were to modify it. We move the assignments inside
the reply (read or error) block to make it more obvious which paths
are possible.
Signed-off-by: Sage Weil <sage@inktank.com>
-rw-r--r-- | src/osd/ReplicatedPG.cc | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index a04ab485e7e..86d2db51cdb 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -1024,21 +1024,22 @@ void ReplicatedPG::do_op(OpRequestRef op) } ctx->reply->set_result(result); - if (result >= 0) { - ctx->reply->set_reply_versions(ctx->at_version, ctx->user_at_version); - } else if (result == -ENOENT) { - ctx->reply->set_enoent_reply_versions(info.last_update, ctx->user_at_version); - } - // read or error? if (ctx->op_t.empty() || result < 0) { + MOSDOpReply *reply = ctx->reply; + ctx->reply = NULL; + if (result >= 0) { log_op_stats(ctx); publish_stats_to_osd(); + + // on read, return the current object version + reply->set_reply_versions(eversion_t(), ctx->obs->oi.user_version); + } else if (result == -ENOENT) { + // on ENOENT, set a floor for what the next user version will be. + reply->set_enoent_reply_versions(info.last_update, ctx->user_at_version); } - MOSDOpReply *reply = ctx->reply; - ctx->reply = NULL; reply->add_flags(CEPH_OSD_FLAG_ACK | CEPH_OSD_FLAG_ONDISK); osd->send_message_osd_client(reply, m->get_connection()); delete ctx; @@ -1046,6 +1047,8 @@ void ReplicatedPG::do_op(OpRequestRef op) return; } + ctx->reply->set_reply_versions(ctx->at_version, ctx->user_at_version); + assert(op->may_write()); // trim log? |