From 868168a5fb5ccc7af62a3edca118c7f84a4aa32e Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Tue, 3 Jul 2012 08:53:54 -0700 Subject: [PATCH] OSD: clean up revcovery_wq queueing and ref counting Previously, we tended to explicitely remove the pg from the queue uisng remove_myself on the xlist::item. This causes us to drop a reference count. Manipulating the revovery_wq is now accomplished through the recovery_wq interface, which also handles pg ref counting. Signed-off-by: Samuel Just --- src/osd/OSD.cc | 12 ++++-------- src/osd/OSD.h | 7 +++++++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 388fd2aaa86eb..2c22674c1d783 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -4832,7 +4832,6 @@ void OSD::do_recovery(PG *pg) pg->lock(); if (pg->deleting || !(pg->is_active() && pg->is_primary())) { pg->unlock(); - pg->put(); return; } @@ -4860,7 +4859,7 @@ void OSD::do_recovery(PG *pg) if (!rctx.query_map->size()) { dout(10) << "do_recovery no luck, giving up on this pg for now" << dendl; recovery_wq.lock(); - pg->recovery_item.remove_myself(); // sigh... + recovery_wq._dequeue(pg); recovery_wq.unlock(); } } @@ -4870,7 +4869,6 @@ void OSD::do_recovery(PG *pg) pg->unlock(); dispatch_context(rctx, pg, curmap); } - pg->put(); } void OSD::start_recovery_op(PG *pg, const hobject_t& soid) @@ -4910,10 +4908,9 @@ void OSD::finish_recovery_op(PG *pg, const hobject_t& soid, bool dequeue) #endif if (dequeue) - pg->recovery_item.remove_myself(); + recovery_wq._dequeue(pg); else { - pg->get(); - recovery_queue.push_front(&pg->recovery_item); // requeue + recovery_wq._queue_front(pg); } recovery_wq.kick(); @@ -4926,8 +4923,7 @@ void OSD::defer_recovery(PG *pg) // move pg to the end of the queue... recovery_wq.lock(); - pg->get(); - recovery_queue.push_back(&pg->recovery_item); + recovery_wq._enqueue(pg); recovery_wq.kick(); recovery_wq.unlock(); } diff --git a/src/osd/OSD.h b/src/osd/OSD.h index cd9c2a5d8b008..7af558150eabc 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -980,8 +980,15 @@ protected: osd->recovery_queue.pop_front(); return pg; } + void _queue_front(PG *pg) { + if (!pg->recovery_item.is_on_list()) { + pg->get(); + osd->recovery_queue.push_front(&pg->recovery_item); + } + } void _process(PG *pg) { osd->do_recovery(pg); + pg->put(); } void _clear() { while (!osd->recovery_queue.empty()) { -- 2.39.5