From 6ed01df412b4f4745c8f427a94446987c88b6bef Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sun, 22 Jul 2012 07:46:11 -0700 Subject: [PATCH] workqueue: kick -> wake or _wake, depending on locking Break kick() into wake() and _wake() methods, depending on whether the lock is already held. (The rename ensures that we audit/fix all callers.) Signed-off-by: Sage Weil Conflicts: src/common/WorkQueue.h src/osd/OSD.cc --- src/common/WorkQueue.h | 19 +++++++++++++++---- src/osd/OSD.cc | 8 ++++---- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/common/WorkQueue.h b/src/common/WorkQueue.h index b02ce75dcc21c..e55adb34e2cdb 100644 --- a/src/common/WorkQueue.h +++ b/src/common/WorkQueue.h @@ -99,8 +99,13 @@ public: void unlock() { pool->unlock(); } - void kick() { - pool->kick(); + /// wake up the thread pool (without lock held) + void wake() { + pool->wake(); + } + /// wake up the thread pool (with lock already held) + void _wake() { + pool->_wake(); } void drain() { pool->drain(this); @@ -182,8 +187,14 @@ public: void wait(Cond &c) { c.Wait(_lock); } - /// wake up a waiter - void kick() { + + /// wake up a waiter (with lock already held) + void _wake() { + _cond.Signal(); + } + /// wake up a waiter (without lock held) + void wake() { + Mutex::Locker l(_lock); _cond.Signal(); } diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index ac771244cf5f6..eb31edaf9a858 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -1941,7 +1941,7 @@ void OSD::tick() logger->set(l_osd_buf, buffer::get_total_alloc()); // periodically kick recovery work queue - recovery_tp.kick(); + recovery_tp.wake(); if (scrub_should_schedule()) { sched_scrub(); @@ -2631,7 +2631,7 @@ void OSD::do_command(Connection *con, tid_t tid, vector& cmd, bufferlist << "to " << g_conf->osd_recovery_delay_start; defer_recovery_until = ceph_clock_now(g_ceph_context); defer_recovery_until += g_conf->osd_recovery_delay_start; - recovery_wq.kick(); + recovery_wq.wake(); } } @@ -5309,7 +5309,7 @@ void OSD::finish_recovery_op(PG *pg, const hobject_t& soid, bool dequeue) recovery_queue.push_front(&pg->recovery_item); // requeue } - recovery_wq.kick(); + recovery_wq._wake(); recovery_wq.unlock(); } @@ -5321,7 +5321,7 @@ void OSD::defer_recovery(PG *pg) recovery_wq.lock(); pg->get(); recovery_queue.push_back(&pg->recovery_item); - recovery_wq.kick(); + recovery_wq._wake(); recovery_wq.unlock(); } -- 2.39.5