From aa81db8392fdcea2ae4122825372ae094da12270 Mon Sep 17 00:00:00 2001 From: Mahati Chamarthy Date: Wed, 2 Sep 2020 15:23:06 +0530 Subject: [PATCH] librbd/cache: Rename namespaces and move files Signed-off-by: Lisa Li Signed-off-by: Mahati Chamarthy Signed-off-by: Changcheng Liu --- src/common/subsys.h | 2 +- src/librbd/CMakeLists.txt | 24 +- src/librbd/ExclusiveLock.cc | 2 +- src/librbd/cache/Utils.h | 2 +- src/librbd/cache/WriteLogCache.cc | 12 +- src/librbd/cache/WriteLogCache.h | 13 +- .../cache/{ => pwl}/AbstractWriteLog.cc | 232 +++++++++--------- src/librbd/cache/{ => pwl}/AbstractWriteLog.h | 107 ++++---- .../cache/{rwl => pwl}/ImageCacheState.cc | 28 +-- .../cache/{rwl => pwl}/ImageCacheState.h | 6 +- src/librbd/cache/{rwl => pwl}/InitRequest.cc | 14 +- src/librbd/cache/{rwl => pwl}/InitRequest.h | 8 +- src/librbd/cache/{rwl => pwl}/LogEntry.cc | 8 +- src/librbd/cache/{rwl => pwl}/LogEntry.h | 10 +- src/librbd/cache/{rwl => pwl}/LogMap.cc | 14 +- src/librbd/cache/{rwl => pwl}/LogMap.h | 4 +- src/librbd/cache/{rwl => pwl}/LogOperation.cc | 22 +- src/librbd/cache/{rwl => pwl}/LogOperation.h | 8 +- src/librbd/cache/{rwl => pwl}/ReadRequest.cc | 20 +- src/librbd/cache/{rwl => pwl}/ReadRequest.h | 8 +- .../cache/{ => pwl}/ReplicatedWriteLog.cc | 34 +-- .../cache/{ => pwl}/ReplicatedWriteLog.h | 25 +- src/librbd/cache/{rwl => pwl}/Request.cc | 190 +++++++------- src/librbd/cache/{rwl => pwl}/Request.h | 34 +-- .../cache/{rwl => pwl}/ShutdownRequest.cc | 12 +- .../cache/{rwl => pwl}/ShutdownRequest.h | 6 +- src/librbd/cache/{rwl => pwl}/SyncPoint.cc | 8 +- src/librbd/cache/{rwl => pwl}/SyncPoint.h | 8 +- src/librbd/cache/{rwl => pwl}/Types.cc | 10 +- src/librbd/cache/{rwl => pwl}/Types.h | 160 ++++++------ .../exclusive_lock/PostAcquireRequest.cc | 8 +- .../exclusive_lock/PreReleaseRequest.cc | 4 +- src/test/librbd/CMakeLists.txt | 2 +- .../cache/{rwl => pwl}/test_WriteLogMap.cc | 6 +- .../cache/test_mock_ReplicatedWriteLog.cc | 14 +- .../test_mock_PostAcquireRequest.cc | 12 +- .../test_mock_PreReleaseRequest.cc | 8 +- 37 files changed, 541 insertions(+), 544 deletions(-) rename src/librbd/cache/{ => pwl}/AbstractWriteLog.cc (93%) rename src/librbd/cache/{ => pwl}/AbstractWriteLog.h (74%) rename src/librbd/cache/{rwl => pwl}/ImageCacheState.cc (91%) rename src/librbd/cache/{rwl => pwl}/ImageCacheState.h (92%) rename src/librbd/cache/{rwl => pwl}/InitRequest.cc (93%) rename src/librbd/cache/{rwl => pwl}/InitRequest.h (91%) rename src/librbd/cache/{rwl => pwl}/LogEntry.cc (98%) rename src/librbd/cache/{rwl => pwl}/LogEntry.h (98%) rename src/librbd/cache/{rwl => pwl}/LogMap.cc (97%) rename src/librbd/cache/{rwl => pwl}/LogMap.h (98%) rename src/librbd/cache/{rwl => pwl}/LogOperation.cc (95%) rename src/librbd/cache/{rwl => pwl}/LogOperation.h (98%) rename src/librbd/cache/{rwl => pwl}/ReadRequest.cc (77%) rename src/librbd/cache/{rwl => pwl}/ReadRequest.h (88%) rename src/librbd/cache/{ => pwl}/ReplicatedWriteLog.cc (51%) rename src/librbd/cache/{ => pwl}/ReplicatedWriteLog.h (63%) rename src/librbd/cache/{rwl => pwl}/Request.cc (77%) rename src/librbd/cache/{rwl => pwl}/Request.h (94%) rename src/librbd/cache/{rwl => pwl}/ShutdownRequest.cc (94%) rename src/librbd/cache/{rwl => pwl}/ShutdownRequest.h (93%) rename src/librbd/cache/{rwl => pwl}/SyncPoint.cc (96%) rename src/librbd/cache/{rwl => pwl}/SyncPoint.h (96%) rename src/librbd/cache/{rwl => pwl}/Types.cc (94%) rename src/librbd/cache/{rwl => pwl}/Types.h (72%) rename src/test/librbd/cache/{rwl => pwl}/test_WriteLogMap.cc (99%) diff --git a/src/common/subsys.h b/src/common/subsys.h index e61b478bfae95..d01abd0f38b85 100644 --- a/src/common/subsys.h +++ b/src/common/subsys.h @@ -37,7 +37,7 @@ SUBSYS(rados, 0, 5) SUBSYS(rbd, 0, 5) SUBSYS(rbd_mirror, 0, 5) SUBSYS(rbd_replay, 0, 5) -SUBSYS(rbd_rwl, 0, 5) +SUBSYS(rbd_pwl, 0, 5) SUBSYS(journaler, 0, 5) SUBSYS(objectcacher, 0, 5) SUBSYS(immutable_obj_cache, 0, 5) diff --git a/src/librbd/CMakeLists.txt b/src/librbd/CMakeLists.txt index 7540032522339..06e37bd39590a 100644 --- a/src/librbd/CMakeLists.txt +++ b/src/librbd/CMakeLists.txt @@ -43,8 +43,8 @@ set(librbd_internal_srcs cache/ObjectCacherObjectDispatch.cc cache/ObjectCacherWriteback.cc cache/PassthroughImageCache.cc - cache/rwl/InitRequest.cc - cache/rwl/ShutdownRequest.cc + cache/pwl/InitRequest.cc + cache/pwl/ShutdownRequest.cc cache/WriteAroundObjectDispatch.cc crypto/CryptoObjectDispatch.cc deep_copy/ImageCopyRequest.cc @@ -196,16 +196,16 @@ endif() if(WITH_RBD_RWL) set(librbd_internal_srcs ${librbd_internal_srcs} - cache/rwl/ImageCacheState.cc - cache/rwl/LogEntry.cc - cache/rwl/LogMap.cc - cache/rwl/LogOperation.cc - cache/rwl/ReadRequest.cc - cache/rwl/Request.cc - cache/rwl/SyncPoint.cc - cache/rwl/Types.cc - cache/ReplicatedWriteLog.cc - cache/AbstractWriteLog.cc + cache/pwl/ImageCacheState.cc + cache/pwl/LogEntry.cc + cache/pwl/LogMap.cc + cache/pwl/LogOperation.cc + cache/pwl/ReadRequest.cc + cache/pwl/Request.cc + cache/pwl/SyncPoint.cc + cache/pwl/Types.cc + cache/pwl/ReplicatedWriteLog.cc + cache/pwl/AbstractWriteLog.cc cache/WriteLogCache.cc) endif() diff --git a/src/librbd/ExclusiveLock.cc b/src/librbd/ExclusiveLock.cc index 00496c765b5f5..c5963b07c036f 100644 --- a/src/librbd/ExclusiveLock.cc +++ b/src/librbd/ExclusiveLock.cc @@ -205,7 +205,7 @@ void ExclusiveLock::handle_init_complete(int r, uint64_t features, on_finish->complete(r); }); - bool rwl_enabled = cache::util::is_rwl_enabled(m_image_ctx); + bool rwl_enabled = cache::util::is_pwl_enabled(m_image_ctx); if (m_image_ctx.clone_copy_on_read || (features & RBD_FEATURE_JOURNALING) != 0 || rwl_enabled) { diff --git a/src/librbd/cache/Utils.h b/src/librbd/cache/Utils.h index e69b09b3aaefe..827dcc5daa6a5 100644 --- a/src/librbd/cache/Utils.h +++ b/src/librbd/cache/Utils.h @@ -12,7 +12,7 @@ namespace cache { namespace util { template -bool is_rwl_enabled(T& image_ctx) { +bool is_pwl_enabled(T& image_ctx) { #if defined(WITH_RBD_RWL) return image_ctx.config.template get_val("rbd_rwl_enabled"); #else diff --git a/src/librbd/cache/WriteLogCache.cc b/src/librbd/cache/WriteLogCache.cc index 310bb5fb1503f..97b4125041d8e 100644 --- a/src/librbd/cache/WriteLogCache.cc +++ b/src/librbd/cache/WriteLogCache.cc @@ -2,11 +2,11 @@ // vim: ts=8 sw=2 smarttab #include "WriteLogCache.h" -#include "ReplicatedWriteLog.h" -#include "librbd/cache/rwl/ImageCacheState.h" +#include "librbd/cache/pwl/ReplicatedWriteLog.h" +#include "librbd/cache/pwl/ImageCacheState.h" #undef dout_subsys -#define dout_subsys ceph_subsys_rbd_rwl +#define dout_subsys ceph_subsys_rbd_pwl #undef dout_prefix #define dout_prefix *_dout << "librbd::cache::WriteLogCache: " << this << " " \ << __func__ << ": " @@ -14,14 +14,14 @@ namespace librbd { namespace cache { -using namespace librbd::cache::rwl; +using namespace librbd::cache::pwl; typedef WriteLogCache::Extent Extent; typedef WriteLogCache::Extents Extents; template -WriteLogCache::WriteLogCache(I &image_ctx, librbd::cache::rwl::ImageCacheState* cache_state) { - m_write_log = new ReplicatedWriteLog(image_ctx, cache_state); +WriteLogCache::WriteLogCache(I &image_ctx, librbd::cache::pwl::ImageCacheState* cache_state) { + m_write_log = new librbd::cache::pwl::ReplicatedWriteLog(image_ctx, cache_state); } template diff --git a/src/librbd/cache/WriteLogCache.h b/src/librbd/cache/WriteLogCache.h index 0f41955a4940e..5fe77a396be73 100644 --- a/src/librbd/cache/WriteLogCache.h +++ b/src/librbd/cache/WriteLogCache.h @@ -6,21 +6,14 @@ #include "librbd/cache/ImageCache.h" -class Context; -class SafeTimer; - -class Context; -class SafeTimer; - namespace librbd { struct ImageCtx; namespace cache { +namespace pwl { template class AbstractWriteLog; - -namespace rwl { template class ImageCacheState; } @@ -30,7 +23,7 @@ public: using typename ImageCache::Extent; using typename ImageCache::Extents; - WriteLogCache(ImageCtxT &image_ctx, librbd::cache::rwl::ImageCacheState* cache_state); + WriteLogCache(ImageCtxT &image_ctx, librbd::cache::pwl::ImageCacheState* cache_state); ~WriteLogCache(); WriteLogCache(const WriteLogCache&) = delete; WriteLogCache &operator=(const WriteLogCache&) = delete; @@ -58,7 +51,7 @@ public: void invalidate(Context *on_finish) override; void flush(Context *on_finish) override; - AbstractWriteLog *m_write_log; + librbd::cache::pwl::AbstractWriteLog *m_write_log; }; } // namespace cache diff --git a/src/librbd/cache/AbstractWriteLog.cc b/src/librbd/cache/pwl/AbstractWriteLog.cc similarity index 93% rename from src/librbd/cache/AbstractWriteLog.cc rename to src/librbd/cache/pwl/AbstractWriteLog.cc index 7b4ffed2e1aa4..8bb111ed5c5fb 100644 --- a/src/librbd/cache/AbstractWriteLog.cc +++ b/src/librbd/cache/pwl/AbstractWriteLog.cc @@ -15,23 +15,24 @@ #include "common/perf_counters.h" #include "librbd/ImageCtx.h" #include "librbd/asio/ContextWQ.h" -#include "librbd/cache/rwl/ImageCacheState.h" -#include "librbd/cache/rwl/LogEntry.h" -#include "librbd/cache/rwl/ReadRequest.h" -#include "librbd/cache/rwl/Types.h" +#include "librbd/cache/pwl/ImageCacheState.h" +#include "librbd/cache/pwl/LogEntry.h" +#include "librbd/cache/pwl/ReadRequest.h" +#include "librbd/cache/pwl/Types.h" #include #include #undef dout_subsys -#define dout_subsys ceph_subsys_rbd_rwl +#define dout_subsys ceph_subsys_rbd_pwl #undef dout_prefix -#define dout_prefix *_dout << "librbd::cache::AbstractWriteLog: " << this << " " \ +#define dout_prefix *_dout << "librbd::cache::pwl::AbstractWriteLog: " << this << " " \ << __func__ << ": " namespace librbd { namespace cache { +namespace pwl { -using namespace librbd::cache::rwl; +using namespace librbd::cache::pwl; typedef AbstractWriteLog::Extent Extent; typedef AbstractWriteLog::Extents Extents; @@ -39,28 +40,28 @@ typedef AbstractWriteLog::Extents Extents; const unsigned long int OPS_APPENDED_TOGETHER = MAX_ALLOC_PER_TRANSACTION; template -AbstractWriteLog::AbstractWriteLog(I &image_ctx, librbd::cache::rwl::ImageCacheState* cache_state) +AbstractWriteLog::AbstractWriteLog(I &image_ctx, librbd::cache::pwl::ImageCacheState* cache_state) : m_cache_state(cache_state), - m_rwl_pool_layout_name(POBJ_LAYOUT_NAME(rbd_rwl)), + m_pwl_pool_layout_name(POBJ_LAYOUT_NAME(rbd_pwl)), m_image_ctx(image_ctx), m_log_pool_config_size(DEFAULT_POOL_SIZE), m_image_writeback(image_ctx), m_write_log_guard(image_ctx.cct), m_log_retire_lock(ceph::make_mutex(util::unique_lock_name( - "librbd::cache::AbstractWriteLog::m_log_retire_lock", this))), - m_entry_reader_lock("librbd::cache::AbstractWriteLog::m_entry_reader_lock"), + "librbd::cache::pwl::AbstractWriteLog::m_log_retire_lock", this))), + m_entry_reader_lock("librbd::cache::pwl::AbstractWriteLog::m_entry_reader_lock"), m_deferred_dispatch_lock(ceph::make_mutex(util::unique_lock_name( - "librbd::cache::AbstractWriteLog::m_deferred_dispatch_lock", this))), + "librbd::cache::pwl::AbstractWriteLog::m_deferred_dispatch_lock", this))), m_log_append_lock(ceph::make_mutex(util::unique_lock_name( - "librbd::cache::AbstractWriteLog::m_log_append_lock", this))), + "librbd::cache::pwl::AbstractWriteLog::m_log_append_lock", this))), m_lock(ceph::make_mutex(util::unique_lock_name( - "librbd::cache::AbstractWriteLog::m_lock", this))), + "librbd::cache::pwl::AbstractWriteLog::m_lock", this))), m_blockguard_lock(ceph::make_mutex(util::unique_lock_name( - "librbd::cache::AbstractWriteLog::m_blockguard_lock", this))), + "librbd::cache::pwl::AbstractWriteLog::m_blockguard_lock", this))), m_blocks_to_log_entries(image_ctx.cct), - m_thread_pool(image_ctx.cct, "librbd::cache::AbstractWriteLog::thread_pool", "tp_rwl", + m_thread_pool(image_ctx.cct, "librbd::cache::pwl::AbstractWriteLog::thread_pool", "tp_pwl", 4, ""), - m_work_queue("librbd::cache::ReplicatedWriteLog::work_queue", + m_work_queue("librbd::cache::pwl::ReplicatedWriteLog::work_queue", ceph::make_timespan( image_ctx.config.template get_val( "rbd_op_thread_timeout")), @@ -92,7 +93,7 @@ AbstractWriteLog::~AbstractWriteLog() { template void AbstractWriteLog::perf_start(std::string name) { - PerfCountersBuilder plb(m_image_ctx.cct, name, l_librbd_rwl_first, l_librbd_rwl_last); + PerfCountersBuilder plb(m_image_ctx.cct, name, l_librbd_pwl_first, l_librbd_pwl_last); // Latency axis configuration for op histograms, values are in nanoseconds PerfHistogramCommon::axis_config_d op_hist_x_axis_config{ @@ -139,134 +140,134 @@ void AbstractWriteLog::perf_start(std::string name) { 32, ///< Writes up to >32k }; - plb.add_u64_counter(l_librbd_rwl_rd_req, "rd", "Reads"); - plb.add_u64_counter(l_librbd_rwl_rd_bytes, "rd_bytes", "Data size in reads"); - plb.add_time_avg(l_librbd_rwl_rd_latency, "rd_latency", "Latency of reads"); + plb.add_u64_counter(l_librbd_pwl_rd_req, "rd", "Reads"); + plb.add_u64_counter(l_librbd_pwl_rd_bytes, "rd_bytes", "Data size in reads"); + plb.add_time_avg(l_librbd_pwl_rd_latency, "rd_latency", "Latency of reads"); - plb.add_u64_counter(l_librbd_rwl_rd_hit_req, "hit_rd", "Reads completely hitting RWL"); - plb.add_u64_counter(l_librbd_rwl_rd_hit_bytes, "rd_hit_bytes", "Bytes read from RWL"); - plb.add_time_avg(l_librbd_rwl_rd_hit_latency, "hit_rd_latency", "Latency of read hits"); + plb.add_u64_counter(l_librbd_pwl_rd_hit_req, "hit_rd", "Reads completely hitting RWL"); + plb.add_u64_counter(l_librbd_pwl_rd_hit_bytes, "rd_hit_bytes", "Bytes read from RWL"); + plb.add_time_avg(l_librbd_pwl_rd_hit_latency, "hit_rd_latency", "Latency of read hits"); - plb.add_u64_counter(l_librbd_rwl_rd_part_hit_req, "part_hit_rd", "reads partially hitting RWL"); + plb.add_u64_counter(l_librbd_pwl_rd_part_hit_req, "part_hit_rd", "reads partially hitting RWL"); plb.add_u64_counter_histogram( - l_librbd_rwl_syncpoint_hist, "syncpoint_logentry_bytes_histogram", + l_librbd_pwl_syncpoint_hist, "syncpoint_logentry_bytes_histogram", sp_logentry_number_config, sp_bytes_number_config, "Histogram of syncpoint's logentry numbers vs bytes number"); - plb.add_u64_counter(l_librbd_rwl_wr_req, "wr", "Writes"); - plb.add_u64_counter(l_librbd_rwl_wr_req_def, "wr_def", "Writes deferred for resources"); - plb.add_u64_counter(l_librbd_rwl_wr_req_def_lanes, "wr_def_lanes", "Writes deferred for lanes"); - plb.add_u64_counter(l_librbd_rwl_wr_req_def_log, "wr_def_log", "Writes deferred for log entries"); - plb.add_u64_counter(l_librbd_rwl_wr_req_def_buf, "wr_def_buf", "Writes deferred for buffers"); - plb.add_u64_counter(l_librbd_rwl_wr_req_overlap, "wr_overlap", "Writes overlapping with prior in-progress writes"); - plb.add_u64_counter(l_librbd_rwl_wr_req_queued, "wr_q_barrier", "Writes queued for prior barriers (aio_flush)"); - plb.add_u64_counter(l_librbd_rwl_wr_bytes, "wr_bytes", "Data size in writes"); + plb.add_u64_counter(l_librbd_pwl_wr_req, "wr", "Writes"); + plb.add_u64_counter(l_librbd_pwl_wr_req_def, "wr_def", "Writes deferred for resources"); + plb.add_u64_counter(l_librbd_pwl_wr_req_def_lanes, "wr_def_lanes", "Writes deferred for lanes"); + plb.add_u64_counter(l_librbd_pwl_wr_req_def_log, "wr_def_log", "Writes deferred for log entries"); + plb.add_u64_counter(l_librbd_pwl_wr_req_def_buf, "wr_def_buf", "Writes deferred for buffers"); + plb.add_u64_counter(l_librbd_pwl_wr_req_overlap, "wr_overlap", "Writes overlapping with prior in-progress writes"); + plb.add_u64_counter(l_librbd_pwl_wr_req_queued, "wr_q_barrier", "Writes queued for prior barriers (aio_flush)"); + plb.add_u64_counter(l_librbd_pwl_wr_bytes, "wr_bytes", "Data size in writes"); - plb.add_u64_counter(l_librbd_rwl_log_ops, "log_ops", "Log appends"); - plb.add_u64_avg(l_librbd_rwl_log_op_bytes, "log_op_bytes", "Average log append bytes"); + plb.add_u64_counter(l_librbd_pwl_log_ops, "log_ops", "Log appends"); + plb.add_u64_avg(l_librbd_pwl_log_op_bytes, "log_op_bytes", "Average log append bytes"); plb.add_time_avg( - l_librbd_rwl_req_arr_to_all_t, "req_arr_to_all_t", + l_librbd_pwl_req_arr_to_all_t, "req_arr_to_all_t", "Average arrival to allocation time (time deferred for overlap)"); plb.add_time_avg( - l_librbd_rwl_req_arr_to_dis_t, "req_arr_to_dis_t", + l_librbd_pwl_req_arr_to_dis_t, "req_arr_to_dis_t", "Average arrival to dispatch time (includes time deferred for overlaps and allocation)"); plb.add_time_avg( - l_librbd_rwl_req_all_to_dis_t, "req_all_to_dis_t", + l_librbd_pwl_req_all_to_dis_t, "req_all_to_dis_t", "Average allocation to dispatch time (time deferred for log resources)"); plb.add_time_avg( - l_librbd_rwl_wr_latency, "wr_latency", + l_librbd_pwl_wr_latency, "wr_latency", "Latency of writes (persistent completion)"); plb.add_u64_counter_histogram( - l_librbd_rwl_wr_latency_hist, "wr_latency_bytes_histogram", + l_librbd_pwl_wr_latency_hist, "wr_latency_bytes_histogram", op_hist_x_axis_config, op_hist_y_axis_config, "Histogram of write request latency (nanoseconds) vs. bytes written"); plb.add_time_avg( - l_librbd_rwl_wr_caller_latency, "caller_wr_latency", + l_librbd_pwl_wr_caller_latency, "caller_wr_latency", "Latency of write completion to caller"); plb.add_time_avg( - l_librbd_rwl_nowait_req_arr_to_all_t, "req_arr_to_all_nw_t", + l_librbd_pwl_nowait_req_arr_to_all_t, "req_arr_to_all_nw_t", "Average arrival to allocation time (time deferred for overlap)"); plb.add_time_avg( - l_librbd_rwl_nowait_req_arr_to_dis_t, "req_arr_to_dis_nw_t", + l_librbd_pwl_nowait_req_arr_to_dis_t, "req_arr_to_dis_nw_t", "Average arrival to dispatch time (includes time deferred for overlaps and allocation)"); plb.add_time_avg( - l_librbd_rwl_nowait_req_all_to_dis_t, "req_all_to_dis_nw_t", + l_librbd_pwl_nowait_req_all_to_dis_t, "req_all_to_dis_nw_t", "Average allocation to dispatch time (time deferred for log resources)"); plb.add_time_avg( - l_librbd_rwl_nowait_wr_latency, "wr_latency_nw", + l_librbd_pwl_nowait_wr_latency, "wr_latency_nw", "Latency of writes (persistent completion) not deferred for free space"); plb.add_u64_counter_histogram( - l_librbd_rwl_nowait_wr_latency_hist, "wr_latency_nw_bytes_histogram", + l_librbd_pwl_nowait_wr_latency_hist, "wr_latency_nw_bytes_histogram", op_hist_x_axis_config, op_hist_y_axis_config, "Histogram of write request latency (nanoseconds) vs. bytes written for writes not deferred for free space"); plb.add_time_avg( - l_librbd_rwl_nowait_wr_caller_latency, "caller_wr_latency_nw", + l_librbd_pwl_nowait_wr_caller_latency, "caller_wr_latency_nw", "Latency of write completion to callerfor writes not deferred for free space"); - plb.add_time_avg(l_librbd_rwl_log_op_alloc_t, "op_alloc_t", "Average buffer pmemobj_reserve() time"); + plb.add_time_avg(l_librbd_pwl_log_op_alloc_t, "op_alloc_t", "Average buffer pmemobj_reserve() time"); plb.add_u64_counter_histogram( - l_librbd_rwl_log_op_alloc_t_hist, "op_alloc_t_bytes_histogram", + l_librbd_pwl_log_op_alloc_t_hist, "op_alloc_t_bytes_histogram", op_hist_x_axis_config, op_hist_y_axis_config, "Histogram of buffer pmemobj_reserve() time (nanoseconds) vs. bytes written"); - plb.add_time_avg(l_librbd_rwl_log_op_dis_to_buf_t, "op_dis_to_buf_t", "Average dispatch to buffer persist time"); - plb.add_time_avg(l_librbd_rwl_log_op_dis_to_app_t, "op_dis_to_app_t", "Average dispatch to log append time"); - plb.add_time_avg(l_librbd_rwl_log_op_dis_to_cmp_t, "op_dis_to_cmp_t", "Average dispatch to persist completion time"); + plb.add_time_avg(l_librbd_pwl_log_op_dis_to_buf_t, "op_dis_to_buf_t", "Average dispatch to buffer persist time"); + plb.add_time_avg(l_librbd_pwl_log_op_dis_to_app_t, "op_dis_to_app_t", "Average dispatch to log append time"); + plb.add_time_avg(l_librbd_pwl_log_op_dis_to_cmp_t, "op_dis_to_cmp_t", "Average dispatch to persist completion time"); plb.add_u64_counter_histogram( - l_librbd_rwl_log_op_dis_to_cmp_t_hist, "op_dis_to_cmp_t_bytes_histogram", + l_librbd_pwl_log_op_dis_to_cmp_t_hist, "op_dis_to_cmp_t_bytes_histogram", op_hist_x_axis_config, op_hist_y_axis_config, "Histogram of op dispatch to persist complete time (nanoseconds) vs. bytes written"); plb.add_time_avg( - l_librbd_rwl_log_op_buf_to_app_t, "op_buf_to_app_t", + l_librbd_pwl_log_op_buf_to_app_t, "op_buf_to_app_t", "Average buffer persist to log append time (write data persist/replicate + wait for append time)"); plb.add_time_avg( - l_librbd_rwl_log_op_buf_to_bufc_t, "op_buf_to_bufc_t", + l_librbd_pwl_log_op_buf_to_bufc_t, "op_buf_to_bufc_t", "Average buffer persist time (write data persist/replicate time)"); plb.add_u64_counter_histogram( - l_librbd_rwl_log_op_buf_to_bufc_t_hist, "op_buf_to_bufc_t_bytes_histogram", + l_librbd_pwl_log_op_buf_to_bufc_t_hist, "op_buf_to_bufc_t_bytes_histogram", op_hist_x_axis_config, op_hist_y_axis_config, "Histogram of write buffer persist time (nanoseconds) vs. bytes written"); plb.add_time_avg( - l_librbd_rwl_log_op_app_to_cmp_t, "op_app_to_cmp_t", + l_librbd_pwl_log_op_app_to_cmp_t, "op_app_to_cmp_t", "Average log append to persist complete time (log entry append/replicate + wait for complete time)"); plb.add_time_avg( - l_librbd_rwl_log_op_app_to_appc_t, "op_app_to_appc_t", + l_librbd_pwl_log_op_app_to_appc_t, "op_app_to_appc_t", "Average log append to persist complete time (log entry append/replicate time)"); plb.add_u64_counter_histogram( - l_librbd_rwl_log_op_app_to_appc_t_hist, "op_app_to_appc_t_bytes_histogram", + l_librbd_pwl_log_op_app_to_appc_t_hist, "op_app_to_appc_t_bytes_histogram", op_hist_x_axis_config, op_hist_y_axis_config, "Histogram of log append persist time (nanoseconds) (vs. op bytes)"); - plb.add_u64_counter(l_librbd_rwl_discard, "discard", "Discards"); - plb.add_u64_counter(l_librbd_rwl_discard_bytes, "discard_bytes", "Bytes discarded"); - plb.add_time_avg(l_librbd_rwl_discard_latency, "discard_lat", "Discard latency"); + plb.add_u64_counter(l_librbd_pwl_discard, "discard", "Discards"); + plb.add_u64_counter(l_librbd_pwl_discard_bytes, "discard_bytes", "Bytes discarded"); + plb.add_time_avg(l_librbd_pwl_discard_latency, "discard_lat", "Discard latency"); - plb.add_u64_counter(l_librbd_rwl_aio_flush, "aio_flush", "AIO flush (flush to RWL)"); - plb.add_u64_counter(l_librbd_rwl_aio_flush_def, "aio_flush_def", "AIO flushes deferred for resources"); - plb.add_time_avg(l_librbd_rwl_aio_flush_latency, "aio_flush_lat", "AIO flush latency"); + plb.add_u64_counter(l_librbd_pwl_aio_flush, "aio_flush", "AIO flush (flush to RWL)"); + plb.add_u64_counter(l_librbd_pwl_aio_flush_def, "aio_flush_def", "AIO flushes deferred for resources"); + plb.add_time_avg(l_librbd_pwl_aio_flush_latency, "aio_flush_lat", "AIO flush latency"); - plb.add_u64_counter(l_librbd_rwl_ws,"ws", "Write Sames"); - plb.add_u64_counter(l_librbd_rwl_ws_bytes, "ws_bytes", "Write Same bytes to image"); - plb.add_time_avg(l_librbd_rwl_ws_latency, "ws_lat", "Write Same latency"); + plb.add_u64_counter(l_librbd_pwl_ws,"ws", "Write Sames"); + plb.add_u64_counter(l_librbd_pwl_ws_bytes, "ws_bytes", "Write Same bytes to image"); + plb.add_time_avg(l_librbd_pwl_ws_latency, "ws_lat", "Write Same latency"); - plb.add_u64_counter(l_librbd_rwl_cmp, "cmp", "Compare and Write requests"); - plb.add_u64_counter(l_librbd_rwl_cmp_bytes, "cmp_bytes", "Compare and Write bytes compared/written"); - plb.add_time_avg(l_librbd_rwl_cmp_latency, "cmp_lat", "Compare and Write latecy"); - plb.add_u64_counter(l_librbd_rwl_cmp_fails, "cmp_fails", "Compare and Write compare fails"); + plb.add_u64_counter(l_librbd_pwl_cmp, "cmp", "Compare and Write requests"); + plb.add_u64_counter(l_librbd_pwl_cmp_bytes, "cmp_bytes", "Compare and Write bytes compared/written"); + plb.add_time_avg(l_librbd_pwl_cmp_latency, "cmp_lat", "Compare and Write latecy"); + plb.add_u64_counter(l_librbd_pwl_cmp_fails, "cmp_fails", "Compare and Write compare fails"); - plb.add_u64_counter(l_librbd_rwl_flush, "flush", "Flush (flush RWL)"); - plb.add_u64_counter(l_librbd_rwl_invalidate_cache, "invalidate", "Invalidate RWL"); - plb.add_u64_counter(l_librbd_rwl_invalidate_discard_cache, "discard", "Discard and invalidate RWL"); + plb.add_u64_counter(l_librbd_pwl_flush, "flush", "Flush (flush RWL)"); + plb.add_u64_counter(l_librbd_pwl_invalidate_cache, "invalidate", "Invalidate RWL"); + plb.add_u64_counter(l_librbd_pwl_invalidate_discard_cache, "discard", "Discard and invalidate RWL"); - plb.add_time_avg(l_librbd_rwl_append_tx_t, "append_tx_lat", "Log append transaction latency"); + plb.add_time_avg(l_librbd_pwl_append_tx_t, "append_tx_lat", "Log append transaction latency"); plb.add_u64_counter_histogram( - l_librbd_rwl_append_tx_t_hist, "append_tx_lat_histogram", + l_librbd_pwl_append_tx_t_hist, "append_tx_lat_histogram", op_hist_x_axis_config, op_hist_y_axis_count_config, "Histogram of log append transaction time (nanoseconds) vs. entries appended"); - plb.add_time_avg(l_librbd_rwl_retire_tx_t, "retire_tx_lat", "Log retire transaction latency"); + plb.add_time_avg(l_librbd_pwl_retire_tx_t, "retire_tx_lat", "Log retire transaction latency"); plb.add_u64_counter_histogram( - l_librbd_rwl_retire_tx_t_hist, "retire_tx_lat_histogram", + l_librbd_pwl_retire_tx_t_hist, "retire_tx_lat_histogram", op_hist_x_axis_config, op_hist_y_axis_count_config, "Histogram of log retire transaction time (nanoseconds) vs. entries retired"); @@ -532,7 +533,7 @@ void AbstractWriteLog::load_existing_entries(DeferredContexts &later) { } template -void AbstractWriteLog::rwl_init(Context *on_finish, DeferredContexts &later) { +void AbstractWriteLog::pwl_init(Context *on_finish, DeferredContexts &later) { CephContext *cct = m_image_ctx.cct; ldout(cct, 20) << dendl; TOID(struct WriteLogPoolRoot) pool_root; @@ -540,13 +541,13 @@ void AbstractWriteLog::rwl_init(Context *on_finish, DeferredContexts &later) std::lock_guard locker(m_lock); ceph_assert(!m_initialized); ldout(cct,5) << "image name: " << m_image_ctx.name << " id: " << m_image_ctx.id << dendl; - ldout(cct,5) << "rwl_size: " << m_cache_state->size << dendl; - std::string rwl_path = m_cache_state->path; - ldout(cct,5) << "rwl_path: " << rwl_path << dendl; + ldout(cct,5) << "pwl_size: " << m_cache_state->size << dendl; + std::string pwl_path = m_cache_state->path; + ldout(cct,5) << "pwl_path: " << pwl_path << dendl; std::string pool_name = m_image_ctx.md_ctx.get_pool_name(); - std::string log_pool_name = rwl_path + "/rbd-rwl." + pool_name + "." + m_image_ctx.id + ".pool"; - std::string log_poolset_name = rwl_path + "/rbd-rwl." + pool_name + "." + m_image_ctx.id + ".poolset"; + std::string log_pool_name = pwl_path + "/rbd-pwl." + pool_name + "." + m_image_ctx.id + ".pool"; + std::string log_poolset_name = pwl_path + "/rbd-pwl." + pool_name + "." + m_image_ctx.id + ".poolset"; m_log_pool_config_size = max(m_cache_state->size, MIN_POOL_SIZE); if (access(log_poolset_name.c_str(), F_OK) == 0) { @@ -575,7 +576,7 @@ void AbstractWriteLog::rwl_init(Context *on_finish, DeferredContexts &later) if (access(m_log_pool_name.c_str(), F_OK) != 0) { if ((m_log_pool = pmemobj_create(m_log_pool_name.c_str(), - m_rwl_pool_layout_name, + m_pwl_pool_layout_name, m_log_pool_config_size, (S_IWUSR | S_IRUSR))) == NULL) { lderr(cct) << "failed to create pool (" << m_log_pool_name << ")" @@ -637,7 +638,7 @@ void AbstractWriteLog::rwl_init(Context *on_finish, DeferredContexts &later) /* Open existing pool */ if ((m_log_pool = pmemobj_open(m_log_pool_name.c_str(), - m_rwl_pool_layout_name)) == NULL) { + m_pwl_pool_layout_name)) == NULL) { lderr(cct) << "failed to open pool (" << m_log_pool_name << "): " << pmemobj_errormsg() << dendl; on_finish->complete(-errno); @@ -738,7 +739,7 @@ void AbstractWriteLog::init(Context *on_finish) { }); DeferredContexts later; - rwl_init(ctx, later); + pwl_init(ctx, later); } template @@ -849,7 +850,7 @@ void AbstractWriteLog::read(Extents&& image_extents, ceph_assert(m_initialized); bl->clear(); - m_perfcounter->inc(l_librbd_rwl_rd_req, 1); + m_perfcounter->inc(l_librbd_pwl_rd_req, 1); /* * The strategy here is to look up all the WriteLogMapEntries that overlap @@ -872,7 +873,7 @@ void AbstractWriteLog::read(Extents&& image_extents, RWLock::RLocker entry_reader_locker(m_entry_reader_lock); WriteLogMapEntries map_entries = m_blocks_to_log_entries.find_map_entries(block_extent(extent)); for (auto &map_entry : map_entries) { - Extent entry_image_extent(rwl::image_extent(map_entry.block_extent)); + Extent entry_image_extent(pwl::image_extent(map_entry.block_extent)); /* If this map entry starts after the current image extent offset ... */ if (entry_image_extent.first > extent.first + extent_offset) { /* ... add range before map_entry to miss extents */ @@ -969,14 +970,14 @@ void AbstractWriteLog::write(Extents &&image_extents, ldout(cct, 20) << "aio_write" << dendl; utime_t now = ceph_clock_now(); - m_perfcounter->inc(l_librbd_rwl_wr_req, 1); + m_perfcounter->inc(l_librbd_pwl_wr_req, 1); ceph_assert(m_initialized); auto *write_req = new C_WriteRequestT(*this, now, std::move(image_extents), std::move(bl), fadvise_flags, m_lock, m_perfcounter, on_finish); - m_perfcounter->inc(l_librbd_rwl_wr_bytes, write_req->image_extents_summary.total_bytes); + 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 */ @@ -998,7 +999,7 @@ void AbstractWriteLog::discard(uint64_t offset, uint64_t length, ldout(cct, 20) << dendl; utime_t now = ceph_clock_now(); - m_perfcounter->inc(l_librbd_rwl_discard, 1); + m_perfcounter->inc(l_librbd_pwl_discard, 1); Extents discard_extents = {{offset, length}}; m_discard_granularity_bytes = discard_granularity_bytes; @@ -1039,7 +1040,7 @@ void AbstractWriteLog::flush(io::FlushSource flush_source, Context *on_finish internal_flush(false, on_finish); return; } - m_perfcounter->inc(l_librbd_rwl_aio_flush, 1); + m_perfcounter->inc(l_librbd_pwl_aio_flush, 1); /* May be called even if initialization fails */ if (!m_initialized) { @@ -1099,7 +1100,7 @@ void AbstractWriteLog::writesame(uint64_t offset, uint64_t length, utime_t now = ceph_clock_now(); Extents ws_extents = {{offset, length}}; - m_perfcounter->inc(l_librbd_rwl_ws, 1); + m_perfcounter->inc(l_librbd_pwl_ws, 1); ceph_assert(m_initialized); /* A write same request is also a write request. The key difference is the @@ -1112,7 +1113,7 @@ void AbstractWriteLog::writesame(uint64_t offset, uint64_t length, auto *ws_req = new C_WriteSameRequestT(*this, now, std::move(ws_extents), std::move(bl), fadvise_flags, m_lock, m_perfcounter, on_finish); - m_perfcounter->inc(l_librbd_rwl_ws_bytes, ws_req->image_extents_summary.total_bytes); + m_perfcounter->inc(l_librbd_pwl_ws_bytes, ws_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 */ @@ -1135,7 +1136,7 @@ void AbstractWriteLog::compare_and_write(Extents &&image_extents, ldout(m_image_ctx.cct, 20) << dendl; utime_t now = ceph_clock_now(); - m_perfcounter->inc(l_librbd_rwl_cmp, 1); + m_perfcounter->inc(l_librbd_pwl_cmp, 1); ceph_assert(m_initialized); /* A compare and write request is also a write request. We only allocate @@ -1144,7 +1145,7 @@ void AbstractWriteLog::compare_and_write(Extents &&image_extents, auto *cw_req = new C_CompAndWriteRequestT(*this, now, std::move(image_extents), std::move(cmp_bl), std::move(bl), mismatch_offset, fadvise_flags, m_lock, m_perfcounter, on_finish); - m_perfcounter->inc(l_librbd_rwl_cmp_bytes, cw_req->image_extents_summary.total_bytes); + m_perfcounter->inc(l_librbd_pwl_cmp_bytes, cw_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 */ @@ -1698,9 +1699,9 @@ int AbstractWriteLog::append_op_log_entries(GenericLogOperations &ops) } TX_END; utime_t tx_end = ceph_clock_now(); - m_perfcounter->tinc(l_librbd_rwl_append_tx_t, tx_end - tx_start); + m_perfcounter->tinc(l_librbd_pwl_append_tx_t, tx_end - tx_start); m_perfcounter->hinc( - l_librbd_rwl_append_tx_t_hist, utime_t(tx_end - tx_start).to_nsec(), ops.size()); + l_librbd_pwl_append_tx_t_hist, utime_t(tx_end - tx_start).to_nsec(), ops.size()); for (auto &operation : ops) { operation->log_append_comp_time = tx_end; } @@ -1730,17 +1731,17 @@ void AbstractWriteLog::complete_op_log_entries(GenericLogOperations &&ops, published_reserves++; } op->complete(result); - m_perfcounter->tinc(l_librbd_rwl_log_op_dis_to_app_t, + m_perfcounter->tinc(l_librbd_pwl_log_op_dis_to_app_t, op->log_append_time - op->dispatch_time); - m_perfcounter->tinc(l_librbd_rwl_log_op_dis_to_cmp_t, now - op->dispatch_time); - m_perfcounter->hinc(l_librbd_rwl_log_op_dis_to_cmp_t_hist, + m_perfcounter->tinc(l_librbd_pwl_log_op_dis_to_cmp_t, now - op->dispatch_time); + m_perfcounter->hinc(l_librbd_pwl_log_op_dis_to_cmp_t_hist, utime_t(now - op->dispatch_time).to_nsec(), log_entry->ram_entry.write_bytes); utime_t app_lat = op->log_append_comp_time - op->log_append_time; - m_perfcounter->tinc(l_librbd_rwl_log_op_app_to_appc_t, app_lat); - m_perfcounter->hinc(l_librbd_rwl_log_op_app_to_appc_t_hist, app_lat.to_nsec(), + m_perfcounter->tinc(l_librbd_pwl_log_op_app_to_appc_t, app_lat); + m_perfcounter->hinc(l_librbd_pwl_log_op_app_to_appc_t_hist, app_lat.to_nsec(), log_entry->ram_entry.write_bytes); - m_perfcounter->tinc(l_librbd_rwl_log_op_app_to_cmp_t, now - op->log_append_time); + m_perfcounter->tinc(l_librbd_pwl_log_op_app_to_cmp_t, now - op->log_append_time); } { @@ -2389,7 +2390,7 @@ void AbstractWriteLog::new_sync_point(DeferredContexts &later) { * nullptr, but m_current_sync_gen may not be zero. */ if (old_sync_point) { new_sync_point->setup_earlier_sync_point(old_sync_point, m_last_op_sequence_num); - m_perfcounter->hinc(l_librbd_rwl_syncpoint_hist, + m_perfcounter->hinc(l_librbd_pwl_syncpoint_hist, old_sync_point->log_entry->writes, old_sync_point->log_entry->bytes); /* This sync point will acquire no more sub-ops. Activation needs @@ -2537,9 +2538,9 @@ void AbstractWriteLog::internal_flush(bool invalidate, Context *on_finish) { if (m_perfcounter) { if (invalidate) { - m_perfcounter->inc(l_librbd_rwl_invalidate_cache, 1); + m_perfcounter->inc(l_librbd_pwl_invalidate_cache, 1); } else { - m_perfcounter->inc(l_librbd_rwl_flush, 1); + m_perfcounter->inc(l_librbd_pwl_flush, 1); } } @@ -2728,8 +2729,8 @@ bool AbstractWriteLog::retire_entries(const unsigned long int frees_per_tx) { } TX_END; tx_end = ceph_clock_now(); } - m_perfcounter->tinc(l_librbd_rwl_retire_tx_t, tx_end - tx_start); - m_perfcounter->hinc(l_librbd_rwl_retire_tx_t_hist, utime_t(tx_end - tx_start).to_nsec(), retiring_entries.size()); + m_perfcounter->tinc(l_librbd_pwl_retire_tx_t, tx_end - tx_start); + m_perfcounter->hinc(l_librbd_pwl_retire_tx_t_hist, utime_t(tx_end - tx_start).to_nsec(), retiring_entries.size()); /* Update runtime copy of first_valid, and free entries counts */ { @@ -2760,10 +2761,11 @@ bool AbstractWriteLog::retire_entries(const unsigned long int frees_per_tx) { return true; } +} // namespace pwl } // namespace cache } // namespace librbd -template class librbd::cache::AbstractWriteLog; -template void librbd::cache::AbstractWriteLog:: \ +template class librbd::cache::pwl::AbstractWriteLog; +template void librbd::cache::pwl::AbstractWriteLog:: \ flush_pmem_buffer(std::vector>&); + librbd::cache::pwl::GenericLogOperation>>&); diff --git a/src/librbd/cache/AbstractWriteLog.h b/src/librbd/cache/pwl/AbstractWriteLog.h similarity index 74% rename from src/librbd/cache/AbstractWriteLog.h rename to src/librbd/cache/pwl/AbstractWriteLog.h index 4951d0f9dd6ae..d47980cc2fd43 100644 --- a/src/librbd/cache/AbstractWriteLog.h +++ b/src/librbd/cache/pwl/AbstractWriteLog.h @@ -12,9 +12,9 @@ #include "librbd/Utils.h" #include "librbd/BlockGuard.h" #include "librbd/cache/Types.h" -#include "librbd/cache/rwl/LogOperation.h" -#include "librbd/cache/rwl/Request.h" -#include "librbd/cache/rwl/LogMap.h" +#include "librbd/cache/pwl/LogOperation.h" +#include "librbd/cache/pwl/Request.h" +#include "librbd/cache/pwl/LogMap.h" #include #include @@ -27,7 +27,7 @@ struct ImageCtx; namespace cache { -namespace rwl { +namespace pwl { class SyncPointLogEntry; class GenericWriteLogEntry; @@ -57,8 +57,6 @@ struct C_WriteRequest; using GenericLogOperations = std::list; -} // namespace rwl - template class AbstractWriteLog { @@ -66,7 +64,7 @@ public: typedef io::Extent Extent; typedef io::Extents Extents; - AbstractWriteLog(ImageCtxT &image_ctx, librbd::cache::rwl::ImageCacheState* cache_state); + AbstractWriteLog(ImageCtxT &image_ctx, librbd::cache::pwl::ImageCacheState* cache_state); ~AbstractWriteLog(); AbstractWriteLog(const AbstractWriteLog&) = delete; AbstractWriteLog &operator=(const AbstractWriteLog&) = delete; @@ -96,12 +94,12 @@ public: void flush(Context *on_finish); using This = AbstractWriteLog; - using C_WriteRequestT = rwl::C_WriteRequest; - using C_BlockIORequestT = rwl::C_BlockIORequest; - using C_FlushRequestT = rwl::C_FlushRequest; - using C_DiscardRequestT = rwl::C_DiscardRequest; - using C_WriteSameRequestT = rwl::C_WriteSameRequest; - using C_CompAndWriteRequestT = rwl::C_CompAndWriteRequest; + using C_WriteRequestT = pwl::C_WriteRequest; + using C_BlockIORequestT = pwl::C_BlockIORequest; + using C_FlushRequestT = pwl::C_FlushRequest; + using C_DiscardRequestT = pwl::C_DiscardRequest; + using C_WriteSameRequestT = pwl::C_WriteSameRequest; + using C_CompAndWriteRequestT = pwl::C_CompAndWriteRequest; CephContext * get_context(); void release_guarded_request(BlockGuardCell *cell); @@ -109,18 +107,18 @@ public: bool alloc_resources(C_BlockIORequestT *req); template void flush_pmem_buffer(V& ops); - void schedule_append(rwl::GenericLogOperationsVector &ops); - void schedule_append(rwl::GenericLogOperationSharedPtr op); - void schedule_flush_and_append(rwl::GenericLogOperationsVector &ops); - void flush_new_sync_point(C_FlushRequestT *flush_req, rwl::DeferredContexts &later); - std::shared_ptr get_current_sync_point() { + void schedule_append(pwl::GenericLogOperationsVector &ops); + void schedule_append(pwl::GenericLogOperationSharedPtr op); + void schedule_flush_and_append(pwl::GenericLogOperationsVector &ops); + void flush_new_sync_point(C_FlushRequestT *flush_req, pwl::DeferredContexts &later); + std::shared_ptr get_current_sync_point() { return m_current_sync_point; } bool get_persist_on_flush() { return m_persist_on_flush; } void inc_last_op_sequence_num() { - m_perfcounter->inc(l_librbd_rwl_log_ops, 1); + m_perfcounter->inc(l_librbd_pwl_log_ops, 1); ++m_last_op_sequence_num; } uint64_t get_last_op_sequence_num() { @@ -135,24 +133,24 @@ public: uint32_t get_free_log_entries() { return m_free_log_entries; } - void add_into_log_map(rwl::GenericWriteLogEntries &log_entries); + void add_into_log_map(pwl::GenericWriteLogEntries &log_entries); protected: - typedef std::list *> C_WriteRequests; - typedef std::list *> C_BlockIORequests; + typedef std::list *> C_WriteRequests; + typedef std::list *> C_BlockIORequests; - BlockGuardCell* detain_guarded_request_helper(rwl::GuardedRequest &req); - BlockGuardCell* detain_guarded_request_barrier_helper(rwl::GuardedRequest &req); + BlockGuardCell* detain_guarded_request_helper(pwl::GuardedRequest &req); + BlockGuardCell* detain_guarded_request_barrier_helper(pwl::GuardedRequest &req); void detain_guarded_request(C_BlockIORequestT *request, - rwl::GuardedRequestFunctionContext *guarded_ctx, + pwl::GuardedRequestFunctionContext *guarded_ctx, bool is_barrier); - librbd::cache::rwl::ImageCacheState* m_cache_state = nullptr; + librbd::cache::pwl::ImageCacheState* m_cache_state = nullptr; std::atomic m_initialized = {false}; std::atomic m_shutting_down = {false}; std::atomic m_invalidating = {false}; PMEMobjpool *m_log_pool = nullptr; - const char* m_rwl_pool_layout_name; + const char* m_pwl_pool_layout_name; ImageCtxT &m_image_ctx; @@ -173,7 +171,7 @@ protected: std::atomic m_alloc_failed_since_retire = {false}; ImageWriteback m_image_writeback; - rwl::WriteLogGuard m_write_log_guard; + pwl::WriteLogGuard m_write_log_guard; /* * When m_first_free_entry == m_first_valid_entry, the log is * empty. There is always at least one free entry, which can't be @@ -218,7 +216,7 @@ protected: mutable ceph::mutex m_blockguard_lock; /* Use m_blockguard_lock for the following 3 things */ - rwl::WriteLogGuard::BlockOperations m_awaiting_barrier; + pwl::WriteLogGuard::BlockOperations m_awaiting_barrier; bool m_barrier_in_progress = false; BlockGuardCell *m_barrier_cell = nullptr; @@ -230,18 +228,18 @@ protected: Contexts m_flush_complete_contexts; - rwl::GenericLogOperations m_ops_to_flush; /* Write ops needing flush in local log */ - rwl::GenericLogOperations m_ops_to_append; /* Write ops needing event append in local log */ + pwl::GenericLogOperations m_ops_to_flush; /* Write ops needing flush in local log */ + pwl::GenericLogOperations m_ops_to_append; /* Write ops needing event append in local log */ - rwl::WriteLogMap m_blocks_to_log_entries; + pwl::WriteLogMap m_blocks_to_log_entries; /* New entries are at the back. Oldest at the front */ - rwl::GenericLogEntries m_log_entries; - rwl::GenericLogEntries m_dirty_log_entries; + pwl::GenericLogEntries m_log_entries; + pwl::GenericLogEntries m_dirty_log_entries; PerfCounters *m_perfcounter = nullptr; - std::shared_ptr m_current_sync_point = nullptr; + std::shared_ptr m_current_sync_point = nullptr; bool m_persist_on_flush = false; /* If false, persist each write before completion */ int m_flush_ops_in_flight = 0; @@ -251,7 +249,7 @@ protected: /* Writes that have left the block guard, but are waiting for resources */ C_BlockIORequests m_deferred_ios; /* Throttle writes concurrently allocating & replicating */ - unsigned int m_free_lanes = rwl::MAX_CONCURRENT_WRITES; + unsigned int m_free_lanes = pwl::MAX_CONCURRENT_WRITES; unsigned int m_unpublished_reserves = 0; /* Initialized from config, then set false during shutdown */ @@ -271,45 +269,46 @@ protected: void periodic_stats(); void arm_periodic_stats(); - void rwl_init(Context *on_finish, rwl::DeferredContexts &later); + void pwl_init(Context *on_finish, pwl::DeferredContexts &later); void update_image_cache_state(Context *on_finish); - void load_existing_entries(rwl::DeferredContexts &later); + void load_existing_entries(pwl::DeferredContexts &later); void wake_up(); void process_work(); void flush_dirty_entries(Context *on_finish); - bool can_flush_entry(const std::shared_ptr log_entry); - Context *construct_flush_entry_ctx(const std::shared_ptr log_entry); + bool can_flush_entry(const std::shared_ptr log_entry); + Context *construct_flush_entry_ctx(const std::shared_ptr log_entry); void persist_last_flushed_sync_gen(); - bool handle_flushed_sync_point(std::shared_ptr log_entry); - void sync_point_writer_flushed(std::shared_ptr log_entry); + bool handle_flushed_sync_point(std::shared_ptr log_entry); + void sync_point_writer_flushed(std::shared_ptr log_entry); void process_writeback_dirty_entries(); - bool can_retire_entry(const std::shared_ptr log_entry); + bool can_retire_entry(const std::shared_ptr log_entry); bool retire_entries(const unsigned long int frees_per_tx); - void init_flush_new_sync_point(rwl::DeferredContexts &later); - void new_sync_point(rwl::DeferredContexts &later); - rwl::C_FlushRequest>* make_flush_req(Context *on_finish); - void flush_new_sync_point_if_needed(C_FlushRequestT *flush_req, rwl::DeferredContexts &later); + void init_flush_new_sync_point(pwl::DeferredContexts &later); + void new_sync_point(pwl::DeferredContexts &later); + pwl::C_FlushRequest>* make_flush_req(Context *on_finish); + void flush_new_sync_point_if_needed(C_FlushRequestT *flush_req, pwl::DeferredContexts &later); void dispatch_deferred_writes(void); void alloc_and_dispatch_io_req(C_BlockIORequestT *write_req); void append_scheduled_ops(void); void enlist_op_appender(); - void schedule_append(rwl::GenericLogOperations &ops); + void schedule_append(pwl::GenericLogOperations &ops); void flush_then_append_scheduled_ops(void); void enlist_op_flusher(); - void alloc_op_log_entries(rwl::GenericLogOperations &ops); - void flush_op_log_entries(rwl::GenericLogOperationsVector &ops); - int append_op_log_entries(rwl::GenericLogOperations &ops); - void complete_op_log_entries(rwl::GenericLogOperations &&ops, const int r); - void schedule_complete_op_log_entries(rwl::GenericLogOperations &&ops, const int r); + void alloc_op_log_entries(pwl::GenericLogOperations &ops); + void flush_op_log_entries(pwl::GenericLogOperationsVector &ops); + int append_op_log_entries(pwl::GenericLogOperations &ops); + void complete_op_log_entries(pwl::GenericLogOperations &&ops, const int r); + void schedule_complete_op_log_entries(pwl::GenericLogOperations &&ops, const int r); void internal_flush(bool invalidate, Context *on_finish); }; +} // namespace pwl } // namespace cache } // namespace librbd -extern template class librbd::cache::AbstractWriteLog; +extern template class librbd::cache::pwl::AbstractWriteLog; #endif // CEPH_LIBRBD_CACHE_PARENT_WRITE_LOG diff --git a/src/librbd/cache/rwl/ImageCacheState.cc b/src/librbd/cache/pwl/ImageCacheState.cc similarity index 91% rename from src/librbd/cache/rwl/ImageCacheState.cc rename to src/librbd/cache/pwl/ImageCacheState.cc index 945e39ed82e00..1aa9c73a7ec6b 100644 --- a/src/librbd/cache/rwl/ImageCacheState.cc +++ b/src/librbd/cache/pwl/ImageCacheState.cc @@ -3,7 +3,7 @@ #include "librbd/cache/Types.h" #include "librbd/cache/Utils.h" -#include "librbd/cache/rwl/ImageCacheState.h" +#include "librbd/cache/pwl/ImageCacheState.h" #include "librbd/ImageCtx.h" #include "librbd/Operations.h" #include "common/environment.h" @@ -12,14 +12,14 @@ #include "common/ceph_json.h" #undef dout_subsys -#define dout_subsys ceph_subsys_rbd_rwl +#define dout_subsys ceph_subsys_rbd_pwl #undef dout_prefix -#define dout_prefix *_dout << "librbd::cache::rwl::ImageCacheState: " \ +#define dout_prefix *_dout << "librbd::cache::pwl::ImageCacheState: " \ << __func__ << ": " namespace librbd { namespace cache { -namespace rwl { +namespace pwl { namespace { bool get_json_format(const std::string& s, JSONFormattable *f) { @@ -55,10 +55,10 @@ ImageCacheState::ImageCacheState( clean = (bool)f["clean"]; host = (string)f["rwl_host"]; path = (string)f["rwl_path"]; - uint64_t rwl_size; + uint64_t pwl_size; std::istringstream iss(f["rwl_size"]); - iss >> rwl_size; - size = rwl_size; + iss >> pwl_size; + size = pwl_size; // Others from config ConfigProxy &config = image_ctx->config; @@ -93,9 +93,9 @@ void ImageCacheState::dump(ceph::Formatter *f) const { ::encode_json("empty", empty, f); ::encode_json("clean", clean, f); ::encode_json("cache_type", (int)get_image_cache_type(), f); - ::encode_json("rwl_host", host, f); - ::encode_json("rwl_path", path, f); - ::encode_json("rwl_size", size, f); + ::encode_json("pwl_host", host, f); + ::encode_json("pwl_path", path, f); + ::encode_json("pwl_size", size, f); } template @@ -112,8 +112,8 @@ ImageCacheState* ImageCacheState::get_image_cache_state( IMAGE_CACHE_STATE, &cache_state_str); } - bool rwl_enabled = cache::util::is_rwl_enabled(*image_ctx); - bool cache_desired = rwl_enabled; + bool pwl_enabled = cache::util::is_pwl_enabled(*image_ctx); + bool cache_desired = pwl_enabled; cache_desired &= !image_ctx->read_only; cache_desired &= !image_ctx->test_features(RBD_FEATURE_MIGRATING); cache_desired &= !image_ctx->test_features(RBD_FEATURE_JOURNALING); @@ -173,8 +173,8 @@ bool ImageCacheState::is_valid() { return true; } -} // namespace rwl +} // namespace pwl } // namespace cache } // namespace librbd -template class librbd::cache::rwl::ImageCacheState; +template class librbd::cache::pwl::ImageCacheState; diff --git a/src/librbd/cache/rwl/ImageCacheState.h b/src/librbd/cache/pwl/ImageCacheState.h similarity index 92% rename from src/librbd/cache/rwl/ImageCacheState.h rename to src/librbd/cache/pwl/ImageCacheState.h index 751978e76ec4f..2bdf31ffeed71 100644 --- a/src/librbd/cache/rwl/ImageCacheState.h +++ b/src/librbd/cache/pwl/ImageCacheState.h @@ -15,7 +15,7 @@ namespace ceph { namespace librbd { namespace cache { -namespace rwl { +namespace pwl { template class ImageCacheState { @@ -53,10 +53,10 @@ public: bool is_valid(); }; -} // namespace rwl +} // namespace pwl } // namespace cache } // namespace librbd -extern template class librbd::cache::rwl::ImageCacheState; +extern template class librbd::cache::pwl::ImageCacheState; #endif // CEPH_LIBRBD_CACHE_RWL_IMAGE_CACHE_STATE_H diff --git a/src/librbd/cache/rwl/InitRequest.cc b/src/librbd/cache/pwl/InitRequest.cc similarity index 93% rename from src/librbd/cache/rwl/InitRequest.cc rename to src/librbd/cache/pwl/InitRequest.cc index 87e372af20d34..1519272463222 100644 --- a/src/librbd/cache/rwl/InitRequest.cc +++ b/src/librbd/cache/pwl/InitRequest.cc @@ -1,28 +1,28 @@ // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- // vim: ts=8 sw=2 smarttab -#include "librbd/cache/rwl/InitRequest.h" +#include "librbd/cache/pwl/InitRequest.h" #include "librbd/Utils.h" #include "common/dout.h" #include "common/errno.h" #include "librbd/asio/ContextWQ.h" #if defined(WITH_RBD_RWL) -#include "librbd/cache/rwl/ImageCacheState.h" +#include "librbd/cache/pwl/ImageCacheState.h" #include "librbd/cache/WriteLogCache.h" #endif // WITH_RBD_RWL #include "librbd/cache/Utils.h" #include "librbd/ImageCtx.h" -#define dout_subsys ceph_subsys_rbd_rwl +#define dout_subsys ceph_subsys_rbd_pwl #undef dout_prefix -#define dout_prefix *_dout << "librbd::cache::rwl:InitRequest " \ +#define dout_prefix *_dout << "librbd::cache::pwl:InitRequest " \ << this << " " << __func__ << ": " namespace librbd { namespace cache { -namespace rwl { +namespace pwl { using librbd::util::create_async_context_callback; using librbd::util::create_context_callback; @@ -164,8 +164,8 @@ void InitRequest::finish() { delete this; } -} // namespace rwl +} // namespace pwl } // namespace cache } // namespace librbd -template class librbd::cache::rwl::InitRequest; +template class librbd::cache::pwl::InitRequest; diff --git a/src/librbd/cache/rwl/InitRequest.h b/src/librbd/cache/pwl/InitRequest.h similarity index 91% rename from src/librbd/cache/rwl/InitRequest.h rename to src/librbd/cache/pwl/InitRequest.h index 9d18e678354db..a18bfa3bb6daa 100644 --- a/src/librbd/cache/rwl/InitRequest.h +++ b/src/librbd/cache/pwl/InitRequest.h @@ -11,7 +11,7 @@ namespace librbd { class ImageCtx; namespace cache { -namespace rwl { +namespace pwl { template class ImageCacheState; @@ -54,7 +54,7 @@ private: int m_error_result; - bool is_rwl_enabled(); + bool is_pwl_enabled(); void get_image_cache_state(); @@ -73,10 +73,10 @@ private: } }; -} // namespace rwl +} // namespace pwl } // namespace cache } // namespace librbd -extern template class librbd::cache::rwl::InitRequest; +extern template class librbd::cache::pwl::InitRequest; #endif // CEPH_LIBRBD_CACHE_RWL_INIT_REQUEST_H diff --git a/src/librbd/cache/rwl/LogEntry.cc b/src/librbd/cache/pwl/LogEntry.cc similarity index 98% rename from src/librbd/cache/rwl/LogEntry.cc rename to src/librbd/cache/pwl/LogEntry.cc index a4fbad4d1ead4..4e7612c94f043 100644 --- a/src/librbd/cache/rwl/LogEntry.cc +++ b/src/librbd/cache/pwl/LogEntry.cc @@ -5,16 +5,16 @@ #include "LogEntry.h" #include "librbd/cache/ImageWriteback.h" -#define dout_subsys ceph_subsys_rbd_rwl +#define dout_subsys ceph_subsys_rbd_pwl #undef dout_prefix -#define dout_prefix *_dout << "librbd::cache::rwl::LogEntry: " << this << " " \ +#define dout_prefix *_dout << "librbd::cache::pwl::LogEntry: " << this << " " \ << __func__ << ": " namespace librbd { namespace cache { -namespace rwl { +namespace pwl { std::ostream& GenericLogEntry::format(std::ostream &os) const { os << "ram_entry=[" << ram_entry << "], " @@ -223,6 +223,6 @@ std::ostream &operator<<(std::ostream &os, return entry.format(os); } -} // namespace rwl +} // namespace pwl } // namespace cache } // namespace librbd diff --git a/src/librbd/cache/rwl/LogEntry.h b/src/librbd/cache/pwl/LogEntry.h similarity index 98% rename from src/librbd/cache/rwl/LogEntry.h rename to src/librbd/cache/pwl/LogEntry.h index df34d8a95d0e0..fb0f7d3fd0b42 100644 --- a/src/librbd/cache/rwl/LogEntry.h +++ b/src/librbd/cache/pwl/LogEntry.h @@ -6,14 +6,14 @@ #include "common/ceph_mutex.h" #include "librbd/Utils.h" -#include "librbd/cache/rwl/Types.h" +#include "librbd/cache/pwl/Types.h" #include #include namespace librbd { namespace cache { class ImageWritebackInterface; -namespace rwl { +namespace pwl { class SyncPointLogEntry; class GenericWriteLogEntry; @@ -158,12 +158,12 @@ public: const uint64_t image_offset_bytes, const uint64_t write_bytes) : GenericWriteLogEntry(sync_point_entry, image_offset_bytes, write_bytes), m_entry_bl_lock(ceph::make_mutex(util::unique_lock_name( - "librbd::cache::rwl::WriteLogEntry::m_entry_bl_lock", this))) + "librbd::cache::pwl::WriteLogEntry::m_entry_bl_lock", this))) { } WriteLogEntry(const uint64_t image_offset_bytes, const uint64_t write_bytes) : GenericWriteLogEntry(nullptr, image_offset_bytes, write_bytes), m_entry_bl_lock(ceph::make_mutex(util::unique_lock_name( - "librbd::cache::rwl::WriteLogEntry::m_entry_bl_lock", this))) + "librbd::cache::pwl::WriteLogEntry::m_entry_bl_lock", this))) { } ~WriteLogEntry() override {}; WriteLogEntry(const WriteLogEntry&) = delete; @@ -260,7 +260,7 @@ public: const WriteSameLogEntry &entry); }; -} // namespace rwl +} // namespace pwl } // namespace cache } // namespace librbd diff --git a/src/librbd/cache/rwl/LogMap.cc b/src/librbd/cache/pwl/LogMap.cc similarity index 97% rename from src/librbd/cache/rwl/LogMap.cc rename to src/librbd/cache/pwl/LogMap.cc index e432da7b671af..d05612ac4d31e 100644 --- a/src/librbd/cache/rwl/LogMap.cc +++ b/src/librbd/cache/pwl/LogMap.cc @@ -4,15 +4,15 @@ #include "LogMap.h" #include "include/ceph_assert.h" #include "librbd/Utils.h" -#include "librbd/cache/rwl/LogEntry.h" +#include "librbd/cache/pwl/LogEntry.h" namespace librbd { namespace cache { -namespace rwl { +namespace pwl { -#define dout_subsys ceph_subsys_rbd_rwl +#define dout_subsys ceph_subsys_rbd_pwl #undef dout_prefix -#define dout_prefix *_dout << "librbd::cache::rwl::LogMap: " << this << " " \ +#define dout_prefix *_dout << "librbd::cache::pwl::LogMap: " << this << " " \ << __func__ << ": " template std::ostream &operator<<(std::ostream &os, @@ -37,7 +37,7 @@ template LogMap::LogMap(CephContext *cct) : m_cct(cct), m_lock(ceph::make_mutex(util::unique_lock_name( - "librbd::cache::rwl::LogMap::m_lock", this))) { + "librbd::cache::pwl::LogMap::m_lock", this))) { } /** @@ -271,8 +271,8 @@ bool LogMap::LogMapEntryCompare::operator()(const LogMapEntry &lhs, return false; } -} //namespace rwl +} //namespace pwl } //namespace cache } //namespace librbd -template class librbd::cache::rwl::LogMap; +template class librbd::cache::pwl::LogMap; diff --git a/src/librbd/cache/rwl/LogMap.h b/src/librbd/cache/pwl/LogMap.h similarity index 98% rename from src/librbd/cache/rwl/LogMap.h rename to src/librbd/cache/pwl/LogMap.h index fcf29d07369ec..a053078961755 100644 --- a/src/librbd/cache/rwl/LogMap.h +++ b/src/librbd/cache/pwl/LogMap.h @@ -9,7 +9,7 @@ namespace librbd { namespace cache { -namespace rwl { +namespace pwl { /** * WriteLogMap: maps block extents to GenericWriteLogEntries @@ -74,7 +74,7 @@ private: BlockExtentToLogMapEntries m_block_to_log_entry_map; }; -} //namespace rwl +} //namespace pwl } //namespace cache } //namespace librbd diff --git a/src/librbd/cache/rwl/LogOperation.cc b/src/librbd/cache/pwl/LogOperation.cc similarity index 95% rename from src/librbd/cache/rwl/LogOperation.cc rename to src/librbd/cache/pwl/LogOperation.cc index 5376f5836e7ef..d47eb3a066e1f 100644 --- a/src/librbd/cache/rwl/LogOperation.cc +++ b/src/librbd/cache/pwl/LogOperation.cc @@ -3,18 +3,18 @@ #include #include "LogOperation.h" -#include "librbd/cache/rwl/Types.h" +#include "librbd/cache/pwl/Types.h" -#define dout_subsys ceph_subsys_rbd_rwl +#define dout_subsys ceph_subsys_rbd_pwl #undef dout_prefix -#define dout_prefix *_dout << "librbd::cache::rwl::LogOperation: " << this << " " \ +#define dout_prefix *_dout << "librbd::cache::pwl::LogOperation: " << this << " " \ << __func__ << ": " namespace librbd { namespace cache { -namespace rwl { +namespace pwl { GenericLogOperation::GenericLogOperation(const utime_t dispatch_time, PerfCounters *perfcounter) : m_perfcounter(perfcounter), dispatch_time(dispatch_time) { @@ -115,7 +115,7 @@ GenericWriteLogOperation::GenericWriteLogOperation(std::shared_ptr sy CephContext *cct) : GenericLogOperation(dispatch_time, perfcounter), m_lock(ceph::make_mutex(util::unique_lock_name( - "librbd::cache::rwl::GenericWriteLogOperation::m_lock", this))), + "librbd::cache::pwl::GenericWriteLogOperation::m_lock", this))), m_cct(cct), sync_point(sync_point) { } @@ -207,18 +207,18 @@ std::ostream &operator<<(std::ostream &os, void WriteLogOperation::complete(int result) { GenericWriteLogOperation::complete(result); - m_perfcounter->tinc(l_librbd_rwl_log_op_dis_to_buf_t, buf_persist_time - dispatch_time); + m_perfcounter->tinc(l_librbd_pwl_log_op_dis_to_buf_t, buf_persist_time - dispatch_time); utime_t buf_lat = buf_persist_comp_time - buf_persist_time; - m_perfcounter->tinc(l_librbd_rwl_log_op_buf_to_bufc_t, buf_lat); - m_perfcounter->hinc(l_librbd_rwl_log_op_buf_to_bufc_t_hist, buf_lat.to_nsec(), + m_perfcounter->tinc(l_librbd_pwl_log_op_buf_to_bufc_t, buf_lat); + m_perfcounter->hinc(l_librbd_pwl_log_op_buf_to_bufc_t_hist, buf_lat.to_nsec(), log_entry->ram_entry.write_bytes); - m_perfcounter->tinc(l_librbd_rwl_log_op_buf_to_app_t, log_append_time - buf_persist_time); + m_perfcounter->tinc(l_librbd_pwl_log_op_buf_to_app_t, log_append_time - buf_persist_time); } void WriteLogOperation::copy_bl_to_pmem_buffer() { /* operation is a shared_ptr, so write_op is only good as long as operation is in scope */ bufferlist::iterator i(&bl); - m_perfcounter->inc(l_librbd_rwl_log_op_bytes, log_entry->write_bytes()); + m_perfcounter->inc(l_librbd_pwl_log_op_bytes, log_entry->write_bytes()); ldout(m_cct, 20) << bl << dendl; i.copy((unsigned)log_entry->write_bytes(), (char*)log_entry->pmem_buffer); } @@ -333,6 +333,6 @@ std::ostream &operator<<(std::ostream &os, return op.format(os); } -} // namespace rwl +} // namespace pwl } // namespace cache } // namespace librbd diff --git a/src/librbd/cache/rwl/LogOperation.h b/src/librbd/cache/pwl/LogOperation.h similarity index 98% rename from src/librbd/cache/rwl/LogOperation.h rename to src/librbd/cache/pwl/LogOperation.h index ad12f6aac460f..8ae6351cc1b9d 100644 --- a/src/librbd/cache/rwl/LogOperation.h +++ b/src/librbd/cache/pwl/LogOperation.h @@ -5,12 +5,12 @@ #define CEPH_LIBRBD_CACHE_RWL_LOG_OPERATION_H #include "include/utime.h" -#include "librbd/cache/rwl/LogEntry.h" -#include "librbd/cache/rwl/SyncPoint.h" +#include "librbd/cache/pwl/LogEntry.h" +#include "librbd/cache/pwl/SyncPoint.h" namespace librbd { namespace cache { -namespace rwl { +namespace pwl { struct WriteBufferAllocation; class WriteLogOperationSet; @@ -224,7 +224,7 @@ public: const WriteSameLogOperation &op); }; -} // namespace rwl +} // namespace pwl } // namespace cache } // namespace librbd diff --git a/src/librbd/cache/rwl/ReadRequest.cc b/src/librbd/cache/pwl/ReadRequest.cc similarity index 77% rename from src/librbd/cache/rwl/ReadRequest.cc rename to src/librbd/cache/pwl/ReadRequest.cc index d9860604f7b50..766e33febf17a 100644 --- a/src/librbd/cache/rwl/ReadRequest.cc +++ b/src/librbd/cache/pwl/ReadRequest.cc @@ -3,14 +3,14 @@ #include "ReadRequest.h" -#define dout_subsys ceph_subsys_rbd_rwl +#define dout_subsys ceph_subsys_rbd_pwl #undef dout_prefix -#define dout_prefix *_dout << "librbd::cache::rwl::ReadRequest: " << this << " " \ +#define dout_prefix *_dout << "librbd::cache::pwl::ReadRequest: " << this << " " \ << __func__ << ": " namespace librbd { namespace cache { -namespace rwl { +namespace pwl { void C_ReadRequest::finish(int r) { ldout(m_cct, 20) << "(" << get_name() << "): r=" << r << dendl; @@ -50,19 +50,19 @@ void C_ReadRequest::finish(int r) { utime_t now = ceph_clock_now(); ceph_assert((int)m_out_bl->length() == hit_bytes + miss_bytes); m_on_finish->complete(r); - m_perfcounter->inc(l_librbd_rwl_rd_bytes, hit_bytes + miss_bytes); - m_perfcounter->inc(l_librbd_rwl_rd_hit_bytes, hit_bytes); - m_perfcounter->tinc(l_librbd_rwl_rd_latency, now - m_arrived_time); + m_perfcounter->inc(l_librbd_pwl_rd_bytes, hit_bytes + miss_bytes); + m_perfcounter->inc(l_librbd_pwl_rd_hit_bytes, hit_bytes); + m_perfcounter->tinc(l_librbd_pwl_rd_latency, now - m_arrived_time); if (!misses) { - m_perfcounter->inc(l_librbd_rwl_rd_hit_req, 1); - m_perfcounter->tinc(l_librbd_rwl_rd_hit_latency, now - m_arrived_time); + m_perfcounter->inc(l_librbd_pwl_rd_hit_req, 1); + m_perfcounter->tinc(l_librbd_pwl_rd_hit_latency, now - m_arrived_time); } else { if (hits) { - m_perfcounter->inc(l_librbd_rwl_rd_part_hit_req, 1); + m_perfcounter->inc(l_librbd_pwl_rd_part_hit_req, 1); } } } -} // namespace rwl +} // namespace pwl } // namespace cache } // namespace librbd diff --git a/src/librbd/cache/rwl/ReadRequest.h b/src/librbd/cache/pwl/ReadRequest.h similarity index 88% rename from src/librbd/cache/rwl/ReadRequest.h rename to src/librbd/cache/pwl/ReadRequest.h index 9daf7d10499b9..7c953547c875d 100644 --- a/src/librbd/cache/rwl/ReadRequest.h +++ b/src/librbd/cache/pwl/ReadRequest.h @@ -5,13 +5,13 @@ #define CEPH_LIBRBD_CACHE_RWL_READ_REQUEST_H #include "include/Context.h" -#include "librbd/cache/rwl/Types.h" +#include "librbd/cache/pwl/Types.h" namespace librbd { namespace cache { -namespace rwl { +namespace pwl { -typedef std::vector ImageExtentBufs; +typedef std::vector ImageExtentBufs; class C_ReadRequest : public Context { public: @@ -38,7 +38,7 @@ private: PerfCounters *m_perfcounter; }; -} // namespace rwl +} // namespace pwl } // namespace cache } // namespace librbd diff --git a/src/librbd/cache/ReplicatedWriteLog.cc b/src/librbd/cache/pwl/ReplicatedWriteLog.cc similarity index 51% rename from src/librbd/cache/ReplicatedWriteLog.cc rename to src/librbd/cache/pwl/ReplicatedWriteLog.cc index bb67d96f4ba40..5db62a5fd50f1 100644 --- a/src/librbd/cache/ReplicatedWriteLog.cc +++ b/src/librbd/cache/pwl/ReplicatedWriteLog.cc @@ -13,30 +13,30 @@ #include "common/Timer.h" #include "common/perf_counters.h" #include "librbd/ImageCtx.h" -#include "librbd/cache/rwl/ImageCacheState.h" -#include "librbd/cache/rwl/LogEntry.h" +#include "librbd/cache/pwl/ImageCacheState.h" +#include "librbd/cache/pwl/LogEntry.h" #include #include #undef dout_subsys -#define dout_subsys ceph_subsys_rbd_rwl +#define dout_subsys ceph_subsys_rbd_pwl #undef dout_prefix -#define dout_prefix *_dout << "librbd::cache::ReplicatedWriteLog: " << this << " " \ +#define dout_prefix *_dout << "librbd::cache::pwl::ReplicatedWriteLog: " << this << " " \ << __func__ << ": " namespace librbd { - namespace cache { - - using namespace librbd::cache::rwl; - - template - ReplicatedWriteLog::ReplicatedWriteLog(I &image_ctx, librbd::cache::rwl::ImageCacheState* cache_state) - : AbstractWriteLog(image_ctx, cache_state) - { - } - - - } // namespace cache +namespace cache { +namespace pwl { +using namespace librbd::cache::pwl; + +template +ReplicatedWriteLog::ReplicatedWriteLog(I &image_ctx, librbd::cache::pwl::ImageCacheState* cache_state) +: AbstractWriteLog(image_ctx, cache_state) +{ +} + +} // namespace pwl +} // namespace cache } // namespace librbd -template class librbd::cache::ReplicatedWriteLog; +template class librbd::cache::pwl::ReplicatedWriteLog; diff --git a/src/librbd/cache/ReplicatedWriteLog.h b/src/librbd/cache/pwl/ReplicatedWriteLog.h similarity index 63% rename from src/librbd/cache/ReplicatedWriteLog.h rename to src/librbd/cache/pwl/ReplicatedWriteLog.h index cd1963fe0acb6..dc1a46a4547c1 100644 --- a/src/librbd/cache/ReplicatedWriteLog.h +++ b/src/librbd/cache/pwl/ReplicatedWriteLog.h @@ -12,9 +12,9 @@ #include "librbd/Utils.h" #include "librbd/BlockGuard.h" #include "librbd/cache/Types.h" -#include "librbd/cache/rwl/LogOperation.h" -#include "librbd/cache/rwl/Request.h" -#include "librbd/cache/rwl/LogMap.h" +#include "librbd/cache/pwl/LogOperation.h" +#include "librbd/cache/pwl/Request.h" +#include "librbd/cache/pwl/LogMap.h" #include "AbstractWriteLog.h" #include #include @@ -28,31 +28,34 @@ struct ImageCtx; namespace cache { +namespace pwl { + template class ReplicatedWriteLog : public AbstractWriteLog { public: typedef io::Extent Extent; typedef io::Extents Extents; - ReplicatedWriteLog(ImageCtxT &image_ctx, librbd::cache::rwl::ImageCacheState* cache_state); + ReplicatedWriteLog(ImageCtxT &image_ctx, librbd::cache::pwl::ImageCacheState* cache_state); ~ReplicatedWriteLog(); ReplicatedWriteLog(const ReplicatedWriteLog&) = delete; ReplicatedWriteLog &operator=(const ReplicatedWriteLog&) = delete; private: using This = AbstractWriteLog; - using C_WriteRequestT = rwl::C_WriteRequest; - using C_BlockIORequestT = rwl::C_BlockIORequest; - using C_FlushRequestT = rwl::C_FlushRequest; - using C_DiscardRequestT = rwl::C_DiscardRequest; - using C_WriteSameRequestT = rwl::C_WriteSameRequest; - using C_CompAndWriteRequestT = rwl::C_CompAndWriteRequest; + using C_WriteRequestT = pwl::C_WriteRequest; + using C_BlockIORequestT = pwl::C_BlockIORequest; + using C_FlushRequestT = pwl::C_FlushRequest; + using C_DiscardRequestT = pwl::C_DiscardRequest; + using C_WriteSameRequestT = pwl::C_WriteSameRequest; + using C_CompAndWriteRequestT = pwl::C_CompAndWriteRequest; }; +} // namespace pwl } // namespace cache } // namespace librbd -extern template class librbd::cache::ReplicatedWriteLog; +extern template class librbd::cache::pwl::ReplicatedWriteLog; #endif // CEPH_LIBRBD_CACHE_REPLICATED_WRITE_LOG diff --git a/src/librbd/cache/rwl/Request.cc b/src/librbd/cache/pwl/Request.cc similarity index 77% rename from src/librbd/cache/rwl/Request.cc rename to src/librbd/cache/pwl/Request.cc index 684883985d880..c30fb2203cbe9 100644 --- a/src/librbd/cache/rwl/Request.cc +++ b/src/librbd/cache/pwl/Request.cc @@ -3,30 +3,30 @@ #include "Request.h" #include "librbd/BlockGuard.h" -#include "librbd/cache/rwl/LogEntry.h" -#include "librbd/cache/ReplicatedWriteLog.h" +#include "librbd/cache/pwl/LogEntry.h" +#include "librbd/cache/pwl/ReplicatedWriteLog.h" -#define dout_subsys ceph_subsys_rbd_rwl +#define dout_subsys ceph_subsys_rbd_pwl #undef dout_prefix -#define dout_prefix *_dout << "librbd::cache::rwl::Request: " << this << " " \ +#define dout_prefix *_dout << "librbd::cache::pwl::Request: " << this << " " \ << __func__ << ": " namespace librbd { namespace cache { -namespace rwl { +namespace pwl { template -C_BlockIORequest::C_BlockIORequest(T &rwl, const utime_t arrived, io::Extents &&extents, +C_BlockIORequest::C_BlockIORequest(T &pwl, const utime_t arrived, io::Extents &&extents, bufferlist&& bl, const int fadvise_flags, Context *user_req) - : rwl(rwl), image_extents(std::move(extents)), + : pwl(pwl), image_extents(std::move(extents)), bl(std::move(bl)), fadvise_flags(fadvise_flags), user_req(user_req), image_extents_summary(image_extents), m_arrived_time(arrived) { - ldout(rwl.get_context(), 99) << this << dendl; + ldout(pwl.get_context(), 99) << this << dendl; } template C_BlockIORequest::~C_BlockIORequest() { - ldout(rwl.get_context(), 99) << this << dendl; + ldout(pwl.get_context(), 99) << this << dendl; ceph_assert(m_cell_released || !m_cell); } @@ -48,7 +48,7 @@ std::ostream &operator<<(std::ostream &os, template void C_BlockIORequest::set_cell(BlockGuardCell *cell) { - ldout(rwl.get_context(), 20) << this << " cell=" << cell << dendl; + ldout(pwl.get_context(), 20) << this << " cell=" << cell << dendl; ceph_assert(cell); ceph_assert(!m_cell); m_cell = cell; @@ -56,19 +56,19 @@ void C_BlockIORequest::set_cell(BlockGuardCell *cell) { template BlockGuardCell *C_BlockIORequest::get_cell(void) { - ldout(rwl.get_context(), 20) << this << " cell=" << m_cell << dendl; + ldout(pwl.get_context(), 20) << this << " cell=" << m_cell << dendl; return m_cell; } template void C_BlockIORequest::release_cell() { - ldout(rwl.get_context(), 20) << this << " cell=" << m_cell << dendl; + ldout(pwl.get_context(), 20) << this << " cell=" << m_cell << dendl; ceph_assert(m_cell); bool initial = false; if (m_cell_released.compare_exchange_strong(initial, true)) { - rwl.release_guarded_request(m_cell); + pwl.release_guarded_request(m_cell); } else { - ldout(rwl.get_context(), 5) << "cell " << m_cell << " already released for " << this << dendl; + ldout(pwl.get_context(), 5) << "cell " << m_cell << " already released for " << this << dendl; } } @@ -76,27 +76,27 @@ template void C_BlockIORequest::complete_user_request(int r) { bool initial = false; if (m_user_req_completed.compare_exchange_strong(initial, true)) { - ldout(rwl.get_context(), 15) << this << " completing user req" << dendl; + ldout(pwl.get_context(), 15) << this << " completing user req" << dendl; m_user_req_completed_time = ceph_clock_now(); user_req->complete(r); // Set user_req as null as it is deleted user_req = nullptr; } else { - ldout(rwl.get_context(), 20) << this << " user req already completed" << dendl; + ldout(pwl.get_context(), 20) << this << " user req already completed" << dendl; } } template void C_BlockIORequest::finish(int r) { - ldout(rwl.get_context(), 20) << this << dendl; + ldout(pwl.get_context(), 20) << this << dendl; complete_user_request(r); bool initial = false; if (m_finish_called.compare_exchange_strong(initial, true)) { - ldout(rwl.get_context(), 15) << this << " finishing" << dendl; + ldout(pwl.get_context(), 15) << this << " finishing" << dendl; finish_req(0); } else { - ldout(rwl.get_context(), 20) << this << " already finished" << dendl; + ldout(pwl.get_context(), 20) << this << " already finished" << dendl; ceph_assert(0); } } @@ -110,17 +110,17 @@ void C_BlockIORequest::deferred() { } template -C_WriteRequest::C_WriteRequest(T &rwl, const utime_t arrived, io::Extents &&image_extents, +C_WriteRequest::C_WriteRequest(T &pwl, const utime_t arrived, io::Extents &&image_extents, bufferlist&& bl, const int fadvise_flags, ceph::mutex &lock, PerfCounters *perfcounter, Context *user_req) - : C_BlockIORequest(rwl, arrived, std::move(image_extents), std::move(bl), fadvise_flags, user_req), + : C_BlockIORequest(pwl, arrived, std::move(image_extents), std::move(bl), fadvise_flags, user_req), m_perfcounter(perfcounter), m_lock(lock) { - ldout(rwl.get_context(), 99) << this << dendl; + ldout(pwl.get_context(), 99) << this << dendl; } template C_WriteRequest::~C_WriteRequest() { - ldout(rwl.get_context(), 99) << this << dendl; + ldout(pwl.get_context(), 99) << this << dendl; } template @@ -136,7 +136,7 @@ std::ostream &operator<<(std::ostream &os, template void C_WriteRequest::blockguard_acquired(GuardedRequestFunctionContext &guard_ctx) { - ldout(rwl.get_context(), 20) << __func__ << " write_req=" << this << " cell=" << guard_ctx.cell << dendl; + ldout(pwl.get_context(), 20) << __func__ << " write_req=" << this << " cell=" << guard_ctx.cell << dendl; ceph_assert(guard_ctx.cell); this->detained = guard_ctx.state.detained; /* overlapped */ @@ -146,11 +146,11 @@ void C_WriteRequest::blockguard_acquired(GuardedRequestFunctionContext &guard template void C_WriteRequest::finish_req(int r) { - ldout(rwl.get_context(), 15) << "write_req=" << this << " cell=" << this->get_cell() << dendl; + ldout(pwl.get_context(), 15) << "write_req=" << this << " cell=" << this->get_cell() << dendl; /* Completed to caller by here (in finish(), which calls this) */ utime_t now = ceph_clock_now(); - rwl.release_write_lanes(this); + pwl.release_write_lanes(this); ceph_assert(m_resources.allocated); m_resources.allocated = false; this->release_cell(); /* TODO: Consider doing this in appending state */ @@ -190,7 +190,7 @@ void C_WriteRequest::setup_buffer_resources( template std::shared_ptr C_WriteRequest::create_operation(uint64_t offset, uint64_t len) { - return std::make_shared(*op_set, offset, len, rwl.get_context()); + return std::make_shared(*op_set, offset, len, pwl.get_context()); } template @@ -198,8 +198,8 @@ void C_WriteRequest::setup_log_operations(DeferredContexts &on_exit) { GenericWriteLogEntries log_entries; { std::lock_guard locker(m_lock); - std::shared_ptr current_sync_point = rwl.get_current_sync_point(); - if ((!rwl.get_persist_on_flush() && current_sync_point->log_entry->writes_completed) || + std::shared_ptr current_sync_point = pwl.get_current_sync_point(); + if ((!pwl.get_persist_on_flush() && current_sync_point->log_entry->writes_completed) || (current_sync_point->log_entry->writes > MAX_WRITES_PER_SYNC_POINT) || (current_sync_point->log_entry->bytes > MAX_BYTES_PER_SYNC_POINT)) { /* Create new sync point and persist the previous one. This sequenced @@ -213,17 +213,17 @@ void C_WriteRequest::setup_log_operations(DeferredContexts &on_exit) { * write (for writes observed here to have been in flight simultaneously) * at a time in persist-on-write mode. */ - rwl.flush_new_sync_point(nullptr, on_exit); - current_sync_point = rwl.get_current_sync_point(); + pwl.flush_new_sync_point(nullptr, on_exit); + current_sync_point = pwl.get_current_sync_point(); } - uint64_t current_sync_gen = rwl.get_current_sync_gen(); + uint64_t current_sync_gen = pwl.get_current_sync_gen(); op_set = make_unique(this->m_dispatched_time, m_perfcounter, current_sync_point, - rwl.get_persist_on_flush(), - rwl.get_context(), this); - ldout(rwl.get_context(), 20) << "write_req=" << *this << " op_set=" << op_set.get() << dendl; + pwl.get_persist_on_flush(), + pwl.get_context(), this); + ldout(pwl.get_context(), 20) << "write_req=" << *this << " op_set=" << op_set.get() << dendl; ceph_assert(m_resources.allocated); /* op_set->operations initialized differently for plain write or write same */ auto allocation = m_resources.buffers.begin(); @@ -234,16 +234,16 @@ void C_WriteRequest::setup_log_operations(DeferredContexts &on_exit) { this->op_set->operations.emplace_back(operation); /* A WS is also a write */ - ldout(rwl.get_context(), 20) << "write_req=" << *this << " op_set=" << op_set.get() + ldout(pwl.get_context(), 20) << "write_req=" << *this << " op_set=" << op_set.get() << " operation=" << operation << dendl; log_entries.emplace_back(operation->log_entry); if (!op_set->persist_on_flush) { - rwl.inc_last_op_sequence_num(); + pwl.inc_last_op_sequence_num(); } operation->init(true, allocation, current_sync_gen, - rwl.get_last_op_sequence_num(), this->bl, buffer_offset, op_set->persist_on_flush); + pwl.get_last_op_sequence_num(), this->bl, buffer_offset, op_set->persist_on_flush); buffer_offset += operation->log_entry->write_bytes(); - ldout(rwl.get_context(), 20) << "operation=[" << *operation << "]" << dendl; + ldout(pwl.get_context(), 20) << "operation=[" << *operation << "]" << dendl; allocation++; } } @@ -255,7 +255,7 @@ void C_WriteRequest::setup_log_operations(DeferredContexts &on_exit) { for (auto &operation : op_set->operations) { operation->copy_bl_to_pmem_buffer(); } - rwl.add_into_log_map(log_entries); + pwl.add_into_log_map(log_entries); } template @@ -278,12 +278,12 @@ void C_WriteRequest::schedule_append() { if (m_do_early_flush) { /* This caller is waiting for persist, so we'll use their thread to * expedite it */ - rwl.flush_pmem_buffer(this->op_set->operations); - rwl.schedule_append(this->op_set->operations); + pwl.flush_pmem_buffer(this->op_set->operations); + pwl.schedule_append(this->op_set->operations); } else { /* This is probably not still the caller's thread, so do the payload * flushing/replicating later. */ - rwl.schedule_flush_and_append(this->op_set->operations); + pwl.schedule_flush_and_append(this->op_set->operations); } } @@ -298,7 +298,7 @@ void C_WriteRequest::schedule_append() { template bool C_WriteRequest::alloc_resources() { this->allocated_time = ceph_clock_now(); - return rwl.alloc_resources(this); + return pwl.alloc_resources(this); } /** @@ -310,7 +310,7 @@ bool C_WriteRequest::alloc_resources() { template void C_WriteRequest::dispatch() { - CephContext *cct = rwl.get_context(); + CephContext *cct = pwl.get_context(); DeferredContexts on_exit; utime_t now = ceph_clock_now(); this->m_dispatched_time = now; @@ -347,40 +347,40 @@ void C_WriteRequest::dispatch() } template -C_FlushRequest::C_FlushRequest(T &rwl, const utime_t arrived, +C_FlushRequest::C_FlushRequest(T &pwl, const utime_t arrived, io::Extents &&image_extents, bufferlist&& bl, const int fadvise_flags, ceph::mutex &lock, PerfCounters *perfcounter, Context *user_req) - : C_BlockIORequest(rwl, arrived, std::move(image_extents), std::move(bl), + : C_BlockIORequest(pwl, arrived, std::move(image_extents), std::move(bl), fadvise_flags, user_req), m_lock(lock), m_perfcounter(perfcounter) { - ldout(rwl.get_context(), 20) << this << dendl; + ldout(pwl.get_context(), 20) << this << dendl; } template void C_FlushRequest::finish_req(int r) { - ldout(rwl.get_context(), 20) << "flush_req=" << this + ldout(pwl.get_context(), 20) << "flush_req=" << this << " cell=" << this->get_cell() << dendl; /* Block guard already released */ ceph_assert(!this->get_cell()); /* Completed to caller by here */ utime_t now = ceph_clock_now(); - m_perfcounter->tinc(l_librbd_rwl_aio_flush_latency, now - this->m_arrived_time); + m_perfcounter->tinc(l_librbd_pwl_aio_flush_latency, now - this->m_arrived_time); } template bool C_FlushRequest::alloc_resources() { - ldout(rwl.get_context(), 20) << "req type=" << get_name() << " " + ldout(pwl.get_context(), 20) << "req type=" << get_name() << " " << "req=[" << *this << "]" << dendl; - return rwl.alloc_resources(this); + return pwl.alloc_resources(this); } template void C_FlushRequest::dispatch() { utime_t now = ceph_clock_now(); - ldout(rwl.get_context(), 20) << "req type=" << get_name() << " " + ldout(pwl.get_context(), 20) << "req type=" << get_name() << " " << "req=[" << *this << "]" << dendl; ceph_assert(this->m_resources.allocated); this->m_dispatched_time = now; @@ -389,10 +389,10 @@ void C_FlushRequest::dispatch() { to_append, now, m_perfcounter, - rwl.get_context()); + pwl.get_context()); - m_perfcounter->inc(l_librbd_rwl_log_ops, 1); - rwl.schedule_append(op); + m_perfcounter->inc(l_librbd_pwl_log_ops, 1); + pwl.schedule_append(op); } template @@ -412,26 +412,26 @@ std::ostream &operator<<(std::ostream &os, } template -C_DiscardRequest::C_DiscardRequest(T &rwl, const utime_t arrived, io::Extents &&image_extents, +C_DiscardRequest::C_DiscardRequest(T &pwl, const utime_t arrived, io::Extents &&image_extents, uint32_t discard_granularity_bytes, ceph::mutex &lock, PerfCounters *perfcounter, Context *user_req) - : C_BlockIORequest(rwl, arrived, std::move(image_extents), bufferlist(), 0, user_req), + : C_BlockIORequest(pwl, arrived, std::move(image_extents), bufferlist(), 0, user_req), m_discard_granularity_bytes(discard_granularity_bytes), m_lock(lock), m_perfcounter(perfcounter) { - ldout(rwl.get_context(), 20) << this << dendl; + ldout(pwl.get_context(), 20) << this << dendl; } template C_DiscardRequest::~C_DiscardRequest() { - ldout(rwl.get_context(), 20) << this << dendl; + ldout(pwl.get_context(), 20) << this << dendl; } template bool C_DiscardRequest::alloc_resources() { - ldout(rwl.get_context(), 20) << "req type=" << get_name() << " " + ldout(pwl.get_context(), 20) << "req type=" << get_name() << " " << "req=[" << *this << "]" << dendl; - return rwl.alloc_resources(this); + return pwl.alloc_resources(this); } template @@ -439,44 +439,44 @@ void C_DiscardRequest::setup_log_operations() { std::lock_guard locker(m_lock); GenericWriteLogEntries log_entries; for (auto &extent : this->image_extents) { - op = std::make_shared(rwl.get_current_sync_point(), + op = std::make_shared(pwl.get_current_sync_point(), extent.first, extent.second, m_discard_granularity_bytes, this->m_dispatched_time, m_perfcounter, - rwl.get_context()); + pwl.get_context()); log_entries.emplace_back(op->log_entry); break; } - uint64_t current_sync_gen = rwl.get_current_sync_gen(); - bool persist_on_flush = rwl.get_persist_on_flush(); + uint64_t current_sync_gen = pwl.get_current_sync_gen(); + bool persist_on_flush = pwl.get_persist_on_flush(); if (!persist_on_flush) { - rwl.inc_last_op_sequence_num(); + pwl.inc_last_op_sequence_num(); } auto discard_req = this; Context *on_write_persist = new LambdaContext( [this, discard_req](int r) { - ldout(rwl.get_context(), 20) << "discard_req=" << discard_req + ldout(pwl.get_context(), 20) << "discard_req=" << discard_req << " cell=" << discard_req->get_cell() << dendl; ceph_assert(discard_req->get_cell()); discard_req->complete_user_request(r); discard_req->release_cell(); }); - op->init(current_sync_gen, persist_on_flush, rwl.get_last_op_sequence_num(), on_write_persist); - rwl.add_into_log_map(log_entries); + op->init(current_sync_gen, persist_on_flush, pwl.get_last_op_sequence_num(), on_write_persist); + pwl.add_into_log_map(log_entries); } template void C_DiscardRequest::dispatch() { utime_t now = ceph_clock_now(); - ldout(rwl.get_context(), 20) << "req type=" << get_name() << " " + ldout(pwl.get_context(), 20) << "req type=" << get_name() << " " << "req=[" << *this << "]" << dendl; ceph_assert(this->m_resources.allocated); this->m_dispatched_time = now; setup_log_operations(); - m_perfcounter->inc(l_librbd_rwl_log_ops, 1); - rwl.schedule_append(op); + m_perfcounter->inc(l_librbd_pwl_log_ops, 1); + pwl.schedule_append(op); } template @@ -496,7 +496,7 @@ void C_DiscardRequest::setup_buffer_resources( template void C_DiscardRequest::blockguard_acquired(GuardedRequestFunctionContext &guard_ctx) { - ldout(rwl.get_context(), 20) << " cell=" << guard_ctx.cell << dendl; + ldout(pwl.get_context(), 20) << " cell=" << guard_ctx.cell << dendl; ceph_assert(guard_ctx.cell); this->detained = guard_ctx.state.detained; /* overlapped */ @@ -516,16 +516,16 @@ std::ostream &operator<<(std::ostream &os, } template -C_WriteSameRequest::C_WriteSameRequest(T &rwl, const utime_t arrived, io::Extents &&image_extents, +C_WriteSameRequest::C_WriteSameRequest(T &pwl, const utime_t arrived, io::Extents &&image_extents, bufferlist&& bl, const int fadvise_flags, ceph::mutex &lock, PerfCounters *perfcounter, Context *user_req) - : C_WriteRequest(rwl, arrived, std::move(image_extents), std::move(bl), fadvise_flags, lock, perfcounter, user_req) { - ldout(rwl.get_context(), 20) << this << dendl; + : C_WriteRequest(pwl, arrived, std::move(image_extents), std::move(bl), fadvise_flags, lock, perfcounter, user_req) { + ldout(pwl.get_context(), 20) << this << dendl; } template C_WriteSameRequest::~C_WriteSameRequest() { - ldout(rwl.get_context(), 20) << this << dendl; + ldout(pwl.get_context(), 20) << this << dendl; } template @@ -533,9 +533,9 @@ void C_WriteSameRequest::update_req_stats(utime_t &now) { /* Write same stats excluded from most write stats * because the read phase will make them look like slow writes in * those histograms. */ - ldout(rwl.get_context(), 20) << this << dendl; + ldout(pwl.get_context(), 20) << this << dendl; utime_t comp_latency = now - this->m_arrived_time; - this->m_perfcounter->tinc(l_librbd_rwl_ws_latency, comp_latency); + this->m_perfcounter->tinc(l_librbd_pwl_ws_latency, comp_latency); } /* Write sames will allocate one buffer, the size of the repeating pattern */ @@ -544,7 +544,7 @@ void C_WriteSameRequest::setup_buffer_resources( uint64_t &bytes_cached, uint64_t &bytes_dirtied, uint64_t &bytes_allocated, uint64_t &number_lanes, uint64_t &number_log_entries, uint64_t &number_unpublished_reserves) { - ldout(rwl.get_context(), 20) << this << dendl; + ldout(pwl.get_context(), 20) << this << dendl; ceph_assert(this->image_extents.size() == 1); bytes_dirtied += this->image_extents[0].second; auto pattern_length = this->bl.length(); @@ -563,7 +563,7 @@ template std::shared_ptr C_WriteSameRequest::create_operation(uint64_t offset, uint64_t len) { ceph_assert(this->image_extents.size() == 1); return std::make_shared(*this->op_set.get(), offset, len, - this->bl.length(), rwl.get_context()); + this->bl.length(), pwl.get_context()); } template @@ -574,18 +574,18 @@ std::ostream &operator<<(std::ostream &os, } template -C_CompAndWriteRequest::C_CompAndWriteRequest(T &rwl, const utime_t arrived, io::Extents &&image_extents, +C_CompAndWriteRequest::C_CompAndWriteRequest(T &pwl, const utime_t arrived, io::Extents &&image_extents, bufferlist&& cmp_bl, bufferlist&& bl, uint64_t *mismatch_offset, int fadvise_flags, ceph::mutex &lock, PerfCounters *perfcounter, Context *user_req) - : C_WriteRequest(rwl, arrived, std::move(image_extents), std::move(bl), fadvise_flags, lock, perfcounter, user_req), + : C_WriteRequest(pwl, arrived, std::move(image_extents), std::move(bl), fadvise_flags, lock, perfcounter, user_req), mismatch_offset(mismatch_offset), cmp_bl(std::move(cmp_bl)) { - ldout(rwl.get_context(), 20) << dendl; + ldout(pwl.get_context(), 20) << dendl; } template C_CompAndWriteRequest::~C_CompAndWriteRequest() { - ldout(rwl.get_context(), 20) << dendl; + ldout(pwl.get_context(), 20) << dendl; } template @@ -604,10 +604,10 @@ void C_CompAndWriteRequest::update_req_stats(utime_t &now) { * stats because the read phase will make them look like slow writes in * those histograms. */ if (!compare_succeeded) { - this->m_perfcounter->inc(l_librbd_rwl_cmp_fails, 1); + this->m_perfcounter->inc(l_librbd_pwl_cmp_fails, 1); } utime_t comp_latency = now - this->m_arrived_time; - this->m_perfcounter->tinc(l_librbd_rwl_cmp_latency, comp_latency); + this->m_perfcounter->tinc(l_librbd_pwl_cmp_latency, comp_latency); } template @@ -621,13 +621,13 @@ std::ostream &operator<<(std::ostream &os, return os; } -} // namespace rwl +} // namespace pwl } // namespace cache } // namespace librbd -template class librbd::cache::rwl::C_BlockIORequest >; -template class librbd::cache::rwl::C_WriteRequest >; -template class librbd::cache::rwl::C_FlushRequest >; -template class librbd::cache::rwl::C_DiscardRequest >; -template class librbd::cache::rwl::C_WriteSameRequest >; -template class librbd::cache::rwl::C_CompAndWriteRequest >; +template class librbd::cache::pwl::C_BlockIORequest >; +template class librbd::cache::pwl::C_WriteRequest >; +template class librbd::cache::pwl::C_FlushRequest >; +template class librbd::cache::pwl::C_DiscardRequest >; +template class librbd::cache::pwl::C_WriteSameRequest >; +template class librbd::cache::pwl::C_CompAndWriteRequest >; diff --git a/src/librbd/cache/rwl/Request.h b/src/librbd/cache/pwl/Request.h similarity index 94% rename from src/librbd/cache/rwl/Request.h rename to src/librbd/cache/pwl/Request.h index 2ab58e51d7152..fd6fa71b9e235 100644 --- a/src/librbd/cache/rwl/Request.h +++ b/src/librbd/cache/pwl/Request.h @@ -6,14 +6,14 @@ #include "include/Context.h" #include "librbd/cache/ImageCache.h" -#include "librbd/cache/rwl/Types.h" -#include "librbd/cache/rwl/LogOperation.h" +#include "librbd/cache/pwl/Types.h" +#include "librbd/cache/pwl/LogOperation.h" namespace librbd { class BlockGuardCell; namespace cache { -namespace rwl { +namespace pwl { class GuardedRequestFunctionContext; @@ -33,7 +33,7 @@ struct WriteRequestResources { template class C_BlockIORequest : public Context { public: - T &rwl; + T &pwl; io::Extents image_extents; bufferlist bl; int fadvise_flags; @@ -45,7 +45,7 @@ public: bool waited_entries = false; /* This IO waited for free log entries */ bool waited_buffers = false; /* This IO waited for data buffers (pmemobj_reserve() failed) */ - C_BlockIORequest(T &rwl, const utime_t arrived, io::Extents &&extents, + C_BlockIORequest(T &pwl, const utime_t arrived, io::Extents &&extents, bufferlist&& bl, const int fadvise_flags, Context *user_req); ~C_BlockIORequest() override; C_BlockIORequest(const C_BlockIORequest&) = delete; @@ -129,10 +129,10 @@ private: template class C_WriteRequest : public C_BlockIORequest { public: - using C_BlockIORequest::rwl; + using C_BlockIORequest::pwl; unique_ptr op_set = nullptr; - C_WriteRequest(T &rwl, const utime_t arrived, io::Extents &&image_extents, + C_WriteRequest(T &pwl, const utime_t arrived, io::Extents &&image_extents, bufferlist&& bl, const int fadvise_flags, ceph::mutex &lock, PerfCounters *perfcounter, Context *user_req); @@ -194,11 +194,11 @@ private: template class C_FlushRequest : public C_BlockIORequest { public: - using C_BlockIORequest::rwl; + using C_BlockIORequest::pwl; bool internal = false; std::shared_ptr to_append; - C_FlushRequest(T &rwl, const utime_t arrived, + C_FlushRequest(T &pwl, const utime_t arrived, io::Extents &&image_extents, bufferlist&& bl, const int fadvise_flags, ceph::mutex &lock, PerfCounters *perfcounter, @@ -225,7 +225,7 @@ private: void finish_req(int r) override; void deferred_handler() override { - m_perfcounter->inc(l_librbd_rwl_aio_flush_def, 1); + m_perfcounter->inc(l_librbd_pwl_aio_flush_def, 1); } template @@ -241,10 +241,10 @@ private: template class C_DiscardRequest : public C_BlockIORequest { public: - using C_BlockIORequest::rwl; + using C_BlockIORequest::pwl; std::shared_ptr op; - C_DiscardRequest(T &rwl, const utime_t arrived, io::Extents &&image_extents, + C_DiscardRequest(T &pwl, const utime_t arrived, io::Extents &&image_extents, uint32_t discard_granularity_bytes, ceph::mutex &lock, PerfCounters *perfcounter, Context *user_req); @@ -286,8 +286,8 @@ private: template class C_WriteSameRequest : public C_WriteRequest { public: - using C_BlockIORequest::rwl; - C_WriteSameRequest(T &rwl, const utime_t arrived, io::Extents &&image_extents, + using C_BlockIORequest::pwl; + C_WriteSameRequest(T &pwl, const utime_t arrived, io::Extents &&image_extents, bufferlist&& bl, const int fadvise_flags, ceph::mutex &lock, PerfCounters *perfcounter, Context *user_req); @@ -320,12 +320,12 @@ public: template class C_CompAndWriteRequest : public C_WriteRequest { public: - using C_BlockIORequest::rwl; + using C_BlockIORequest::pwl; bool compare_succeeded = false; uint64_t *mismatch_offset; bufferlist cmp_bl; bufferlist read_bl; - C_CompAndWriteRequest(T &rwl, const utime_t arrived, io::Extents &&image_extents, + C_CompAndWriteRequest(T &pwl, const utime_t arrived, io::Extents &&image_extents, bufferlist&& cmp_bl, bufferlist&& bl, uint64_t *mismatch_offset, int fadvise_flags, ceph::mutex &lock, PerfCounters *perfcounter, Context *user_req); @@ -401,7 +401,7 @@ public: } }; -} // namespace rwl +} // namespace pwl } // namespace cache } // namespace librbd diff --git a/src/librbd/cache/rwl/ShutdownRequest.cc b/src/librbd/cache/pwl/ShutdownRequest.cc similarity index 94% rename from src/librbd/cache/rwl/ShutdownRequest.cc rename to src/librbd/cache/pwl/ShutdownRequest.cc index 8259662ae9731..d3eda226be277 100644 --- a/src/librbd/cache/rwl/ShutdownRequest.cc +++ b/src/librbd/cache/pwl/ShutdownRequest.cc @@ -1,7 +1,7 @@ // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- // vim: ts=8 sw=2 smarttab -#include "librbd/cache/rwl/ShutdownRequest.h" +#include "librbd/cache/pwl/ShutdownRequest.h" #include "librbd/ImageCtx.h" #include "librbd/Utils.h" #include "common/dout.h" @@ -12,14 +12,14 @@ #include "librbd/cache/Types.h" -#define dout_subsys ceph_subsys_rbd_rwl +#define dout_subsys ceph_subsys_rbd_pwl #undef dout_prefix -#define dout_prefix *_dout << "librbd::cache::rwl:ShutdownRequest: " \ +#define dout_prefix *_dout << "librbd::cache::pwl:ShutdownRequest: " \ << this << " " << __func__ << ": " namespace librbd { namespace cache { -namespace rwl { +namespace pwl { using librbd::util::create_async_context_callback; using librbd::util::create_context_callback; @@ -144,8 +144,8 @@ void ShutdownRequest::finish() { delete this; } -} // namespace rwl +} // namespace pwl } // namespace cache } // namespace librbd -template class librbd::cache::rwl::ShutdownRequest; +template class librbd::cache::pwl::ShutdownRequest; diff --git a/src/librbd/cache/rwl/ShutdownRequest.h b/src/librbd/cache/pwl/ShutdownRequest.h similarity index 93% rename from src/librbd/cache/rwl/ShutdownRequest.h rename to src/librbd/cache/pwl/ShutdownRequest.h index 635527f63c7b4..3cacb5317bf90 100644 --- a/src/librbd/cache/rwl/ShutdownRequest.h +++ b/src/librbd/cache/pwl/ShutdownRequest.h @@ -11,7 +11,7 @@ namespace librbd { class ImageCtx; namespace cache { -namespace rwl { +namespace pwl { template class ImageCacheState; @@ -72,10 +72,10 @@ private: } }; -} // namespace rwl +} // namespace pwl } // namespace cache } // namespace librbd -extern template class librbd::cache::rwl::ShutdownRequest; +extern template class librbd::cache::pwl::ShutdownRequest; #endif // CEPH_LIBRBD_CACHE_RWL_SHUTDOWN_REQUEST_H diff --git a/src/librbd/cache/rwl/SyncPoint.cc b/src/librbd/cache/pwl/SyncPoint.cc similarity index 96% rename from src/librbd/cache/rwl/SyncPoint.cc rename to src/librbd/cache/pwl/SyncPoint.cc index cb3f3cfeebd91..8fb2f82052e63 100644 --- a/src/librbd/cache/rwl/SyncPoint.cc +++ b/src/librbd/cache/pwl/SyncPoint.cc @@ -3,14 +3,14 @@ #include "SyncPoint.h" -#define dout_subsys ceph_subsys_rbd_rwl +#define dout_subsys ceph_subsys_rbd_pwl #undef dout_prefix -#define dout_prefix *_dout << "librbd::cache::rwl::SyncPoint: " << this << " " \ +#define dout_prefix *_dout << "librbd::cache::pwl::SyncPoint: " << this << " " \ << __func__ << ": " namespace librbd { namespace cache { -namespace rwl { +namespace pwl { SyncPoint::SyncPoint(uint64_t sync_gen_num, CephContext *cct) : log_entry(std::make_shared(sync_gen_num)), m_cct(cct) { @@ -104,6 +104,6 @@ void SyncPoint::setup_earlier_sync_point(std::shared_ptr sync_point, } } -} // namespace rwl +} // namespace pwl } // namespace cache } // namespace librbd diff --git a/src/librbd/cache/rwl/SyncPoint.h b/src/librbd/cache/pwl/SyncPoint.h similarity index 96% rename from src/librbd/cache/rwl/SyncPoint.h rename to src/librbd/cache/pwl/SyncPoint.h index 1445146534e59..424e3730e8a6b 100644 --- a/src/librbd/cache/rwl/SyncPoint.h +++ b/src/librbd/cache/pwl/SyncPoint.h @@ -5,12 +5,12 @@ #define CEPH_LIBRBD_CACHE_RWL_SYNC_POINT_H #include "librbd/ImageCtx.h" -#include "librbd/cache/rwl/LogEntry.h" -#include "librbd/cache/rwl/Types.h" +#include "librbd/cache/pwl/LogEntry.h" +#include "librbd/cache/pwl/Types.h" namespace librbd { namespace cache { -namespace rwl { +namespace pwl { class SyncPoint: public std::enable_shared_from_this { public: @@ -62,7 +62,7 @@ private: const SyncPoint &p); }; -} // namespace rwl +} // namespace pwl } // namespace cache } // namespace librbd diff --git a/src/librbd/cache/rwl/Types.cc b/src/librbd/cache/pwl/Types.cc similarity index 94% rename from src/librbd/cache/rwl/Types.cc rename to src/librbd/cache/pwl/Types.cc index 7f46c07041009..d19ad0ed406d7 100644 --- a/src/librbd/cache/rwl/Types.cc +++ b/src/librbd/cache/pwl/Types.cc @@ -6,16 +6,16 @@ #include "common/ceph_context.h" #include "include/Context.h" -#define dout_subsys ceph_subsys_rbd_rwl +#define dout_subsys ceph_subsys_rbd_pwl #undef dout_prefix -#define dout_prefix *_dout << "librbd::cache::rwl::Types: " << this << " " \ +#define dout_prefix *_dout << "librbd::cache::pwl::Types: " << this << " " \ << __func__ << ": " namespace librbd { namespace cache { -namespace rwl { +namespace pwl { DeferredContexts::~DeferredContexts() { finish_contexts(nullptr, contexts, 0); @@ -114,8 +114,8 @@ Context * override_ctx(int r, Context *ctx) { } } -} // namespace rwl +} // namespace pwl } // namespace cache } // namespace librbd -template class librbd::cache::rwl::ExtentsSummary; +template class librbd::cache::pwl::ExtentsSummary; diff --git a/src/librbd/cache/rwl/Types.h b/src/librbd/cache/pwl/Types.h similarity index 72% rename from src/librbd/cache/rwl/Types.h rename to src/librbd/cache/pwl/Types.h index 61b7786219328..78a2440e51f35 100644 --- a/src/librbd/cache/rwl/Types.h +++ b/src/librbd/cache/pwl/Types.h @@ -12,37 +12,37 @@ class Context; enum { - l_librbd_rwl_first = 26500, + l_librbd_pwl_first = 26500, // All read requests - l_librbd_rwl_rd_req, // read requests - l_librbd_rwl_rd_bytes, // bytes read - l_librbd_rwl_rd_latency, // average req completion latency + l_librbd_pwl_rd_req, // read requests + l_librbd_pwl_rd_bytes, // bytes read + l_librbd_pwl_rd_latency, // average req completion latency // Read requests completed from RWL (no misses) - l_librbd_rwl_rd_hit_req, // read requests - l_librbd_rwl_rd_hit_bytes, // bytes read - l_librbd_rwl_rd_hit_latency, // average req completion latency + l_librbd_pwl_rd_hit_req, // read requests + l_librbd_pwl_rd_hit_bytes, // bytes read + l_librbd_pwl_rd_hit_latency, // average req completion latency // Reed requests with hit and miss extents - l_librbd_rwl_rd_part_hit_req, // read ops + l_librbd_pwl_rd_part_hit_req, // read ops // Per SyncPoint's LogEntry number and write bytes distribution - l_librbd_rwl_syncpoint_hist, + l_librbd_pwl_syncpoint_hist, // All write requests - l_librbd_rwl_wr_req, // write requests - l_librbd_rwl_wr_req_def, // write requests deferred for resources - l_librbd_rwl_wr_req_def_lanes, // write requests deferred for lanes - l_librbd_rwl_wr_req_def_log, // write requests deferred for log entries - l_librbd_rwl_wr_req_def_buf, // write requests deferred for buffer space - l_librbd_rwl_wr_req_overlap, // write requests detained for overlap - l_librbd_rwl_wr_req_queued, // write requests queued for prior barrier - l_librbd_rwl_wr_bytes, // bytes written + l_librbd_pwl_wr_req, // write requests + l_librbd_pwl_wr_req_def, // write requests deferred for resources + l_librbd_pwl_wr_req_def_lanes, // write requests deferred for lanes + l_librbd_pwl_wr_req_def_log, // write requests deferred for log entries + l_librbd_pwl_wr_req_def_buf, // write requests deferred for buffer space + l_librbd_pwl_wr_req_overlap, // write requests detained for overlap + l_librbd_pwl_wr_req_queued, // write requests queued for prior barrier + l_librbd_pwl_wr_bytes, // bytes written // Write log operations (1 .. n per request that appends to the log) - l_librbd_rwl_log_ops, // log append ops - l_librbd_rwl_log_op_bytes, // average bytes written per log op + l_librbd_pwl_log_ops, // log append ops + l_librbd_pwl_log_op_bytes, // average bytes written per log op /* @@ -81,68 +81,68 @@ enum { */ /* Request times */ - l_librbd_rwl_req_arr_to_all_t, // arrival to allocation elapsed time - same as time deferred in block guard - l_librbd_rwl_req_arr_to_dis_t, // arrival to dispatch elapsed time - l_librbd_rwl_req_all_to_dis_t, // Time spent allocating or waiting to allocate resources - l_librbd_rwl_wr_latency, // average req (persist) completion latency - l_librbd_rwl_wr_latency_hist, // Histogram of write req (persist) completion latency vs. bytes written - l_librbd_rwl_wr_caller_latency, // average req completion (to caller) latency + l_librbd_pwl_req_arr_to_all_t, // arrival to allocation elapsed time - same as time deferred in block guard + l_librbd_pwl_req_arr_to_dis_t, // arrival to dispatch elapsed time + l_librbd_pwl_req_all_to_dis_t, // Time spent allocating or waiting to allocate resources + l_librbd_pwl_wr_latency, // average req (persist) completion latency + l_librbd_pwl_wr_latency_hist, // Histogram of write req (persist) completion latency vs. bytes written + l_librbd_pwl_wr_caller_latency, // average req completion (to caller) latency /* Request times for requests that never waited for space*/ - l_librbd_rwl_nowait_req_arr_to_all_t, // arrival to allocation elapsed time - same as time deferred in block guard - l_librbd_rwl_nowait_req_arr_to_dis_t, // arrival to dispatch elapsed time - l_librbd_rwl_nowait_req_all_to_dis_t, // Time spent allocating or waiting to allocate resources - l_librbd_rwl_nowait_wr_latency, // average req (persist) completion latency - l_librbd_rwl_nowait_wr_latency_hist, // Histogram of write req (persist) completion latency vs. bytes written - l_librbd_rwl_nowait_wr_caller_latency, // average req completion (to caller) latency + l_librbd_pwl_nowait_req_arr_to_all_t, // arrival to allocation elapsed time - same as time deferred in block guard + l_librbd_pwl_nowait_req_arr_to_dis_t, // arrival to dispatch elapsed time + l_librbd_pwl_nowait_req_all_to_dis_t, // Time spent allocating or waiting to allocate resources + l_librbd_pwl_nowait_wr_latency, // average req (persist) completion latency + l_librbd_pwl_nowait_wr_latency_hist, // Histogram of write req (persist) completion latency vs. bytes written + l_librbd_pwl_nowait_wr_caller_latency, // average req completion (to caller) latency /* Log operation times */ - l_librbd_rwl_log_op_alloc_t, // elapsed time of pmemobj_reserve() - l_librbd_rwl_log_op_alloc_t_hist, // Histogram of elapsed time of pmemobj_reserve() - - l_librbd_rwl_log_op_dis_to_buf_t, // dispatch to buffer persist elapsed time - l_librbd_rwl_log_op_dis_to_app_t, // dispatch to log append elapsed time - l_librbd_rwl_log_op_dis_to_cmp_t, // dispatch to persist completion elapsed time - l_librbd_rwl_log_op_dis_to_cmp_t_hist, // Histogram of dispatch to persist completion elapsed time - - l_librbd_rwl_log_op_buf_to_app_t, // data buf persist + append wait time - l_librbd_rwl_log_op_buf_to_bufc_t,// data buf persist / replicate elapsed time - l_librbd_rwl_log_op_buf_to_bufc_t_hist,// data buf persist time vs bytes histogram - l_librbd_rwl_log_op_app_to_cmp_t, // log entry append + completion wait time - l_librbd_rwl_log_op_app_to_appc_t, // log entry append / replicate elapsed time - l_librbd_rwl_log_op_app_to_appc_t_hist, // log entry append time (vs. op bytes) histogram - - l_librbd_rwl_discard, - l_librbd_rwl_discard_bytes, - l_librbd_rwl_discard_latency, - - l_librbd_rwl_aio_flush, - l_librbd_rwl_aio_flush_def, - l_librbd_rwl_aio_flush_latency, - l_librbd_rwl_ws, - l_librbd_rwl_ws_bytes, // Bytes modified by write same, probably much larger than WS payload bytes - l_librbd_rwl_ws_latency, - - l_librbd_rwl_cmp, - l_librbd_rwl_cmp_bytes, - l_librbd_rwl_cmp_latency, - l_librbd_rwl_cmp_fails, - - l_librbd_rwl_flush, - l_librbd_rwl_invalidate_cache, - l_librbd_rwl_invalidate_discard_cache, - - l_librbd_rwl_append_tx_t, - l_librbd_rwl_retire_tx_t, - l_librbd_rwl_append_tx_t_hist, - l_librbd_rwl_retire_tx_t_hist, - - l_librbd_rwl_last, + l_librbd_pwl_log_op_alloc_t, // elapsed time of pmemobj_reserve() + l_librbd_pwl_log_op_alloc_t_hist, // Histogram of elapsed time of pmemobj_reserve() + + l_librbd_pwl_log_op_dis_to_buf_t, // dispatch to buffer persist elapsed time + l_librbd_pwl_log_op_dis_to_app_t, // dispatch to log append elapsed time + l_librbd_pwl_log_op_dis_to_cmp_t, // dispatch to persist completion elapsed time + l_librbd_pwl_log_op_dis_to_cmp_t_hist, // Histogram of dispatch to persist completion elapsed time + + l_librbd_pwl_log_op_buf_to_app_t, // data buf persist + append wait time + l_librbd_pwl_log_op_buf_to_bufc_t,// data buf persist / replicate elapsed time + l_librbd_pwl_log_op_buf_to_bufc_t_hist,// data buf persist time vs bytes histogram + l_librbd_pwl_log_op_app_to_cmp_t, // log entry append + completion wait time + l_librbd_pwl_log_op_app_to_appc_t, // log entry append / replicate elapsed time + l_librbd_pwl_log_op_app_to_appc_t_hist, // log entry append time (vs. op bytes) histogram + + l_librbd_pwl_discard, + l_librbd_pwl_discard_bytes, + l_librbd_pwl_discard_latency, + + l_librbd_pwl_aio_flush, + l_librbd_pwl_aio_flush_def, + l_librbd_pwl_aio_flush_latency, + l_librbd_pwl_ws, + l_librbd_pwl_ws_bytes, // Bytes modified by write same, probably much larger than WS payload bytes + l_librbd_pwl_ws_latency, + + l_librbd_pwl_cmp, + l_librbd_pwl_cmp_bytes, + l_librbd_pwl_cmp_latency, + l_librbd_pwl_cmp_fails, + + l_librbd_pwl_flush, + l_librbd_pwl_invalidate_cache, + l_librbd_pwl_invalidate_discard_cache, + + l_librbd_pwl_append_tx_t, + l_librbd_pwl_retire_tx_t, + l_librbd_pwl_append_tx_t_hist, + l_librbd_pwl_retire_tx_t_hist, + + l_librbd_pwl_last, }; namespace librbd { namespace cache { -namespace rwl { +namespace pwl { class ImageExtentBuf; typedef std::vector ImageExtentBufs; @@ -184,11 +184,11 @@ public: }; /* Pmem structures */ -POBJ_LAYOUT_BEGIN(rbd_rwl); -POBJ_LAYOUT_ROOT(rbd_rwl, struct WriteLogPoolRoot); -POBJ_LAYOUT_TOID(rbd_rwl, uint8_t); -POBJ_LAYOUT_TOID(rbd_rwl, struct WriteLogPmemEntry); -POBJ_LAYOUT_END(rbd_rwl); +POBJ_LAYOUT_BEGIN(rbd_pwl); +POBJ_LAYOUT_ROOT(rbd_pwl, struct WriteLogPoolRoot); +POBJ_LAYOUT_TOID(rbd_pwl, uint8_t); +POBJ_LAYOUT_TOID(rbd_pwl, struct WriteLogPmemEntry); +POBJ_LAYOUT_END(rbd_pwl); struct WriteLogPmemEntry { uint64_t sync_gen_number = 0; @@ -286,7 +286,7 @@ public: return BlockExtent(first_image_byte, last_image_byte); } io::Extent image_extent() { - return librbd::cache::rwl::image_extent(block_extent()); + return librbd::cache::pwl::image_extent(block_extent()); } }; @@ -305,7 +305,7 @@ public: : io::Extent(extent), m_bl(bl) { } }; -} // namespace rwl +} // namespace pwl } // namespace cache } // namespace librbd diff --git a/src/librbd/exclusive_lock/PostAcquireRequest.cc b/src/librbd/exclusive_lock/PostAcquireRequest.cc index 6c920cc8aa6a4..cf75d91f0e9be 100644 --- a/src/librbd/exclusive_lock/PostAcquireRequest.cc +++ b/src/librbd/exclusive_lock/PostAcquireRequest.cc @@ -7,8 +7,8 @@ #include "common/dout.h" #include "common/errno.h" #include "include/stringify.h" -#include "librbd/cache/rwl/InitRequest.h" -#include "librbd/cache/rwl/ShutdownRequest.h" +#include "librbd/cache/pwl/InitRequest.h" +#include "librbd/cache/pwl/ShutdownRequest.h" #include "librbd/ExclusiveLock.h" #include "librbd/ImageCtx.h" #include "librbd/ImageState.h" @@ -186,7 +186,7 @@ void PostAcquireRequest::send_open_image_cache() { Context *ctx = create_async_context_callback( m_image_ctx, create_context_callback< klass, &klass::handle_open_image_cache>(this)); - cache::rwl::InitRequest *req = cache::rwl::InitRequest::create( + cache::pwl::InitRequest *req = cache::pwl::InitRequest::create( m_image_ctx, ctx); req->send(); } @@ -216,7 +216,7 @@ void PostAcquireRequest::send_close_image_cache() { using klass = PostAcquireRequest; Context *ctx = create_context_callback( this); - cache::rwl::ShutdownRequest *req = cache::rwl::ShutdownRequest::create( + cache::pwl::ShutdownRequest *req = cache::pwl::ShutdownRequest::create( m_image_ctx, ctx); req->send(); } diff --git a/src/librbd/exclusive_lock/PreReleaseRequest.cc b/src/librbd/exclusive_lock/PreReleaseRequest.cc index fb1aa8322fb90..be5f7c2aa620e 100644 --- a/src/librbd/exclusive_lock/PreReleaseRequest.cc +++ b/src/librbd/exclusive_lock/PreReleaseRequest.cc @@ -5,7 +5,7 @@ #include "common/AsyncOpTracker.h" #include "common/dout.h" #include "common/errno.h" -#include "librbd/cache/rwl/ShutdownRequest.h" +#include "librbd/cache/pwl/ShutdownRequest.h" #include "librbd/ExclusiveLock.h" #include "librbd/ImageState.h" #include "librbd/ImageWatcher.h" @@ -174,7 +174,7 @@ void PreReleaseRequest::send_shut_down_image_cache() { Context *ctx = create_async_context_callback(m_image_ctx, create_context_callback< PreReleaseRequest, &PreReleaseRequest::handle_shut_down_image_cache>(this)); - cache::rwl::ShutdownRequest *req = cache::rwl::ShutdownRequest::create( + cache::pwl::ShutdownRequest *req = cache::pwl::ShutdownRequest::create( m_image_ctx, ctx); req->send(); } diff --git a/src/test/librbd/CMakeLists.txt b/src/test/librbd/CMakeLists.txt index ae6966d5daf95..7f18790dfc1e6 100644 --- a/src/test/librbd/CMakeLists.txt +++ b/src/test/librbd/CMakeLists.txt @@ -121,7 +121,7 @@ if(WITH_RBD_RWL) set(unittest_librbd_srcs ${unittest_librbd_srcs} cache/test_mock_ReplicatedWriteLog.cc - cache/rwl/test_WriteLogMap.cc) + cache/pwl/test_WriteLogMap.cc) endif(WITH_RBD_RWL) add_executable(unittest_librbd diff --git a/src/test/librbd/cache/rwl/test_WriteLogMap.cc b/src/test/librbd/cache/pwl/test_WriteLogMap.cc similarity index 99% rename from src/test/librbd/cache/rwl/test_WriteLogMap.cc rename to src/test/librbd/cache/pwl/test_WriteLogMap.cc index 1fc2cfd42e03e..7263d0831ac88 100644 --- a/src/test/librbd/cache/rwl/test_WriteLogMap.cc +++ b/src/test/librbd/cache/pwl/test_WriteLogMap.cc @@ -4,14 +4,14 @@ #include "test/librbd/test_fixture.h" #include "test/librbd/test_support.h" -#include "librbd/cache/rwl/LogMap.cc" +#include "librbd/cache/pwl/LogMap.cc" void register_test_write_log_map() { } namespace librbd { namespace cache { -namespace rwl { +namespace pwl { struct TestLogEntry { uint64_t image_offset_bytes; @@ -331,6 +331,6 @@ TEST_F(TestWriteLogMap, OverlapSplit) { ASSERT_EQ(8, found0.front().block_extent.block_end); } -} // namespace rwl +} // namespace pwl } // namespace cache } // namespace librbd diff --git a/src/test/librbd/cache/test_mock_ReplicatedWriteLog.cc b/src/test/librbd/cache/test_mock_ReplicatedWriteLog.cc index 717b19b938019..4e9f8065ae4c4 100644 --- a/src/test/librbd/cache/test_mock_ReplicatedWriteLog.cc +++ b/src/test/librbd/cache/test_mock_ReplicatedWriteLog.cc @@ -7,8 +7,8 @@ #include "test/librbd/test_support.h" #include "test/librbd/mock/MockImageCtx.h" #include "include/rbd/librbd.hpp" -#include "librbd/cache/rwl/ImageCacheState.h" -#include "librbd/cache/rwl/Types.h" +#include "librbd/cache/pwl/ImageCacheState.h" +#include "librbd/cache/pwl/Types.h" #include "librbd/cache/ImageWriteback.h" #include "librbd/cache/WriteLogCache.h" @@ -37,13 +37,13 @@ inline ImageCtx *get_image_ctx(MockImageCtx *image_ctx) { } // namespace librbd #include "librbd/cache/WriteLogCache.cc" -#include "librbd/cache/AbstractWriteLog.cc" -#include "librbd/cache/ReplicatedWriteLog.cc" +#include "librbd/cache/pwl/AbstractWriteLog.cc" +#include "librbd/cache/pwl/ReplicatedWriteLog.cc" // template definitions #include "librbd/cache/ImageWriteback.cc" -#include "librbd/cache/rwl/ImageCacheState.cc" -#include "librbd/cache/rwl/Request.cc" +#include "librbd/cache/pwl/ImageCacheState.cc" +#include "librbd/cache/pwl/Request.cc" namespace librbd { namespace cache { @@ -55,7 +55,7 @@ using ::testing::Invoke; struct TestMockCacheReplicatedWriteLog : public TestMockFixture { typedef WriteLogCache MockReplicatedWriteLog; - typedef librbd::cache::rwl::ImageCacheState MockImageCacheStateRWL; + typedef librbd::cache::pwl::ImageCacheState MockImageCacheStateRWL; MockImageCacheStateRWL *get_cache_state(MockImageCtx& mock_image_ctx) { MockImageCacheStateRWL *rwl_state = new MockImageCacheStateRWL(&mock_image_ctx); diff --git a/src/test/librbd/exclusive_lock/test_mock_PostAcquireRequest.cc b/src/test/librbd/exclusive_lock/test_mock_PostAcquireRequest.cc index 9379e3ecf8955..c0e2a0ecf7307 100644 --- a/src/test/librbd/exclusive_lock/test_mock_PostAcquireRequest.cc +++ b/src/test/librbd/exclusive_lock/test_mock_PostAcquireRequest.cc @@ -11,8 +11,8 @@ #include "test/librbd/mock/MockObjectMap.h" #include "test/librados_test_stub/MockTestMemIoCtxImpl.h" #include "test/librados_test_stub/MockTestMemRadosClient.h" -#include "librbd/cache/rwl/InitRequest.h" -#include "librbd/cache/rwl/ShutdownRequest.h" +#include "librbd/cache/pwl/InitRequest.h" +#include "librbd/cache/pwl/ShutdownRequest.h" #include "librbd/exclusive_lock/PostAcquireRequest.h" #include "librbd/image/RefreshRequest.h" @@ -63,7 +63,7 @@ RefreshRequest *RefreshRequest struct InitRequest { @@ -105,7 +105,7 @@ struct ShutdownRequest { ShutdownRequest *ShutdownRequest::s_instance = nullptr; -} // namespace rwl +} // namespace pwl } // namespace cache } // namespace librbd @@ -138,8 +138,8 @@ class TestMockExclusiveLockPostAcquireRequest : public TestMockFixture { public: typedef PostAcquireRequest MockPostAcquireRequest; typedef librbd::image::RefreshRequest MockRefreshRequest; - typedef librbd::cache::rwl::InitRequest MockInitRequest; - typedef librbd::cache::rwl::ShutdownRequest MockShutdownRequest; + typedef librbd::cache::pwl::InitRequest MockInitRequest; + typedef librbd::cache::pwl::ShutdownRequest MockShutdownRequest; void expect_test_features(MockTestImageCtx &mock_image_ctx, uint64_t features, bool enabled) { diff --git a/src/test/librbd/exclusive_lock/test_mock_PreReleaseRequest.cc b/src/test/librbd/exclusive_lock/test_mock_PreReleaseRequest.cc index d56ee1155f625..8c9c1fa44e35d 100644 --- a/src/test/librbd/exclusive_lock/test_mock_PreReleaseRequest.cc +++ b/src/test/librbd/exclusive_lock/test_mock_PreReleaseRequest.cc @@ -1,7 +1,7 @@ // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- // vim: ts=8 sw=2 smarttab -#include "librbd/cache/rwl/ShutdownRequest.h" +#include "librbd/cache/pwl/ShutdownRequest.h" #include "test/librbd/test_mock_fixture.h" #include "test/librbd/test_support.h" #include "test/librbd/mock/cache/MockImageCache.h" @@ -40,7 +40,7 @@ struct ImageDispatch { } // namespace exclusive_lock namespace cache { -namespace rwl { +namespace pwl { template<> struct ShutdownRequest { static ShutdownRequest *s_instance; @@ -61,7 +61,7 @@ struct ShutdownRequest { ShutdownRequest *ShutdownRequest::s_instance = nullptr; -} // namespace rwl +} // namespace pwl } // namespace cache } // namespace librbd @@ -93,7 +93,7 @@ class TestMockExclusiveLockPreReleaseRequest : public TestMockFixture { public: typedef ImageDispatch MockImageDispatch; typedef PreReleaseRequest MockPreReleaseRequest; - typedef librbd::cache::rwl::ShutdownRequest MockShutdownRequest; + typedef librbd::cache::pwl::ShutdownRequest MockShutdownRequest; void expect_complete_context(MockContext &mock_context, int r) { EXPECT_CALL(mock_context, complete(r)); -- 2.47.3