From 050873feae3c2d7e51ee0d37a00204934f2a1161 Mon Sep 17 00:00:00 2001 From: Igor Fedotov Date: Thu, 8 Oct 2020 15:14:58 +0300 Subject: [PATCH] os/bluestore: do not assign already cached buffer to mempool_bluestore_writing. This spoils mempool stats with unexpectedly high mount of entries in the bluestore_writing mempool. The issue might occurs while handling partial overwrites in EC pools. Unser some circumstances EC backend might rewrite data from read cache back to disk. Signed-off-by: Igor Fedotov --- src/os/bluestore/BlueStore.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index fdde77dabb7fe..f7a72f1f73b1b 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -297,11 +297,13 @@ public: ceph_assert(writing.empty()); } - void _add_buffer(BufferCacheShard* cache, Buffer *b, int level, Buffer *near) { + void _add_buffer(BufferCacheShard* cache, Buffer* b, int level, Buffer* near) { cache->_audit("_add_buffer start"); buffer_map[b->offset].reset(b); if (b->is_writing()) { - b->data.reassign_to_mempool(mempool::mempool_bluestore_writing); + // we might get already cached data for which resetting mempool is inppropriate + // hence calling try_assign_to_mempool + b->data.try_assign_to_mempool(mempool::mempool_bluestore_writing); if (writing.empty() || writing.rbegin()->seq <= b->seq) { writing.push_back(*b); } else { @@ -316,8 +318,8 @@ public: writing.insert(it, *b); } } else { - b->data.reassign_to_mempool(mempool::mempool_bluestore_cache_data); - cache->_add(b, level, near); + b->data.reassign_to_mempool(mempool::mempool_bluestore_cache_data); + cache->_add(b, level, near); } cache->_audit("_add_buffer end"); } -- 2.39.5