From: Sage Weil Date: Thu, 19 Oct 2017 21:19:35 +0000 (-0500) Subject: buffer: remove list _mempool member X-Git-Tag: v12.2.2~126^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F18491%2Fhead;p=ceph.git buffer: remove list _mempool member This broke the C++ ABI by changing the list structure size. Also, it's not necessary as we can infer the mempool by looking at the other list contents. We don't (currently) have a need to map an empty list to a particular mempool and have that state stick. Fixes: http://tracker.ceph.com/issues/21573 Signed-off-by: Sage Weil (cherry picked from commit 9b92d87d37e3892b0096cd728b46154aed1e2d86) --- diff --git a/src/common/buffer.cc b/src/common/buffer.cc index c518451e3581..18ae276cc6fa 100644 --- a/src/common/buffer.cc +++ b/src/common/buffer.cc @@ -964,6 +964,13 @@ static std::atomic_flag buffer_debug_lock = ATOMIC_FLAG_INIT; bool buffer::ptr::at_buffer_tail() const { return _off + _len == _raw->len; } + int buffer::ptr::get_mempool() const { + if (_raw) { + return _raw->mempool; + } + return mempool::mempool_buffer_anon; + } + void buffer::ptr::reassign_to_mempool(int pool) { if (_raw) { _raw->reassign_to_mempool(pool); @@ -1516,7 +1523,6 @@ static std::atomic_flag buffer_debug_lock = ATOMIC_FLAG_INIT; { std::swap(_len, other._len); std::swap(_memcopy_count, other._memcopy_count); - std::swap(_mempool, other._mempool); _buffers.swap(other._buffers); append_buffer.swap(other.append_buffer); //last_p.swap(other.last_p); @@ -1689,9 +1695,16 @@ static std::atomic_flag buffer_debug_lock = ATOMIC_FLAG_INIT; return is_aligned(CEPH_PAGE_SIZE); } + int buffer::list::get_mempool() const + { + if (_buffers.empty()) { + return mempool::mempool_buffer_anon; + } + return _buffers.back().get_mempool(); + } + void buffer::list::reassign_to_mempool(int pool) { - _mempool = pool; if (append_buffer.get_raw()) { append_buffer.get_raw()->reassign_to_mempool(pool); } @@ -1702,7 +1715,6 @@ static std::atomic_flag buffer_debug_lock = ATOMIC_FLAG_INIT; void buffer::list::try_assign_to_mempool(int pool) { - _mempool = pool; if (append_buffer.get_raw()) { append_buffer.get_raw()->try_assign_to_mempool(pool); } @@ -1801,10 +1813,7 @@ static std::atomic_flag buffer_debug_lock = ATOMIC_FLAG_INIT; void buffer::list::reserve(size_t prealloc) { if (append_buffer.unused_tail_length() < prealloc) { - append_buffer = buffer::create(prealloc); - if (_mempool >= 0) { - append_buffer.get_raw()->reassign_to_mempool(_mempool); - } + append_buffer = buffer::create_in_mempool(prealloc, get_mempool()); append_buffer.set_length(0); // unused, so far. } } @@ -1902,11 +1911,9 @@ static std::atomic_flag buffer_debug_lock = ATOMIC_FLAG_INIT; unsigned gap = append_buffer.unused_tail_length(); if (!gap) { // make a new append_buffer! - append_buffer = raw_combined::create(CEPH_BUFFER_APPEND_SIZE); + append_buffer = raw_combined::create(CEPH_BUFFER_APPEND_SIZE, 0, + get_mempool()); append_buffer.set_length(0); // unused, so far. - if (_mempool >= 0) { - append_buffer.get_raw()->reassign_to_mempool(_mempool); - } } append(append_buffer, append_buffer.append(c) - 1, 1); // add segment to the list } @@ -1932,11 +1939,8 @@ static std::atomic_flag buffer_debug_lock = ATOMIC_FLAG_INIT; size_t need = ROUND_UP_TO(len, sizeof(size_t)) + sizeof(raw_combined); size_t alen = ROUND_UP_TO(need, CEPH_BUFFER_ALLOC_UNIT) - sizeof(raw_combined); - append_buffer = raw_combined::create(alen, 0); + append_buffer = raw_combined::create(alen, 0, get_mempool()); append_buffer.set_length(0); // unused, so far. - if (_mempool >= 0) { - append_buffer.get_raw()->reassign_to_mempool(_mempool); - } } } diff --git a/src/include/buffer.h b/src/include/buffer.h index 84012665dab2..3fe729cf8aa8 100644 --- a/src/include/buffer.h +++ b/src/include/buffer.h @@ -290,6 +290,7 @@ namespace buffer CEPH_BUFFER_API { return have_raw() && (start() > 0 || end() < raw_length()); } + int get_mempool() const; void reassign_to_mempool(int pool); void try_assign_to_mempool(int pool); @@ -353,7 +354,6 @@ namespace buffer CEPH_BUFFER_API { unsigned _len; unsigned _memcopy_count; //the total of memcopy using rebuild(). ptr append_buffer; // where i put small appends. - int _mempool = -1; public: class iterator; @@ -687,7 +687,6 @@ namespace buffer CEPH_BUFFER_API { _memcopy_count = other._memcopy_count; last_p = begin(); append_buffer.swap(other.append_buffer); - _mempool = other._mempool; other.clear(); return *this; } @@ -696,6 +695,7 @@ namespace buffer CEPH_BUFFER_API { const ptr& front() const { return _buffers.front(); } const ptr& back() const { return _buffers.back(); } + int get_mempool() const; void reassign_to_mempool(int pool); void try_assign_to_mempool(int pool);