From: Adam Kupczyk Date: Tue, 16 Jun 2020 07:36:55 +0000 (+0200) Subject: common/mempool: copies bufferlist assignment to mempool through rebuild X-Git-Tag: v14.2.17~19^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=579d91165ee05e993c9ffa630f01b53a00aa5cf4;p=ceph.git common/mempool: copies bufferlist assignment to mempool through rebuild Fixes: https://tracker.ceph.com/issues/46027 Signed-off-by: Adam Kupczyk (cherry picked from commit b3a6d18ea64e0f70e0d3371cbfcd21280677000e) Conflicts: src/test/test_mempool.cc - nautilus version of this file has less tests than master --- diff --git a/src/common/buffer.cc b/src/common/buffer.cc index 7ff943953056..8caaae907aad 100644 --- a/src/common/buffer.cc +++ b/src/common/buffer.cc @@ -1230,6 +1230,8 @@ static ceph::spinlock debug_lock; std::unique_ptr nb) { unsigned pos = 0; + int mempool = _buffers.front().get_mempool(); + nb->reassign_to_mempool(mempool); for (auto& node : _buffers) { nb->copy_in(pos, node.length(), node.c_str(), false); pos += node.length(); diff --git a/src/test/test_mempool.cc b/src/test/test_mempool.cc index 02e99f3fcc19..39ebc0248bec 100644 --- a/src/test/test_mempool.cc +++ b/src/test/test_mempool.cc @@ -365,6 +365,21 @@ TEST(mempool, bufferlist_reassign) ASSERT_EQ(bytes_before, mempool::osd::allocated_bytes()); } +TEST(mempool, bufferlist_c_str) +{ + bufferlist bl; + int len = 1048576; + size_t before = mempool::osd::allocated_bytes(); + bl.append(buffer::create_aligned(len, 4096)); + bl.append(buffer::create_aligned(len, 4096)); + bl.reassign_to_mempool(mempool::mempool_osd); + size_t after = mempool::osd::allocated_bytes(); + ASSERT_GE(after, before + len * 2); + bl.c_str(); + size_t after_c_str = mempool::osd::allocated_bytes(); + ASSERT_EQ(after, after_c_str); +} + TEST(mempool, check_shard_select) { const size_t samples = 100;