]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/ReplicatedPG: set version, user_version correctly on reads
authorSage Weil <sage@inktank.com>
Wed, 28 Aug 2013 23:29:16 +0000 (16:29 -0700)
committerSage Weil <sage@inktank.com>
Thu, 29 Aug 2013 00:05:10 +0000 (17:05 -0700)
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>
src/osd/ReplicatedPG.cc

index a04ab485e7e0261f905c0d757a09552982d44bb2..86d2db51cdb927e3126bbbba1676d812fcdc5d81 100644 (file)
@@ -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?