]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd/cache/pwl: don't clear next_sync_point_entry prematurely 43006/head
authorYin Congmin <congmin.yin@intel.com>
Wed, 1 Sep 2021 15:56:18 +0000 (15:56 +0000)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 6 Sep 2021 14:18:24 +0000 (16:18 +0200)
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 <congmin.yin@intel.com>
src/librbd/cache/pwl/AbstractWriteLog.cc
src/librbd/cache/pwl/LogOperation.cc

index eca1e0836aa9a54a212f52f5d904736ed5365038..ad9dfc0b442b4f1323f4981e7e2352215755fc61 100644 (file)
@@ -1756,11 +1756,11 @@ bool AbstractWriteLog<I>::handle_flushed_sync_point(std::shared_ptr<SyncPointLog
     }
     m_async_op_tracker.start_op();
     m_work_queue.queue(new LambdaContext(
-      [this, log_entry](int r) {
+      [this, next = std::move(log_entry->next_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();
index ee90df41baaee2e5637bea3d50e497c986c713b7..24d949387bf5d6b3ec93e6529ecc48945177faf9 100644 (file)
@@ -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<Context*> SyncPointLogOperation::swap_on_sync_point_persisted() {