From: Greg Farnum Date: Tue, 3 Sep 2013 17:54:23 +0000 (-0700) Subject: osd: provide better version bounds for cls_current_version and ENOENT replies X-Git-Tag: v0.69~20 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=087800ee49a443098e7deec90cb0ee37aed0ff26;p=ceph.git osd: provide better version bounds for cls_current_version and ENOENT replies Following the changes to when we set or increase the user_version, we want to continue to return the best lower bound we can on the version of any newly-created object. For ENOENT replies that means returning info.last_user_version instead of the (potentially-zero) ctx->user_at_version. Similarly, for cls_current_version we want to return the last version on the PG rather than the last update to the object in order to provide sensible version ordering across object deletes and creates. Update the versions doc so it continues to be precise. Signed-off-by: Greg Farnum Reviewed-by: Sage Weil --- diff --git a/doc/dev/versions.rst b/doc/dev/versions.rst index c6a1ee690231..4fc4d8a12b26 100644 --- a/doc/dev/versions.rst +++ b/doc/dev/versions.rst @@ -12,11 +12,12 @@ transactions. user_at_version is modified only in ReplicatedPG::prepare_transaction when the op was a "user modify" (a non-watch write), and the durable user_version is updated according to the following rules: -1) increment user_at_version +1) set user_at_version to the maximum of ctx->new_obs.oi.user_version+1 + and info.last_user_version+1. 2) set user_at_version to the maximum of itself and -ctx->at_version.version. + ctx->at_version.version. 3) ctx->new_obs.oi.user_version = ctx->user_at_version (to change the -object's user_version) + object's user_version) This set of update semantics mean that for traditional pools the user_version will be equal to the past reassert_version, while for @@ -36,6 +37,5 @@ is filled in on every operation (reads included) while replay_version is filled in for writes. The objclass function get_current_version() now always returns the -user_at_version, which means it is guaranteed to contain the version -of the last user update in the PG (including on reads!). - +pg->info.last_user_version, which means it is guaranteed to contain +the version of the last user update in the PG (including on reads!). diff --git a/src/objclass/class_api.cc b/src/objclass/class_api.cc index b95260b7e166..1ac224cdfe7d 100644 --- a/src/objclass/class_api.cc +++ b/src/objclass/class_api.cc @@ -582,7 +582,7 @@ uint64_t cls_current_version(cls_method_context_t hctx) { ReplicatedPG::OpContext *ctx = *(ReplicatedPG::OpContext **)hctx; - return ctx->user_at_version; + return ctx->pg->info.last_user_version; } diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 1ab363091a93..0027edda077a 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -1049,7 +1049,7 @@ void ReplicatedPG::execute_ctx(OpContext *ctx) 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); + reply->set_enoent_reply_versions(info.last_update, info.last_user_version); } reply->add_flags(CEPH_OSD_FLAG_ACK | CEPH_OSD_FLAG_ONDISK);