]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ReplicatedPG: merge apply_ctx_scrub_stats into apply_stats
authorSamuel Just <sjust@redhat.com>
Tue, 29 Nov 2016 21:56:06 +0000 (13:56 -0800)
committerSamuel Just <sjust@redhat.com>
Fri, 2 Dec 2016 21:40:14 +0000 (13:40 -0800)
The only way the two aren't called essentially atomically is when the
ECBackend needs to delay a write for rmw.  In such a case, we actually
want to delay the scrub_cstat application as well since otherwise, we'd
have to flush the backend before settling up at the end of scrub.

Perhaps this should be a separate function to distinguish between the
replica+primary info update and the primary scrub_cstat update, but that
seems more complicated than it's really worth.

Fixes: http://tracker.ceph.com/issues/17999
Signed-off-by: Samuel Just <sjust@redhat.com>
src/osd/ReplicatedPG.cc
src/osd/ReplicatedPG.h

index b69e90349d7afdf6b2fac97d9cf6683ec3ac2ef7..ee5c9fd0b5e783cd44c4769336eece8c5a986845 100644 (file)
@@ -6775,8 +6775,7 @@ int ReplicatedPG::prepare_transaction(OpContext *ctx)
   return result;
 }
 
-void ReplicatedPG::finish_ctx(OpContext *ctx, int log_op_type, bool maintain_ssc,
-                             bool scrub_ok)
+void ReplicatedPG::finish_ctx(OpContext *ctx, int log_op_type, bool maintain_ssc)
 {
   const hobject_t& soid = ctx->obs->oi.soid;
   dout(20) << __func__ << " " << soid << " " << ctx
@@ -6934,8 +6933,6 @@ void ReplicatedPG::finish_ctx(OpContext *ctx, int log_op_type, bool maintain_ssc
     ctx->obc->ssc->exists = true;
     ctx->obc->ssc->snapset = ctx->new_snapset;
   }
-
-  apply_ctx_scrub_stats(ctx, scrub_ok);
 }
 
 void ReplicatedPG::apply_stats(
@@ -6954,16 +6951,11 @@ void ReplicatedPG::apply_stats(
     else if (cmp(soid, last_backfill_started, get_sort_bitwise()) <= 0)
       pending_backfill_updates[soid].stats.add(delta_stats);
   }
-}
 
-void ReplicatedPG::apply_ctx_scrub_stats(OpContext *ctx, bool scrub_ok)
-{
-  const hobject_t& soid = ctx->obs->oi.soid;
-  if (!scrub_ok && scrubber.active) {
-    assert(cmp(soid, scrubber.start, get_sort_bitwise()) < 0 ||
-          cmp(soid, scrubber.end, get_sort_bitwise()) >= 0);
-    if (cmp(soid, scrubber.start, get_sort_bitwise()) < 0)
-      scrub_cstat.add(ctx->delta_stats);
+  if (is_primary() && scrubber.active) {
+    if (cmp(soid, scrubber.start, get_sort_bitwise()) < 0) {
+      scrub_cstat.add(delta_stats);
+    }
   }
 }
 
@@ -11623,7 +11615,6 @@ void ReplicatedPG::hit_set_remove_all()
     utime_t now = ceph_clock_now(cct);
     ctx->mtime = now;
     hit_set_trim(ctx, 0);
-    apply_ctx_scrub_stats(ctx.get());
     simple_opc_submit(std::move(ctx));
   }
 
@@ -11842,7 +11833,6 @@ void ReplicatedPG::hit_set_persist()
 
   hit_set_trim(ctx, max);
 
-  apply_ctx_scrub_stats(ctx.get());
   simple_opc_submit(std::move(ctx));
 }
 
@@ -13012,7 +13002,7 @@ void ReplicatedPG::scrub_snapshot_metadata(
     ctx->mtime = utime_t();      // do not update mtime
     ctx->new_obs.oi.set_data_digest(p->second.first);
     ctx->new_obs.oi.set_omap_digest(p->second.second);
-    finish_ctx(ctx.get(), pg_log_entry_t::MODIFY, true, true);
+    finish_ctx(ctx.get(), pg_log_entry_t::MODIFY);
 
     ctx->register_on_success(
       [this]() {
@@ -13265,7 +13255,6 @@ boost::statechart::result ReplicatedPG::AwaitAsyncWork::react(const DoSnapWork&)
          pg->snap_trimmer_machine.process_event(RepopsComplete());
       });
 
-    pg->apply_ctx_scrub_stats(ctx.get());
     pg->simple_opc_submit(std::move(ctx));
   }
 
index bb9fbf3fdcae9ec80fcf74b158631d8714409bdd..cc2ac7d6fe1f018daf760fe524c8ed6cdba9b73d 100644 (file)
@@ -1097,15 +1097,11 @@ protected:
     const hobject_t& head, const hobject_t& coid,
     object_info_t *poi);
   void execute_ctx(OpContext *ctx);
-  void finish_ctx(OpContext *ctx, int log_op_type, bool maintain_ssc=true,
-                 bool scrub_ok=false);
+  void finish_ctx(OpContext *ctx, int log_op_type, bool maintain_ssc=true);
   void reply_ctx(OpContext *ctx, int err);
   void reply_ctx(OpContext *ctx, int err, eversion_t v, version_t uv);
   void make_writeable(OpContext *ctx);
   void log_op_stats(OpContext *ctx);
-  void apply_ctx_scrub_stats(
-    OpContext *ctx,
-    bool scrub_ok=false); ///< true if we should skip scrub stat update
 
   void write_update_size_and_usage(object_stat_sum_t& stats, object_info_t& oi,
                                   interval_set<uint64_t>& modified, uint64_t offset,