From 8ac59239e3f386f766a05c49e5d90ec58f78f8f9 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 17 Aug 2015 15:09:47 -0400 Subject: [PATCH] os/ObjectStore: do not let Sequencer::flush_commit delete the context Let the caller manage the lifecycle; this allows us to potentially put it on the stack, for instance. Signed-off-by: Sage Weil --- src/os/FileStore.h | 1 - src/os/KeyValueStore.h | 1 - src/os/ObjectStore.h | 5 ++--- src/osd/PG.cc | 7 ++++--- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/os/FileStore.h b/src/os/FileStore.h index 3775fbac3c71d..710a1ad8c90d1 100644 --- a/src/os/FileStore.h +++ b/src/os/FileStore.h @@ -304,7 +304,6 @@ private: Mutex::Locker l(qlock); uint64_t seq = 0; if (_get_max_uncompleted(&seq)) { - delete c; return true; } else { flush_commit_waiters.push_back(make_pair(seq, c)); diff --git a/src/os/KeyValueStore.h b/src/os/KeyValueStore.h index 48135f142c3fd..a4a402837c4f9 100644 --- a/src/os/KeyValueStore.h +++ b/src/os/KeyValueStore.h @@ -407,7 +407,6 @@ class KeyValueStore : public ObjectStore, Mutex::Locker l(qlock); uint64_t seq = 0; if (_get_max_uncompleted(&seq)) { - delete c; return true; } else { flush_commit_waiters.push_back(make_pair(seq, c)); diff --git a/src/os/ObjectStore.h b/src/os/ObjectStore.h index 201ec30a083ee..5b72165360b12 100644 --- a/src/os/ObjectStore.h +++ b/src/os/ObjectStore.h @@ -144,8 +144,8 @@ public: * Async flush_commit * * There are two cases: - * 1) sequencer is currently idle: the method returns true and - * c is deleted + * 1) sequencer is currently idle: the method returns true. c is + * not touched. * 2) sequencer is not idle: the method returns false and c is * called asyncronously with a value of 0 once all transactions * queued on this sequencer prior to the call have been applied @@ -185,7 +185,6 @@ public: /// @see Sequencer_impl::flush_commit() bool flush_commit(Context *c) { if (!p) { - delete c; return true; } else { return p->flush_commit(c); diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 9eca0b1dd464e..23961f0df6100 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -4622,13 +4622,14 @@ void PG::reset_interval_flush() dout(10) << "Clearing blocked outgoing recovery messages" << dendl; recovery_state.clear_blocked_outgoing(); - if (!osr->flush_commit( - new QueuePeeringEvt( - this, get_osdmap()->get_epoch(), IntervalFlush()))) { + Context *c = new QueuePeeringEvt( + this, get_osdmap()->get_epoch(), IntervalFlush()); + if (!osr->flush_commit(c)) { dout(10) << "Beginning to block outgoing recovery messages" << dendl; recovery_state.begin_block_outgoing(); } else { dout(10) << "Not blocking outgoing recovery messages" << dendl; + delete c; } } -- 2.39.5