]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd/cache/pwl: use m_bytes_allocated_cap for both rwl and ssd
authorIlya Dryomov <idryomov@gmail.com>
Wed, 28 Apr 2021 12:27:12 +0000 (14:27 +0200)
committerDeepika Upadhyay <dupadhya@redhat.com>
Tue, 2 Nov 2021 11:42:05 +0000 (17:12 +0530)
Follow rwl mode and use AbstractWriteLog::m_bytes_allocated_cap
instead of m_log_pool_ring_buffer_size specific to ssd.  This fixes
"bytes available" calculation in STATS output.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
(cherry picked from commit 27dd7f85aefecea83a424036ef84116aae5d1857)

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
src/librbd/cache/pwl/ssd/WriteLog.h

index 76e8e478e2bf7487907ba7e680b871133a1f9f2a..dceedc66c7e912a9331b5be9567838c9fea14743 100644 (file)
@@ -1460,7 +1460,7 @@ template <typename I>
 bool AbstractWriteLog<I>::check_allocation(C_BlockIORequestT *req,
       uint64_t &bytes_cached, uint64_t &bytes_dirtied, uint64_t &bytes_allocated,
       uint64_t &num_lanes, uint64_t &num_log_entries,
-      uint64_t &num_unpublished_reserves, uint64_t bytes_allocated_cap){
+      uint64_t &num_unpublished_reserves{
   bool alloc_succeeds = true;
   bool no_space = false;
   {
@@ -1484,11 +1484,11 @@ bool AbstractWriteLog<I>::check_allocation(C_BlockIORequestT *req,
       no_space = true; /* Entries must be retired */
     }
     /* Don't attempt buffer allocate if we've exceeded the "full" threshold */
-    if (m_bytes_allocated + bytes_allocated > bytes_allocated_cap) {
+    if (m_bytes_allocated + bytes_allocated > m_bytes_allocated_cap) {
       if (!req->has_io_waited_for_buffers()) {
         req->set_io_waited_for_buffers(true);
         ldout(m_image_ctx.cct, 1) << "Waiting for allocation cap (cap="
-                                  << bytes_allocated_cap
+                                  << m_bytes_allocated_cap
                                   << ", allocated=" << m_bytes_allocated
                                   << ") in write [" << *req << "]" << dendl;
       }
index 7b11542d65a8a827a366058d6b597a8ca98b3ac8..150a0242f41cbae0bcd8d9cf01462bbc4d172c15 100644 (file)
@@ -356,7 +356,7 @@ protected:
       uint64_t &bytes_cached, uint64_t &bytes_dirtied,
       uint64_t &bytes_allocated,
       uint64_t &num_lanes, uint64_t &num_log_entries,
-      uint64_t &num_unpublished_reserves, uint64_t bytes_allocated_cap);
+      uint64_t &num_unpublished_reserves);
   void append_scheduled(
       pwl::GenericLogOperations &ops, bool &ops_remain, bool &appending,
       bool isRWL=false);
index 0dba120f9310720a01978f9a04f1cd3728ddcb47..85979434ef0ab02e7eee3369cc4dfd152d648e68 100644 (file)
@@ -931,9 +931,9 @@ bool WriteLog<I>::alloc_resources(C_BlockIORequestT *req) {
   req->setup_buffer_resources(&bytes_cached, &bytes_dirtied, &bytes_allocated,
                               &num_lanes, &num_log_entries, &num_unpublished_reserves);
 
-  alloc_succeeds = this->check_allocation(req, bytes_cached, bytes_dirtied, bytes_allocated,
-                              num_lanes, num_log_entries, num_unpublished_reserves,
-                              this->m_bytes_allocated_cap);
+  alloc_succeeds = this->check_allocation(req, bytes_cached, bytes_dirtied,
+                                          bytes_allocated, num_lanes, num_log_entries,
+                                          num_unpublished_reserves);
 
   std::vector<WriteBufferAllocation>& buffers = req->get_resources_buffers();
   if (!alloc_succeeds) {
index 7b8a1968762e9a1d50f8f5a186f212edfecc086c..9c0e834a08fc703f861d29a7f24126b4669d7514 100644 (file)
@@ -139,7 +139,9 @@ void WriteLog<I>::initialize_pool(Context *on_finish,
       num_small_writes = MAX_LOG_ENTRIES;
     }
     assert(num_small_writes > 2);
-    m_log_pool_ring_buffer_size = this->m_log_pool_config_size - DATA_RING_BUFFER_OFFSET;
+    /* Size of ring buffer */
+    this->m_bytes_allocated_cap =
+        this->m_log_pool_config_size - DATA_RING_BUFFER_OFFSET;
     /* Log ring empty */
     m_first_free_entry = DATA_RING_BUFFER_OFFSET;
     m_first_valid_entry = DATA_RING_BUFFER_OFFSET;
@@ -302,8 +304,7 @@ bool WriteLog<I>::alloc_resources(C_BlockIORequestT *req) {
   alloc_succeeds = this->check_allocation(req, bytes_cached, bytes_dirtied,
                                           bytes_allocated, num_lanes,
                                           num_log_entries,
-                                          num_unpublished_reserves,
-                                          m_log_pool_ring_buffer_size);
+                                          num_unpublished_reserves);
   req->set_allocated(alloc_succeeds);
   return alloc_succeeds;
 }
@@ -533,9 +534,10 @@ void WriteLog<I>::process_work() {
   CephContext *cct = m_image_ctx.cct;
   int max_iterations = 4;
   bool wake_up_requested = false;
-  uint64_t aggressive_high_water_bytes = m_log_pool_ring_buffer_size * AGGRESSIVE_RETIRE_HIGH_WATER;
+  uint64_t aggressive_high_water_bytes =
+      this->m_bytes_allocated_cap * AGGRESSIVE_RETIRE_HIGH_WATER;
   uint64_t aggressive_high_water_entries = this->m_total_log_entries * AGGRESSIVE_RETIRE_HIGH_WATER;
-  uint64_t high_water_bytes = m_log_pool_ring_buffer_size * RETIRE_HIGH_WATER;
+  uint64_t high_water_bytes = this->m_bytes_allocated_cap * RETIRE_HIGH_WATER;
   uint64_t high_water_entries = this->m_total_log_entries * RETIRE_HIGH_WATER;
 
   ldout(cct, 20) << dendl;
index 64b4baa38bcdde49b1d1c768898f6af9540f1bde..2202aa609c6289208511da36923783c71c208fb5 100644 (file)
@@ -99,7 +99,6 @@ private:
   WriteLogPoolRootUpdateList m_poolroot_to_update; /* pool root list to update to SSD */
   bool m_updating_pool_root = false;
 
-  uint64_t m_log_pool_ring_buffer_size; /* Size of ring buffer */
   std::atomic<int> m_async_update_superblock = {0};
   BlockDevice *bdev = nullptr;
   uint64_t pool_size;