From 3796c4ab8fd55bd37b84a7af0e33cf19fe4d8688 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sat, 11 Feb 2012 21:47:42 -0800 Subject: [PATCH] osd: flush pg on activate _after_ we queue our transaction We recently added a flush on activate, but we are still building the transaction (the caller queues it), so calling osr.flush() here is totally useless. Instead, set a flag 'need_flush', and do the flush the next time we receive some work. This has the added benefit of doing the flush in the worker thread, outside of osd_lock. Signed-off-by: Sage Weil --- src/osd/PG.cc | 16 +++++++++++++--- src/osd/PG.h | 4 ++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/osd/PG.cc b/src/osd/PG.cc index c66b4d121a3e9..132aaa168440b 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -1367,9 +1367,8 @@ void PG::activate(ObjectStore::Transaction& t, list& tfin, update_stats(); } - // flush this all out (e.g., deletions from clean_up_local) to avoid - // subsequent races. - osr.flush(); + // we need to flush this all out before doing anything else.. + need_flush = true; // waiters if (!is_replay()) { @@ -1379,6 +1378,17 @@ void PG::activate(ObjectStore::Transaction& t, list& tfin, on_activate(); } +void PG::do_pending_flush() +{ + assert(is_locked()); + if (need_flush) { + dout(10) << "do_pending_flush doing pending flush" << dendl; + osr.flush(); + need_flush = false; + dout(10) << "do_pending_flush done" << dendl; + } +} + void PG::do_request(OpRequest *op) { // do any pending flush diff --git a/src/osd/PG.h b/src/osd/PG.h index 582dab6f5bac7..a8976991732c1 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -558,6 +558,7 @@ protected: // primary-only, recovery-only state set might_have_unfound; // These osds might have objects on them // which are unfound on the primary + bool need_flush; // need to flush before any new activity epoch_t last_peering_reset; @@ -1236,6 +1237,7 @@ public: role(0), state(0), need_up_thru(false), + need_flush(false), last_peering_reset(0), backfill_target(-1), pg_stats_lock("PG::pg_stats_lock"), @@ -1293,6 +1295,8 @@ public: bool is_empty() const { return info.last_update == eversion_t(0,0); } // pg on-disk state + void do_pending_flush(); + void write_info(ObjectStore::Transaction& t); void write_log(ObjectStore::Transaction& t); -- 2.39.5