]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
osd/: rephrase [un]reg_next_scrub as on_info_history_change
authorsjust@redhat.com <sjust@redhat.com>
Wed, 27 Mar 2019 23:13:23 +0000 (16:13 -0700)
committersjust@redhat.com <sjust@redhat.com>
Wed, 1 May 2019 18:22:14 +0000 (11:22 -0700)
As PeeringState won't be as careful about usage of
on_info_history_change, add a scrub_registered flag
to protect against double-(un)registers.

Signed-off-by: sjust@redhat.com <sjust@redhat.com>
src/osd/PG.cc
src/osd/PG.h
src/osd/PeeringState.cc
src/osd/PeeringState.h

index 98d6a546e7a28c6c0fa8389baa3906563a86be2b..f6f46361035660c30c64f37ab2074c1582264c3e 100644 (file)
@@ -4028,16 +4028,33 @@ void PG::reg_next_scrub()
                                               must);
   dout(10) << __func__ << " pg " << pg_id << " register next scrub, scrub time "
       << scrubber.scrub_reg_stamp << ", must = " << (int)must << dendl;
+  scrub_registered = true;
 }
 
 void PG::unreg_next_scrub()
 {
-  if (is_primary()) {
+  if (scrub_registered) {
     osd->unreg_pg_scrub(info.pgid, scrubber.scrub_reg_stamp);
     scrubber.scrub_reg_stamp = utime_t();
+    scrub_registered = false;
   }
 }
 
+void PG::on_info_history_change()
+{
+  unreg_next_scrub();
+  reg_next_scrub();
+}
+
+void PG::scrub_requested(bool deep, bool repair)
+{
+  unreg_next_scrub();
+  scrubber.must_scrub = true;
+  scrubber.must_deep_scrub = deep || repair;
+  scrubber.must_repair = repair;
+  reg_next_scrub();
+}
+
 void PG::clear_ready_to_merge() {
   osd->clear_ready_to_merge(this);
 }
index 003050f07319ae68dd707fe42091ca7a1fd6e0ea..e5853066a35efe3a5910bd91728ed94b7f81f4ee 100644 (file)
@@ -403,8 +403,8 @@ public:
 
   void scrub(epoch_t queued, ThreadPool::TPHandle &handle);
 
-  void reg_next_scrub() override;
-  void unreg_next_scrub() override;
+  void reg_next_scrub();
+  void unreg_next_scrub();
 
   void clear_ready_to_merge() override;
 
@@ -420,6 +420,9 @@ public:
   void on_pool_change() override;
   virtual void plpg_on_pool_change() = 0;
 
+  void on_info_history_change() override;
+
+  void scrub_requested(bool deep, bool repair) override;
 
   void clear_publish_stats() override;
   void clear_primary_state() override;
@@ -617,6 +620,7 @@ protected:
   /* You should not use these items without taking their respective queue locks
    * (if they have one) */
   xlist<PG*>::item stat_queue_item;
+  bool scrub_registered = false;
   bool scrub_queued;
   bool recovery_queued;
 
index 0f035a401396961793cf11ae36e8633c2b4427c9..2f4f0b21bac3b13d3a351b07929cccca2880ec8d 100644 (file)
@@ -168,7 +168,6 @@ void PeeringState::check_recovery_sources(const OSDMapRef& osdmap)
 
 void PeeringState::update_history(const pg_history_t& new_history)
 {
-  pl->unreg_next_scrub();
   if (info.history.merge(new_history)) {
     psdout(20) << __func__ << " advanced history from " << new_history << dendl;
     dirty_info = true;
@@ -178,7 +177,7 @@ void PeeringState::update_history(const pg_history_t& new_history)
       dirty_big_info = true;
     }
   }
-  pl->reg_next_scrub();
+  pl->on_info_history_change();
 }
 
 void PeeringState::purge_strays()
@@ -470,7 +469,6 @@ void PeeringState::start_peering_interval(
   vector<int> oldacting, oldup;
   int oldrole = get_role();
 
-  pl->unreg_next_scrub();
   if (is_primary()) {
     pl->clear_ready_to_merge();
   }
@@ -573,7 +571,7 @@ void PeeringState::start_peering_interval(
   }
 
   pl->on_new_interval();
-  pl->reg_next_scrub();
+  pl->on_info_history_change();
 
   psdout(1) << __func__ << " up " << oldup << " -> " << up
            << ", acting " << oldacting << " -> " << acting
@@ -1082,14 +1080,11 @@ boost::statechart::result PeeringState::Primary::react(
 boost::statechart::result PeeringState::Primary::react(
   const RequestScrub& evt)
 {
-  PG *pg = context< PeeringMachine >().pg;
-  if (pg->is_primary()) {
-    pg->unreg_next_scrub();
-    pg->scrubber.must_scrub = true;
-    pg->scrubber.must_deep_scrub = evt.deep || evt.repair;
-    pg->scrubber.must_repair = evt.repair;
-    pg->reg_next_scrub();
-    ldout(pg->cct,10) << "marking for scrub" << dendl;
+  PeeringListener *pl = context< PeeringMachine >().pl;
+  PeeringState *ps = context< PeeringMachine >().state;
+  if (ps->is_primary()) {
+    pl->scrub_requested(evt.deep, evt.repair);
+    psdout(10) << "marking for scrub" << dendl;
   }
   return discard_event();
 }
@@ -2685,9 +2680,8 @@ boost::statechart::result PeeringState::Stray::react(const MLogRec& logevt)
   ObjectStore::Transaction* t = context<PeeringMachine>().get_cur_transaction();
   if (msg->info.last_backfill == hobject_t()) {
     // restart backfill
-    pg->unreg_next_scrub();
     pg->info = msg->info;
-    pg->reg_next_scrub();
+    pg->on_info_history_change();
     pg->dirty_info = true;
     pg->dirty_big_info = true;  // maybe.
 
index 249ac29553b059a589ee2ff7d594c0d1c45a2a26..7c78db7aab32eca36d20d65de063f8feee9a0df0 100644 (file)
@@ -66,8 +66,8 @@ public:
       ObjectStore::Transaction &t) = 0;
     virtual void update_heartbeat_peers(set<int> peers) = 0;
 
-    virtual void reg_next_scrub() = 0;
-    virtual void unreg_next_scrub() = 0;
+    virtual void on_info_history_change() = 0;
+    virtual void scrub_requested(bool deep, bool repair) = 0;
 
     virtual void send_cluster_message(int osd, Message *m, epoch_t epoch) = 0;