From: Yin Congmin Date: Mon, 8 Mar 2021 16:26:04 +0000 (+0800) Subject: librbd/cache/pwl: set max size of continuous data X-Git-Tag: v16.2.0~92^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d34cb367742bc4c86197fd9293924ae001b61aaa;p=ceph.git librbd/cache/pwl: set max size of continuous data Signed-off-by: Yin Congmin (cherry picked from commit bcad92c126526be7ba249322ac3ead0d83b4d188) --- diff --git a/src/librbd/cache/pwl/AbstractWriteLog.cc b/src/librbd/cache/pwl/AbstractWriteLog.cc index 640fead2e189..b08d5df7962d 100644 --- a/src/librbd/cache/pwl/AbstractWriteLog.cc +++ b/src/librbd/cache/pwl/AbstractWriteLog.cc @@ -818,15 +818,44 @@ void AbstractWriteLog::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); }); diff --git a/src/librbd/cache/pwl/AbstractWriteLog.h b/src/librbd/cache/pwl/AbstractWriteLog.h index 29b6c3b9c709..56ecd6c1c209 100644 --- a/src/librbd/cache/pwl/AbstractWriteLog.h +++ b/src/librbd/cache/pwl/AbstractWriteLog.h @@ -393,6 +393,10 @@ protected: const std::shared_ptr log_entry) { return nullptr; } + virtual uint64_t get_max_extent() { + return 0; + } + }; } // namespace pwl diff --git a/src/librbd/cache/pwl/Types.h b/src/librbd/cache/pwl/Types.h index e6d0e08a922f..5d438b2f11d0 100644 --- a/src/librbd/cache/pwl/Types.h +++ b/src/librbd/cache/pwl/Types.h @@ -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; diff --git a/src/librbd/cache/pwl/rwl/WriteLog.h b/src/librbd/cache/pwl/rwl/WriteLog.h index dcdd9880aa89..7aea8573c917 100644 --- a/src/librbd/cache/pwl/rwl/WriteLog.h +++ b/src/librbd/cache/pwl/rwl/WriteLog.h @@ -58,6 +58,7 @@ private: PMEMobjpool *m_log_pool = nullptr; Builder *m_builderobj; const char* m_pwl_pool_layout_name; + const uint64_t MAX_EXTENT_SIZE = 1048576; Builder* create_builder(); void remove_pool_file(); @@ -106,6 +107,9 @@ protected: void write_data_to_buffer( std::shared_ptr ws_entry, pwl::WriteLogCacheEntry *pmem_entry) override; + uint64_t get_max_extent() override { + return MAX_EXTENT_SIZE; + } }; } // namespace rwl