From: Radoslaw Zarzynski Date: Fri, 24 Jul 2020 09:13:04 +0000 (+0000) Subject: common/bl: drop clone() and clone_empty() from buffer::raw. X-Git-Tag: v18.0.0~450^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=35ce1a10afe6a76d36602e84ac1d3218ea4d5cb0;p=ceph.git common/bl: drop clone() and clone_empty() from buffer::raw. Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/blk/kernel/KernelDevice.cc b/src/blk/kernel/KernelDevice.cc index ee06af61e05..ddba9473f59 100644 --- a/src/blk/kernel/KernelDevice.cc +++ b/src/blk/kernel/KernelDevice.cc @@ -1065,11 +1065,6 @@ struct ExplicitHugePagePool { // don't delete nor unmmap; recycle the region instead region_q.push(data); } - raw* clone_empty() override { - // the entire cloning facility is used solely by the dev-only MemDB. - // see: https://github.com/ceph/ceph/pull/36282 - ceph_abort_msg("this should be never called on this path!"); - } }; ExplicitHugePagePool(const size_t buffer_size, size_t buffers_in_pool) diff --git a/src/common/buffer.cc b/src/common/buffer.cc index 18f510394e9..e32503c2890 100644 --- a/src/common/buffer.cc +++ b/src/common/buffer.cc @@ -87,15 +87,9 @@ static ceph::spinlock debug_lock; * raw_combined at the end. */ class buffer::raw_combined : public buffer::raw { - size_t alignment; public: - raw_combined(char *dataptr, unsigned l, unsigned align, - int mempool) - : raw(dataptr, l, mempool), - alignment(align) { - } - raw* clone_empty() override { - return create(len, alignment).release(); + raw_combined(char *dataptr, unsigned l, int mempool) + : raw(dataptr, l, mempool) { } static ceph::unique_leakable_ptr @@ -123,7 +117,7 @@ static ceph::spinlock debug_lock; // actual data first, since it has presumably larger alignment restriction // then put the raw_combined at the end return ceph::unique_leakable_ptr( - new (ptr + datalen) raw_combined(ptr, len, align, mempool)); + new (ptr + datalen) raw_combined(ptr, len, mempool)); } static void operator delete(void *ptr) { @@ -153,20 +147,16 @@ static ceph::spinlock debug_lock; free(data); bdout << "raw_malloc " << this << " free " << (void *)data << " " << bendl; } - raw* clone_empty() override { - return new raw_malloc(len); - } }; #ifndef __CYGWIN__ class buffer::raw_posix_aligned : public buffer::raw { - unsigned align; public: MEMPOOL_CLASS_HELPERS(); - raw_posix_aligned(unsigned l, unsigned _align) : raw(l) { + raw_posix_aligned(unsigned l, unsigned align) : raw(l) { // posix_memalign() requires a multiple of sizeof(void *) - align = std::max(_align, sizeof(void *)); + align = std::max(align, sizeof(void *)); #ifdef DARWIN data = (char *) valloc(len); #else @@ -183,19 +173,14 @@ static ceph::spinlock debug_lock; aligned_free(data); bdout << "raw_posix_aligned " << this << " free " << (void *)data << bendl; } - raw* clone_empty() override { - return new raw_posix_aligned(len, align); - } }; #endif #ifdef __CYGWIN__ class buffer::raw_hack_aligned : public buffer::raw { - unsigned align; char *realdata; public: - raw_hack_aligned(unsigned l, unsigned _align) : raw(l) { - align = _align; + raw_hack_aligned(unsigned l, unsigned align) : raw(l) { realdata = new char[len+align-1]; unsigned off = ((uintptr_t)realdata) & (align-1); if (off) @@ -210,9 +195,6 @@ static ceph::spinlock debug_lock; ~raw_hack_aligned() { delete[] realdata; } - raw* clone_empty() { - return new raw_hack_aligned(len, align); - } }; #endif @@ -237,9 +219,6 @@ static ceph::spinlock debug_lock; delete[] data; bdout << "raw_char " << this << " free " << (void *)data << bendl; } - raw* clone_empty() override { - return new raw_char(len); - } }; class buffer::raw_claimed_char : public buffer::raw { @@ -254,9 +233,6 @@ static ceph::spinlock debug_lock; bdout << "raw_claimed_char " << this << " free " << (void *)data << bendl; } - raw* clone_empty() override { - return new raw_char(len); - } }; class buffer::raw_static : public buffer::raw { @@ -265,9 +241,6 @@ static ceph::spinlock debug_lock; raw_static(const char *d, unsigned l) : raw((char*)d, l) { } ~raw_static() override {} - raw* clone_empty() override { - return new buffer::raw_char(len); - } }; class buffer::raw_claim_buffer : public buffer::raw { @@ -276,9 +249,6 @@ static ceph::spinlock debug_lock; raw_claim_buffer(const char *b, unsigned l, deleter d) : raw((char*)b, l), del(std::move(d)) { } ~raw_claim_buffer() override {} - raw* clone_empty() override { - return new buffer::raw_char(len); - } }; ceph::unique_leakable_ptr buffer::copy(const char *c, unsigned len) { diff --git a/src/common/buffer_seastar.cc b/src/common/buffer_seastar.cc index 7d0e98e379a..1f85c33f514 100644 --- a/src/common/buffer_seastar.cc +++ b/src/common/buffer_seastar.cc @@ -27,9 +27,6 @@ class raw_seastar_foreign_ptr : public raw { public: raw_seastar_foreign_ptr(temporary_buffer&& buf) : raw(buf.get_write(), buf.size()), ptr(std::move(buf)) {} - raw* clone_empty() override { - return create(len).release(); - } }; class raw_seastar_local_ptr : public raw { @@ -37,9 +34,6 @@ class raw_seastar_local_ptr : public raw { public: raw_seastar_local_ptr(temporary_buffer&& buf) : raw(buf.get_write(), buf.size()), buf(std::move(buf)) {} - raw* clone_empty() override { - return create(len).release(); - } }; inline namespace v15_2_0 { @@ -93,9 +87,6 @@ class raw_seastar_local_shared_ptr : public raw { public: raw_seastar_local_shared_ptr(temporary_buffer& buf) : raw(buf.get_write(), buf.size()), buf(buf.share()) {} - raw* clone_empty() override { - return ceph::buffer::create(len).release(); - } }; } diff --git a/src/include/buffer_raw.h b/src/include/buffer_raw.h index 890fb04d5b2..2298525c959 100644 --- a/src/include/buffer_raw.h +++ b/src/include/buffer_raw.h @@ -92,12 +92,6 @@ public: unsigned get_len() const { return len; } - virtual raw* clone_empty() = 0; - ceph::unique_leakable_ptr clone() { - raw* const c = clone_empty(); - memcpy(c->data, data, len); - return ceph::unique_leakable_ptr(c); - } bool get_crc(const std::pair &fromto, std::pair *crc) const { std::lock_guard lg(crc_spinlock);