]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: cache: keep writing buffers out of LRU
authorSage Weil <sage@redhat.com>
Fri, 10 Jun 2016 13:10:30 +0000 (09:10 -0400)
committerSage Weil <sage@redhat.com>
Wed, 22 Jun 2016 15:28:40 +0000 (11:28 -0400)
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 <sage@redhat.com>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index 01a3e84637adbfe268b8eb2c9c3759fc4b311cc0..c1ab8e42d2b3c56709b670add2f1f7055abc9268 100644 (file)
@@ -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;
index df56d91d9e8725edddac37bcfc5f7582a77b4032..5d103748efaecd51b98f776b2b9833809aba24f8 100644 (file)
@@ -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<uint64_t,std::unique_ptr<Buffer>>::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");