From a1a20041d57c9a90bc0a60d86469445ba8efb5ea Mon Sep 17 00:00:00 2001 From: Yin Congmin Date: Wed, 1 Sep 2021 15:56:18 +0000 Subject: [PATCH] librbd/cache/pwl: don't clear next_sync_point_entry prematurely In SyncPointLogOperation::clear_earlier_sync_point(), sync_point->log_entry->next_sync_point_entry was prematurely set to nullptr in clear_earlier_sync_point(). It is in write op stage, but next_sync_point_entry is used in writeback stage in handle_flushed_sync_point(). handle_flushed_sync_point() may pass a nullptr cause assert in m_work_queue.The solution is to move the statement that set next_sync_point_entry to nullptr after it is used. Fixes: https://tracker.ceph.com/issues/52465 Signed-off-by: Yin Congmin --- src/librbd/cache/pwl/AbstractWriteLog.cc | 4 ++-- src/librbd/cache/pwl/LogOperation.cc | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/librbd/cache/pwl/AbstractWriteLog.cc b/src/librbd/cache/pwl/AbstractWriteLog.cc index eca1e0836aa..ad9dfc0b442 100644 --- a/src/librbd/cache/pwl/AbstractWriteLog.cc +++ b/src/librbd/cache/pwl/AbstractWriteLog.cc @@ -1756,11 +1756,11 @@ bool AbstractWriteLog::handle_flushed_sync_point(std::shared_ptrnext_sync_point_entry)](int r) { bool handled_by_next; { std::lock_guard locker(m_lock); - handled_by_next = handle_flushed_sync_point(log_entry->next_sync_point_entry); + handled_by_next = handle_flushed_sync_point(std::move(next)); } if (!handled_by_next) { persist_last_flushed_sync_gen(); diff --git a/src/librbd/cache/pwl/LogOperation.cc b/src/librbd/cache/pwl/LogOperation.cc index ee90df41baa..24d949387bf 100644 --- a/src/librbd/cache/pwl/LogOperation.cc +++ b/src/librbd/cache/pwl/LogOperation.cc @@ -73,7 +73,6 @@ void SyncPointLogOperation::clear_earlier_sync_point() { ceph_assert(sync_point->later_sync_point->earlier_sync_point == sync_point); sync_point->later_sync_point->earlier_sync_point = nullptr; sync_point->later_sync_point = nullptr; - sync_point->log_entry->next_sync_point_entry = nullptr; } std::vector SyncPointLogOperation::swap_on_sync_point_persisted() { -- 2.39.5