]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: stray pg ref on shutdown 1356/head
authorDavid Zafman <david.zafman@inktank.com>
Thu, 27 Feb 2014 23:27:56 +0000 (15:27 -0800)
committerDavid Zafman <david.zafman@inktank.com>
Fri, 28 Feb 2014 19:12:39 +0000 (11:12 -0800)
Move agent_clear() from only being done when becoming replica
  Do it in clear_primary_state() whenever we stop being primary
  clear_primary_state() passed whether we are staying a primary
Add asserts in agent_stop() and don't need to clear agent_queue

Fixes: #7458
Signed-off-by: David Zafman <david.zafman@inktank.com>
src/osd/OSD.cc
src/osd/PG.cc
src/osd/PG.h
src/osd/ReplicatedPG.cc

index d3d14f96f62fe16269ac9493dfd55e52d87ae643..66c6fc4df596b47034534703a9a675d310031c66 100644 (file)
@@ -511,12 +511,16 @@ void OSDService::agent_stop()
 {
   {
     Mutex::Locker l(agent_lock);
+
+    // By this time all ops should be cancelled
+    assert(agent_ops == 0);
+    // By this time all PGs are shutdown and dequeued
+    assert(agent_queue.empty());
+
     agent_stop_flag = true;
     agent_cond.Signal();
   }
   agent_thread.join();
-
-  agent_queue.clear();
 }
 
 
index a525b7195299c0a57695723a7dbb2f5f79796e44..ef7d812b1f4ff79510c2ebed633e2511639160f8 100644 (file)
@@ -794,7 +794,7 @@ void PG::build_prior(std::auto_ptr<PriorSet> &prior_set)
   set_probe_targets(prior_set->probe);
 }
 
-void PG::clear_primary_state()
+void PG::clear_primary_state(bool staying_primary)
 {
   dout(10) << "clear_primary_state" << dendl;
 
@@ -827,6 +827,9 @@ void PG::clear_primary_state()
 
   osd->recovery_wq.dequeue(this);
   osd->snap_trim_wq.dequeue(this);
+
+  if (!staying_primary)
+    agent_clear();
 }
 
 /**
@@ -4730,7 +4733,7 @@ void PG::start_peering_interval(
 
   // reset primary state?
   if (was_old_primary || is_primary())
-    clear_primary_state();
+    clear_primary_state(was_old_primary && is_primary());
 
     
   // pg->on_*
@@ -6403,8 +6406,6 @@ PG::RecoveryState::ReplicaActive::ReplicaActive(my_context ctx)
     context< RecoveryMachine >().get_cur_transaction(),
     context< RecoveryMachine >().get_on_applied_context_list(),
     context< RecoveryMachine >().get_on_safe_context_list());
-
-  pg->agent_clear();
 }
 
 
index df189fa317a1b80b077a36ee22ecc77633ea147f..003f43b53bc7604097295e982b329cf221990d9a 100644 (file)
@@ -675,7 +675,7 @@ protected:
   void clear_publish_stats();
 
 public:
-  void clear_primary_state();
+  void clear_primary_state(bool stay_primary);
 
  public:
   bool is_actingbackfill(pg_shard_t osd) const {
index 32171c3ba4bbf6ca9e60460f42d8957b7da50883..5109ed116ed84446de30b3d9cc2ef05058cfbaa9 100644 (file)
@@ -8876,7 +8876,7 @@ void ReplicatedPG::on_shutdown()
   osd->remote_reserver.cancel_reservation(info.pgid);
   osd->local_reserver.cancel_reservation(info.pgid);
 
-  clear_primary_state();
+  clear_primary_state(false);  // Not staying primary
   osd->remove_want_pg_temp(info.pgid.pgid);
   cancel_recovery();
 }
@@ -10464,6 +10464,8 @@ void ReplicatedPG::agent_work(int start_max)
     return;
   }
 
+  assert(!deleting);
+
   if (agent_state->is_idle()) {
     dout(10) << __func__ << " idle, stopping" << dendl;
     unlock();