From: Mykola Golub Date: Wed, 21 Aug 2019 14:04:47 +0000 (+0100) Subject: journal: fix race between player shut down and cache rebalance X-Git-Tag: v15.1.0~1785^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=adf1715d9523e98a29923a620df8b854b50ae54e;p=ceph.git journal: fix race between player shut down and cache rebalance 25a23364 was supposed to fix this race, but it was not enough: there was still a window between `prefetch` is queued for execution in handle_cache_rebalanced and is actually executed, during which shut_down can be called and completed. Signed-off-by: Mykola Golub --- diff --git a/src/journal/JournalPlayer.cc b/src/journal/JournalPlayer.cc index 02df4dfb7e98..9033c93f2fb7 100644 --- a/src/journal/JournalPlayer.cc +++ b/src/journal/JournalPlayer.cc @@ -120,6 +120,10 @@ void JournalPlayer::prefetch() { std::lock_guard locker{m_lock}; ceph_assert(m_state == STATE_INIT); + if (m_shut_down) { + return; + } + if (m_cache_manager_handler != nullptr && m_max_fetch_bytes == 0) { m_state = STATE_WAITCACHE; return; @@ -851,9 +855,11 @@ void JournalPlayer::handle_cache_rebalanced(uint64_t new_cache_bytes) { if (m_state == STATE_WAITCACHE) { m_state = STATE_INIT; if (m_max_fetch_bytes >= min_bytes) { + m_async_op_tracker.start_op(); auto ctx = new FunctionContext( [this](int r) { prefetch(); + m_async_op_tracker.finish_op(); }); m_journal_metadata->queue(ctx, 0); return;