]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd/cache/pwl: don't clear next_sync_point_entry prematurely
authorYin Congmin <congmin.yin@intel.com>
Wed, 1 Sep 2021 15:56:18 +0000 (15:56 +0000)
committerDeepika Upadhyay <dupadhya@redhat.com>
Fri, 5 Nov 2021 09:22:02 +0000 (14:52 +0530)
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>
(cherry picked from commit a1a20041d57c9a90bc0a60d86469445ba8efb5ea)

src/librbd/cache/pwl/AbstractWriteLog.cc
src/librbd/cache/pwl/LogOperation.cc

index 40b7fcb7daf3ff93a360aa13279a433fbdfea118..89527c3f0a468a7f0d68711b91b6fd2b60daecfc 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 54da5a2e002d65212020cfedd642dbf74cba53c8..4fc13a91a23f2d8debe40bb05e234c813db3740e 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() {