]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
journal: fix race between player shut down and cache rebalance 29796/head
authorMykola Golub <mgolub@suse.com>
Wed, 21 Aug 2019 14:04:47 +0000 (15:04 +0100)
committerMykola Golub <mgolub@suse.com>
Wed, 21 Aug 2019 14:18:54 +0000 (15:18 +0100)
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 <mgolub@suse.com>
src/journal/JournalPlayer.cc

index 02df4dfb7e98f07ed8f643d68a8b76f0a41ba7fc..9033c93f2fb704b82064fc9658629addd5228a98 100644 (file)
@@ -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;