From: Sage Weil Date: Wed, 28 Aug 2013 23:29:16 +0000 (-0700) Subject: osd/ReplicatedPG: set version, user_version correctly on reads X-Git-Tag: v0.69~34^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c8dcd2ea715c5f838b6460f6aae77393e9df2954;p=ceph.git 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 --- diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index a04ab485e7e0..86d2db51cdb9 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?