From 09af670b1d2b3f8f06647f2f73c799aca86d6ea5 Mon Sep 17 00:00:00 2001
From: Samuel Just <sam.just@inktank.com>
Date: Thu, 5 Jul 2012 15:39:24 -0700
Subject: [PATCH] PG,ReplicatedPG: on_removal must handle repop and watcher
 state

on_removal is now in ReplicatedPG in order to handle watcher state
and repop state.  Addionally, workqueue dequeues are handled already
in OSD::_remove_pg.

Signed-off-by: Samuel Just <sam.just@inktank.com>
---
 src/osd/PG.cc           | 12 ------------
 src/osd/PG.h            |  2 +-
 src/osd/ReplicatedPG.cc |  7 +++++++
 src/osd/ReplicatedPG.h  |  1 +
 4 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/src/osd/PG.cc b/src/osd/PG.cc
index 1762f32fe53..1d22a11c366 100644
--- a/src/osd/PG.cc
+++ b/src/osd/PG.cc
@@ -3682,18 +3682,6 @@ bool PG::old_peering_msg(epoch_t reply_epoch, epoch_t query_epoch)
   return false;
 }
 
-
-void PG::on_removal()
-{
-  osd->recovery_wq.dequeue(this);
-  osd->scrub_wq.dequeue(this);
-  osd->scrub_finalize_wq.dequeue(this);
-  osd->snap_trim_wq.dequeue(this);
-  osd->pg_stat_queue_dequeue(this);
-
-  remove_watchers_and_notifies();
-}
-
 void PG::set_last_peering_reset()
 {
   dout(20) << "set_last_peering_reset " << get_osdmap()->get_epoch() << dendl;
diff --git a/src/osd/PG.h b/src/osd/PG.h
index 3248a4009c4..ab7b90f892e 100644
--- a/src/osd/PG.h
+++ b/src/osd/PG.h
@@ -1498,7 +1498,7 @@ public:
   void handle_loaded(RecoveryCtx *rctx);
   void handle_query_state(Formatter *f);
 
-  void on_removal();
+  virtual void on_removal();
 
 
   // abstract bits
diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc
index 91249b5a939..17128a76bf1 100644
--- a/src/osd/ReplicatedPG.cc
+++ b/src/osd/ReplicatedPG.cc
@@ -5692,6 +5692,13 @@ void ReplicatedPG::apply_and_flush_repops(bool requeue)
   }
 }
 
+void ReplicatedPG::on_removal()
+{
+  dout(10) << "on_removal" << dendl;
+  apply_and_flush_repops(false);
+  remove_watchers_and_notifies();
+}
+
 void ReplicatedPG::on_shutdown()
 {
   dout(10) << "on_shutdown" << dendl;
diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h
index a3876a851dd..da85a6b9242 100644
--- a/src/osd/ReplicatedPG.h
+++ b/src/osd/ReplicatedPG.h
@@ -913,6 +913,7 @@ public:
   void on_role_change();
   void on_change();
   void on_activate();
+  void on_removal();
   void on_shutdown();
 };