From 31a2ce25e6f09164e9ea3e974848f4e11fcc71d3 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 28 Jan 2010 10:33:04 -0800 Subject: [PATCH] finisher: fix flushing, debug output --- src/common/Finisher.cc | 29 ++++++++++++++++++++++------- src/common/Finisher.h | 5 +++-- src/config.cc | 1 + src/config.h | 1 + 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/common/Finisher.cc b/src/common/Finisher.cc index fb0f8e0fa1273..b184035a94561 100644 --- a/src/common/Finisher.cc +++ b/src/common/Finisher.cc @@ -2,6 +2,11 @@ #include "config.h" #include "Finisher.h" +#include "common/debug.h" +#define DOUT_SUBSYS finisher +#undef dout_prefix +#define dout_prefix *_dout << dbeginl << std::hex << pthread_self() << std::dec << " finisher(" << this << ") " + void Finisher::start() { finisher_thread.create(); @@ -19,15 +24,18 @@ void Finisher::stop() void Finisher::wait_for_empty() { finisher_lock.Lock(); - while (!finisher_queue.empty()) - finisher_cond.Wait(finisher_lock); + while (!finisher_queue.empty() || finisher_running) { + dout(10) << "wait_for_empty waiting" << dendl; + finisher_empty_cond.Wait(finisher_lock); + } + dout(10) << "wait_for_empty empty" << dendl; finisher_lock.Unlock(); } void *Finisher::finisher_thread_entry() { finisher_lock.Lock(); - //dout_generic(10) << "finisher_thread start" << dendl; + dout(10) << "finisher_thread start" << dendl; while (!finisher_stop) { while (!finisher_queue.empty()) { @@ -35,7 +43,9 @@ void *Finisher::finisher_thread_entry() list > ls_rval; ls.swap(finisher_queue); ls_rval.swap(finisher_queue_rval); + finisher_running = true; finisher_lock.Unlock(); + dout(10) << "finisher_thread doing " << ls << dendl; for (vector::iterator p = ls.begin(); p != ls.end(); @@ -51,18 +61,23 @@ void *Finisher::finisher_thread_entry() ls_rval.pop_front(); } } + dout(10) << "finisher_thread done with " << ls << dendl; ls.clear(); finisher_lock.Lock(); - finisher_empty_cond.Signal(); + finisher_running = false; } - if (finisher_stop) break; + dout(10) << "finisher_thread empty" << dendl; + finisher_empty_cond.Signal(); + if (finisher_stop) + break; - //dout_generic(30) << "finisher_thread sleeping" << dendl; + dout(10) << "finisher_thread sleeping" << dendl; finisher_cond.Wait(finisher_lock); } + finisher_empty_cond.Signal(); - //dout_generic(10) << "finisher_thread start" << dendl; + dout(10) << "finisher_thread stop" << dendl; finisher_lock.Unlock(); return 0; } diff --git a/src/common/Finisher.h b/src/common/Finisher.h index 94291b494dd9a..50d9f6123039f 100644 --- a/src/common/Finisher.h +++ b/src/common/Finisher.h @@ -22,7 +22,7 @@ class Finisher { Mutex finisher_lock; Cond finisher_cond, finisher_empty_cond; - bool finisher_stop; + bool finisher_stop, finisher_running; vector finisher_queue; list > finisher_queue_rval; @@ -65,7 +65,8 @@ class Finisher { void wait_for_empty(); - Finisher() : finisher_lock("Finisher::finisher_lock"), finisher_stop(false), finisher_thread(this) {} + Finisher() : finisher_lock("Finisher::finisher_lock"), + finisher_stop(false), finisher_running(false), finisher_thread(this) {} }; #endif diff --git a/src/config.cc b/src/config.cc index ac0cb2e72d4e7..43a09bcc63691 100644 --- a/src/config.cc +++ b/src/config.cc @@ -353,6 +353,7 @@ static struct config_option config_optionsp[] = { OPTION(debug_paxos, 0, OPT_INT, 0), OPTION(debug_tp, 0, OPT_INT, 0), OPTION(debug_auth, 0, OPT_INT, 1), + OPTION(debug_finisher, 0, OPT_INT, 1), OPTION(keys_file, 'k', OPT_STR, "~/.ceph/keyring.bin, /etc/ceph/keyring.bin, .ceph_keyring"), OPTION(supported_auth, 0, OPT_STR, "none"), OPTION(clock_lock, 0, OPT_BOOL, false), diff --git a/src/config.h b/src/config.h index e43ee18648dd1..7b1af1c84ea03 100644 --- a/src/config.h +++ b/src/config.h @@ -106,6 +106,7 @@ struct md_config_t { int debug_paxos; int debug_tp; int debug_auth; + int debug_finisher; // clock bool clock_lock; -- 2.39.5