]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd/cache: PWL doesn't use bptr::clone() anymore.
authorRadosław Zarzyński <rzarzyns@redhat.com>
Mon, 23 May 2022 17:07:10 +0000 (19:07 +0200)
committerRadosław Zarzyński <rzarzyns@redhat.com>
Mon, 23 May 2022 21:50:31 +0000 (23:50 +0200)
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 <rzarzyns@redhat.com>
src/librbd/cache/pwl/rwl/LogEntry.cc

index 056701fb514880d1902034eb72a30dc54d432e1e..38e09c22ab16f2391ed47d3a70d36bbd60678e5a 100644 (file)
@@ -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);
 }