]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd/cache/pwl: fix reorder issue between func process_writeback_dirty_entries
authorJianpeng Ma <jianpeng.ma@intel.com>
Mon, 8 Nov 2021 06:33:28 +0000 (14:33 +0800)
committerDeepika Upadhyay <dupadhya@redhat.com>
Sat, 13 Nov 2021 11:59:25 +0000 (17:29 +0530)
In fact, we not only make sure ops in order in func process_writeback_dirty_entries,
but also make sure ops in order between func process_writeback_dirty_entries.

Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
(cherry picked from commit 76f4d29d92be3f9f45767cb1ac6cc50da528ecec)

src/librbd/cache/pwl/AbstractWriteLog.cc
src/librbd/cache/pwl/AbstractWriteLog.h
src/librbd/cache/pwl/rwl/WriteLog.cc
src/librbd/cache/pwl/ssd/WriteLog.cc

index 5470be9a3b953b345af8ff0c4515120fae058532..5d63920ce18b1b155c4b6141213f7fef208e6593 100644 (file)
@@ -1638,6 +1638,7 @@ Context* AbstractWriteLog<I>::construct_flush_entry(std::shared_ptr<GenericLogEn
     m_lowest_flushing_sync_gen = log_entry->ram_entry.sync_gen_number;
   }
   m_flush_ops_in_flight += 1;
+  m_flush_ops_will_send += 1;
   /* For write same this is the bytes affected by the flush op, not the bytes transferred */
   m_flush_bytes_in_flight += log_entry->ram_entry.write_bytes;
 
@@ -1709,6 +1710,11 @@ void AbstractWriteLog<I>::process_writeback_dirty_entries() {
         all_clean = !m_flush_ops_in_flight;
         break;
       }
+
+      if (m_flush_ops_will_send) {
+       ldout(cct, 20) << "Previous flush-ops is still not sent" << dendl;
+       break;
+      }
       auto candidate = m_dirty_log_entries.front();
       bool flushable = can_flush_entry(candidate);
       if (flushable) {
index 88e6470f12f7b4cd284b9490a2b6d40343dfd1d3..887d77010bb45605d94e37da103ae86d9acebadc 100644 (file)
@@ -294,6 +294,7 @@ protected:
   std::atomic<int> m_async_flush_ops = {0};
   std::atomic<int> m_async_append_ops = {0};
 
+  std::atomic<int> m_flush_ops_will_send = {0};
   /* Acquire locks in order declared here */
 
   mutable ceph::mutex m_log_retire_lock;
index e22cb62da1b3eea5237a15da9c54a75982204907..25612197862e5a4745ac0b1c1f58847ce197b95d 100644 (file)
@@ -591,6 +591,7 @@ void WriteLog<I>::construct_flush_entries(pwl::GenericLogEntries entries_to_flus
              ldout(m_image_ctx.cct, 15) << "flushing:" << log_entry
                                         << " " << *log_entry << dendl;
              log_entry->writeback(this->m_image_writeback, ctx);
+             this->m_flush_ops_will_send -= 1;
            }), 0);
         });
    }
index 19576ccc254ac989b5841aad431465df5f28baf7..09bbc66d1ca4bbc5ab627817863ba084a23a66c7 100644 (file)
@@ -537,6 +537,7 @@ void WriteLog<I>::construct_flush_entries(pwl::GenericLogEntries entries_to_flus
              ldout(m_image_ctx.cct, 15) << "flushing:" << log_entry
                                          << " " << *log_entry << dendl;
              log_entry->writeback(this->m_image_writeback, ctx);
+             this->m_flush_ops_will_send -= 1;
            }), 0);
        });
       }
@@ -587,6 +588,7 @@ void WriteLog<I>::construct_flush_entries(pwl::GenericLogEntries entries_to_flus
                                           << " " << *log_entry << dendl;
                log_entry->writeback_bl(this->m_image_writeback, ctx,
                                        std::move(captured_entry_bl));
+               this->m_flush_ops_will_send -= 1;
              }), 0);
          } else {
              m_image_ctx.op_work_queue->queue(new LambdaContext(
@@ -594,6 +596,7 @@ void WriteLog<I>::construct_flush_entries(pwl::GenericLogEntries entries_to_flus
                  ldout(m_image_ctx.cct, 15) << "flushing:" << log_entry
                                              << " " << *log_entry << dendl;
                  log_entry->writeback(this->m_image_writeback, ctx);
+                 this->m_flush_ops_will_send -= 1;
                }), 0);
          }
        }