From: Radosław Zarzyński Date: Mon, 23 May 2022 17:07:10 +0000 (+0200) Subject: librbd/cache: PWL doesn't use bptr::clone() anymore. X-Git-Tag: v18.0.0~450^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0e4ee2a2dd93b1227dbc1fc57c5e7fb8c0c28231;p=ceph.git librbd/cache: PWL doesn't use bptr::clone() anymore. This usage got introduced in 7c68bd931bf4acdcadfd3ef7462935ab8f1ff09c and later reworked by 55099fb05b76ac7f4f72a41fa77ad9672711a93d. It can be easily replaced with `ptr::iterator::get_ptr()` as: 1. the source `cache_bp` bases on `raw_static`: ``` void WriteLogEntry::init_cache_bp() { ceph_assert(!this->cache_bp.have_raw()); cache_bp = buffer::ptr(buffer::create_static(this->write_bytes(), (char*)this->cache_buffer)); } ``` 2. which `clone_empty()` is implemented as follows: ``` class buffer::raw_static : public buffer::raw { public: MEMPOOL_CLASS_HELPERS(); raw_static(const char *d, unsigned l) : raw((char*)d, l) { } ~raw_static() override {} raw* clone_empty() override { return new buffer::raw_char(len); } }; ``` Signed-off-by: Radosław Zarzyński --- diff --git a/src/librbd/cache/pwl/rwl/LogEntry.cc b/src/librbd/cache/pwl/rwl/LogEntry.cc index 056701fb5148..38e09c22ab16 100644 --- a/src/librbd/cache/pwl/rwl/LogEntry.cc +++ b/src/librbd/cache/pwl/rwl/LogEntry.cc @@ -75,7 +75,8 @@ buffer::list& WriteLogEntry::get_cache_bl() { void WriteLogEntry::copy_cache_bl(bufferlist *out_bl) { this->get_cache_bl(); // cache_bp is now initialized - buffer::ptr cloned_bp(cache_bp.clone()); + ceph_assert(cache_bp.length() == cache_bp.raw_length()); + buffer::ptr cloned_bp = cache_bp.begin_deep().get_ptr(cache_bp.length()); out_bl->clear(); this->init_bl(cloned_bp, *out_bl); }