]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
librbd: fix deadlock on RWL unit test
authorYuan Lu <yuan.y.lu@intel.com>
Wed, 3 Jun 2020 08:59:32 +0000 (16:59 +0800)
committerYuan Lu <yuan.y.lu@intel.com>
Wed, 3 Jun 2020 09:01:08 +0000 (17:01 +0800)
Signed-off-by: Yuan Lu <yuan.y.lu@intel.com>
src/librbd/cache/ReplicatedWriteLog.cc

index bc12af60dfa560f98ad946987a39375e371d56d3..a2c62bc43bdee2a3770cf14097b69bef51abc117 100644 (file)
@@ -796,42 +796,38 @@ void ReplicatedWriteLog<I>::shut_down(Context *on_finish) {
       }
       update_image_cache_state(next_ctx);
     });
-  if (m_first_free_entry == m_first_valid_entry) { //if the log entries are free.
-    m_image_ctx.op_work_queue->queue(ctx, 0);
-  } else {
-    ctx = new LambdaContext(
-      [this, ctx](int r) {
-        Context *next_ctx = override_ctx(r, ctx);
-        {
-          /* Sync with process_writeback_dirty_entries() */
-          RWLock::WLocker entry_reader_wlocker(m_entry_reader_lock);
-          m_shutting_down = true;
-          /* Flush all writes to OSDs (unless disabled) and wait for all
-             in-progress flush writes to complete */
-          ldout(m_image_ctx.cct, 6) << "flushing" << dendl;
-          if (m_periodic_stats_enabled) {
-            periodic_stats();
-          }
+  ctx = new LambdaContext(
+    [this, ctx](int r) {
+      Context *next_ctx = override_ctx(r, ctx);
+      {
+        /* Sync with process_writeback_dirty_entries() */
+        RWLock::WLocker entry_reader_wlocker(m_entry_reader_lock);
+        m_shutting_down = true;
+        /* Flush all writes to OSDs (unless disabled) and wait for all
+           in-progress flush writes to complete */
+        ldout(m_image_ctx.cct, 6) << "flushing" << dendl;
+        if (m_periodic_stats_enabled) {
+          periodic_stats();
         }
-        flush_dirty_entries(next_ctx);
-      });
-    ctx = new LambdaContext(
-      [this, ctx](int r) {
-        Context *next_ctx = override_ctx(r, ctx);
-        ldout(m_image_ctx.cct, 6) << "waiting for in flight operations" << dendl;
-        // Wait for in progress IOs to complete
-        next_ctx = util::create_async_context_callback(m_image_ctx, next_ctx);
-        m_async_op_tracker.wait_for_ops(next_ctx);
-      });
-    ctx = new LambdaContext(
-      [this, ctx](int r) {
-        ldout(m_image_ctx.cct, 6) << "Done internal_flush in shutdown" << dendl;
-        m_work_queue.queue(ctx, r);
-      });
-    /* Complete all in-flight writes before shutting down */
-    ldout(m_image_ctx.cct, 6) << "internal_flush in shutdown" << dendl;
-    internal_flush(false, ctx);
-  }
+      }
+      flush_dirty_entries(next_ctx);
+    });
+  ctx = new LambdaContext(
+    [this, ctx](int r) {
+      Context *next_ctx = override_ctx(r, ctx);
+      ldout(m_image_ctx.cct, 6) << "waiting for in flight operations" << dendl;
+      // Wait for in progress IOs to complete
+      next_ctx = util::create_async_context_callback(m_image_ctx, next_ctx);
+      m_async_op_tracker.wait_for_ops(next_ctx);
+    });
+  ctx = new LambdaContext(
+    [this, ctx](int r) {
+      ldout(m_image_ctx.cct, 6) << "Done internal_flush in shutdown" << dendl;
+      m_work_queue.queue(ctx, r);
+    });
+  /* Complete all in-flight writes before shutting down */
+  ldout(m_image_ctx.cct, 6) << "internal_flush in shutdown" << dendl;
+  internal_flush(false, ctx);
 }
 
 template <typename I>