From: Sage Weil Date: Fri, 10 Jun 2016 13:10:30 +0000 (-0400) Subject: os/bluestore: cache: keep writing buffers out of LRU X-Git-Tag: v11.0.0~70^2~15 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7d9629c07e5c7f07ae78072d17608c62979f5f67;p=ceph-ci.git os/bluestore: cache: keep writing buffers out of LRU Don't bother putting a writing buffer in the LRU until it is clean (and trimmable). Otherwise, we end up with writing items near the end of the LRU that we have to iterate over on every trim() invocation. Signed-off-by: Sage Weil --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 01a3e84637a..c1ab8e42d2b 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -673,7 +673,9 @@ void BlueStore::BufferSpace::read( res_intervals.insert(offset, l); offset += l; length -= l; - cache->_touch_buffer(b); + if (!b->is_writing()) { + cache->_touch_buffer(b); + } continue; } if (b->offset > offset) { @@ -684,7 +686,9 @@ void BlueStore::BufferSpace::read( offset += gap; length -= gap; } - cache->_touch_buffer(b); + if (!b->is_writing()) { + cache->_touch_buffer(b); + } if (b->length > length) { res[offset].substr_of(b->data, 0, length); res_intervals.insert(offset, length); @@ -714,6 +718,7 @@ void BlueStore::BufferSpace::finish_write(uint64_t seq) } else { b->state = Buffer::STATE_CLEAN; writing.erase(i++); + cache->_add_buffer(b, 1, nullptr); } } else { ++i; diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index df56d91d9e8..5d103748efa 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -211,9 +211,10 @@ public: void _add_buffer(Buffer *b, int level, Buffer *near) { cache->_audit_lru("_add_buffer start"); buffer_map[b->offset].reset(b); - cache->_add_buffer(b, level, near); if (b->is_writing()) { writing.push_back(*b); + } else { + cache->_add_buffer(b, level, near); } cache->_audit_lru("_add_buffer end"); } @@ -222,9 +223,10 @@ public: } void _rm_buffer(map>::iterator p) { cache->_audit_lru("_rm_buffer start"); - cache->_rm_buffer(p->second.get()); if (p->second->is_writing()) { writing.erase(writing.iterator_to(*p->second)); + } else { + cache->_rm_buffer(p->second.get()); } buffer_map.erase(p); cache->_audit_lru("_rm_buffer end");