From 9b18e55e86a18de6ff91a42984ba9ba35d3bdd4f Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Tue, 11 Oct 2011 08:33:32 -0700 Subject: [PATCH] PG,OSD: clean up xlist::items on pg removal Should take care of #1599. Signed-off-by: Samuel Just --- src/osd/OSD.cc | 6 +++--- src/osd/OSD.h | 4 +++- src/osd/PG.cc | 14 ++++++++++++++ src/osd/PG.h | 2 +- src/osd/ReplicatedPG.cc | 2 ++ 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 53c38a50d4724..780936ddf43bd 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -4664,11 +4664,11 @@ void OSD::_remove_pg(PG *pg) } - // remove_watchers_and_notifies and the erasure from the pg_map - // must be done together without unlocking the pg lock, + // on_removal, which calls remove_watchers_and_notifies, and the erasure from + // the pg_map must be done together without unlocking the pg lock, // to avoid racing with watcher cleanup in ms_handle_reset // and handle_notify_timeout - pg->remove_watchers_and_notifies(); + pg->on_removal(); // remove from map pg_map.erase(pgid); diff --git a/src/osd/OSD.h b/src/osd/OSD.h index 9cdcfe1cce432..2b9d1a7d93ac7 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -741,11 +741,13 @@ protected: bool _enqueue(PG *pg) { if (pg->snap_trim_item.is_on_list()) return false; + pg->get(); osd->snap_trim_queue.push_back(&pg->snap_trim_item); return true; } void _dequeue(PG *pg) { - pg->snap_trim_item.remove_myself(); + if (pg->snap_trim_item.remove_myself()) + pg->put(); } PG *_dequeue() { if (osd->snap_trim_queue.empty()) diff --git a/src/osd/PG.cc b/src/osd/PG.cc index da09cb64948ab..b538606170342 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -3540,6 +3540,20 @@ bool PG::old_peering_msg(epoch_t reply_epoch, last_peering_reset > query_epoch); } + +void PG::on_removal() +{ + osd->recovery_wq.dequeue(this); + osd->backlog_wq.dequeue(this); + osd->scrub_wq.dequeue(this); + osd->scrub_finalize_wq.dequeue(this); + osd->snap_trim_wq.dequeue(this); + osd->remove_wq.dequeue(this); + osd->pg_stat_queue_dequeue(this); + + remove_watchers_and_notifies(); +} + void PG::set_last_peering_reset() { last_peering_reset = osd->osdmap->get_epoch(); } diff --git a/src/osd/PG.h b/src/osd/PG.h index b346cda2eade9..f57145a1cf7f2 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -1645,7 +1645,7 @@ public: recovery_state.handle_loaded(rctx); } - + void on_removal(); // abstract bits virtual void do_op(MOSDOp *op) = 0; virtual void do_sub_op(MOSDSubOp *op) = 0; diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 57c7032580d80..8df429ed6687c 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -990,6 +990,7 @@ bool ReplicatedPG::snap_trimmer() dout(10) << " can't write, requeueing" << dendl; queue_snap_trim(); unlock(); + put(); return true; } if (!finalizing_scrub) { @@ -1016,6 +1017,7 @@ bool ReplicatedPG::snap_trimmer() queue_snap_trim(); } unlock(); + put(); return true; } -- 2.39.5