]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: add processed_subop_count for cls_cxx_subop_version()
authorCasey Bodley <cbodley@redhat.com>
Sat, 28 Oct 2017 20:28:27 +0000 (16:28 -0400)
committerShinobu Kinjo <shinobu@redhat.com>
Fri, 3 Nov 2017 22:34:23 +0000 (07:34 +0900)
cls_log_add() relies on cls_cxx_subop_version() to generate unique keys
for log entries with the same timestamp. because cls calls back into
do_osd_ops(), resetting current_osd_subop_num means that cls_log_add()
will keep seeing the same subop version and generating the same keys.
this causes the following failure in ceph_test_cls_log:

[ RUN      ] cls_rgw.test_log_add_same_time
/home/cbodley/ceph/src/test/cls_log/test_cls_log.cc:144: Failure
      Expected: 10
To be equal to: (int)entries.size()
      Which is: 1
[  FAILED  ] cls_rgw.test_log_add_same_time (1180 ms)

Fixes: http://tracker.ceph.com/issues/21964
Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 95faac9ae2cd38b1ca25c90f90bd4a53fe6af4d4)

src/objclass/class_api.cc
src/osd/PrimaryLogPG.cc
src/osd/PrimaryLogPG.h

index cb8aa0677f8c215e84374b9da1229f1f30a114e8..db05fcdcfbc7060f6bf5d75c32e6da9a31406575 100644 (file)
@@ -676,7 +676,7 @@ int cls_current_subop_num(cls_method_context_t hctx)
 {
   PrimaryLogPG::OpContext *ctx = *(PrimaryLogPG::OpContext **)hctx;
 
-  return ctx->current_osd_subop_num;
+  return ctx->processed_subop_count;
 }
 
 uint64_t cls_get_features(cls_method_context_t hctx)
index 3dd4eff09893b04f12545410058f70eac0261b7d..e98f2b7c75531053dde631ea094d70281fa67554 100644 (file)
@@ -5031,7 +5031,7 @@ int PrimaryLogPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
   dout(10) << "do_osd_op " << soid << " " << ops << dendl;
 
   ctx->current_osd_subop_num = 0;
-  for (vector<OSDOp>::iterator p = ops.begin(); p != ops.end(); ++p, ctx->current_osd_subop_num++) {
+  for (auto p = ops.begin(); p != ops.end(); ++p, ctx->current_osd_subop_num++, ctx->processed_subop_count++) {
     OSDOp& osd_op = *p;
     ceph_osd_op& op = osd_op.op;
 
index df2a45f5877bbff4625124f7e0a5bbbba3f09e89..31aa3502d169bc6ca17ff36051e8e2ed7472d39a 100644 (file)
@@ -527,7 +527,10 @@ public:
     eversion_t at_version;       // pg's current version pointer
     version_t user_at_version;   // pg's current user version pointer
 
+    /// index of the current subop - only valid inside of do_osd_ops()
     int current_osd_subop_num;
+    /// total number of subops processed in this context for cls_cxx_subop_version()
+    int processed_subop_count = 0;
 
     PGTransactionUPtr op_t;
     vector<pg_log_entry_t> log;