]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd/cache/pwl: set max size of continuous data
authorYin Congmin <congmin.yin@intel.com>
Mon, 8 Mar 2021 16:26:04 +0000 (00:26 +0800)
committerJason Dillaman <dillaman@redhat.com>
Thu, 18 Mar 2021 19:12:55 +0000 (15:12 -0400)
Signed-off-by: Yin Congmin <congmin.yin@intel.com>
(cherry picked from commit bcad92c126526be7ba249322ac3ead0d83b4d188)

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

index 640fead2e1891c19562fd4fa34a407612a97e0c7..b08d5df7962da9c51f6cd7c6737f6346c91a6834 100644 (file)
@@ -818,15 +818,44 @@ void AbstractWriteLog<I>::write(Extents &&image_extents,
 
   ceph_assert(m_initialized);
 
+  /* Split images because PMDK doesn't support allocating too big extent
+   * TODO: If the bluestore allocator is implemented as a library,
+   * the split operation is not necessary
+   */
+  Extents split_image_extents;
+  uint64_t max_extent_size = get_max_extent();
+  if (max_extent_size != 0) {
+    for (auto extent : image_extents) {
+      if (extent.second > max_extent_size) {
+        uint64_t off = extent.first;
+        uint64_t extent_bytes = extent.second;
+        for (int i = 0; extent_bytes != 0; ++i) {
+          Extent _ext;
+          _ext.first = off + i * max_extent_size;
+          _ext.second = std::min(max_extent_size, extent_bytes);
+          extent_bytes = extent_bytes - _ext.second ;
+          split_image_extents.emplace_back(_ext);
+        }
+      } else {
+        split_image_extents.emplace_back(extent);
+      }
+    }
+  } else {
+    split_image_extents = image_extents;
+  }
+
   C_WriteRequestT *write_req =
-    m_builder->create_write_request(*this, now, std::move(image_extents), std::move(bl),
-                                    fadvise_flags, m_lock, m_perfcounter, on_finish);
-  m_perfcounter->inc(l_librbd_pwl_wr_bytes, write_req->image_extents_summary.total_bytes);
+    m_builder->create_write_request(*this, now, std::move(split_image_extents),
+                                    std::move(bl), fadvise_flags, m_lock,
+                                    m_perfcounter, on_finish);
+  m_perfcounter->inc(l_librbd_pwl_wr_bytes,
+                      write_req->image_extents_summary.total_bytes);
 
   /* The lambda below will be called when the block guard for all
    * blocks affected by this write is obtained */
   GuardedRequestFunctionContext *guarded_ctx =
-    new GuardedRequestFunctionContext([this, write_req](GuardedRequestFunctionContext &guard_ctx) {
+    new GuardedRequestFunctionContext([this,
+      write_req](GuardedRequestFunctionContext &guard_ctx) {
       write_req->blockguard_acquired(guard_ctx);
       alloc_and_dispatch_io_req(write_req);
     });
index 29b6c3b9c7090e89ccc3fcb2e1cddfb07f05e89a..56ecd6c1c209111beee6bb702af15195a5dfe439 100644 (file)
@@ -393,6 +393,10 @@ protected:
       const std::shared_ptr<pwl::GenericLogEntry> log_entry) {
     return nullptr;
   }
+  virtual uint64_t get_max_extent() {
+    return 0;
+  }
+
 };
 
 } // namespace pwl
index e6d0e08a922fdc2b8b62f66a41555f45785cc3fe..5d438b2f11d0631e4eac219306b65ce525c9d822 100644 (file)
@@ -169,7 +169,7 @@ const uint32_t LOG_STATS_INTERVAL_SECONDS = 5;
 /**** Write log entries ****/
 const unsigned long int MAX_ALLOC_PER_TRANSACTION = 8;
 const unsigned long int MAX_FREE_PER_TRANSACTION = 1;
-const unsigned int MAX_CONCURRENT_WRITES = 256;
+const unsigned int MAX_CONCURRENT_WRITES = (1024 * 1024);
 
 const uint64_t DEFAULT_POOL_SIZE = 1u<<30;
 const uint64_t MIN_POOL_SIZE = DEFAULT_POOL_SIZE;
@@ -182,7 +182,7 @@ const double RETIRE_HIGH_WATER = 0.50;
 const double RETIRE_LOW_WATER = 0.40;
 const int RETIRE_BATCH_TIME_LIMIT_MS = 250;
 const uint64_t CONTROL_BLOCK_MAX_LOG_ENTRIES = 32;
-const uint64_t SPAN_MAX_DATA_LEN = (16*1024*1024);
+const uint64_t SPAN_MAX_DATA_LEN = (16 * 1024 * 1024);
 
 /* offset of ring on SSD */
 const uint64_t DATA_RING_BUFFER_OFFSET = 8192;
index dcdd9880aa89e5ede1315a70d845594c1f719037..7aea8573c917323b1e5a8aee4b13a0fbe9cfe370 100644 (file)
@@ -58,6 +58,7 @@ private:
   PMEMobjpool *m_log_pool = nullptr;
   Builder<This> *m_builderobj;
   const char* m_pwl_pool_layout_name;
+  const uint64_t MAX_EXTENT_SIZE = 1048576;
 
   Builder<This>* create_builder();
   void remove_pool_file();
@@ -106,6 +107,9 @@ protected:
   void write_data_to_buffer(
       std::shared_ptr<pwl::WriteLogEntry> ws_entry,
       pwl::WriteLogCacheEntry *pmem_entry) override;
+  uint64_t get_max_extent() override {
+    return MAX_EXTENT_SIZE;
+  }
 };
 
 } // namespace rwl