From: Yuan Lu Date: Wed, 3 Jun 2020 08:59:32 +0000 (+0800) Subject: librbd: fix deadlock on RWL unit test X-Git-Tag: v16.1.0~2092^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F35357%2Fhead;p=ceph.git librbd: fix deadlock on RWL unit test Signed-off-by: Yuan Lu --- diff --git a/src/librbd/cache/ReplicatedWriteLog.cc b/src/librbd/cache/ReplicatedWriteLog.cc index bc12af60dfa..a2c62bc43bd 100644 --- a/src/librbd/cache/ReplicatedWriteLog.cc +++ b/src/librbd/cache/ReplicatedWriteLog.cc @@ -796,42 +796,38 @@ void ReplicatedWriteLog::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