]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: simplify BufferSpace::read() a little
authorxie xingguo <xie.xingguo@zte.com.cn>
Mon, 20 Jun 2016 12:02:41 +0000 (20:02 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Tue, 21 Jun 2016 13:35:43 +0000 (21:35 +0800)
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/os/bluestore/BlueStore.cc

index 26c208aae857de8d088a7b06ea5f1378cf7943f1..e5ed1083593228f5b81db60650b50fe9b1b58d9e 100644 (file)
@@ -606,14 +606,14 @@ void BlueStore::BufferSpace::_discard(uint64_t offset, uint64_t length)
   uint64_t end = offset + length;
   while (i != buffer_map.end()) {
     Buffer *b = i->second.get();
-    if (b->offset >= offset + length) {
+    if (b->offset >= end) {
       break;
     }
     if (b->offset < offset) {
       uint64_t front = offset - b->offset;
-      if (b->offset + b->length > offset + length) {
+      if (b->end() > end) {
        // drop middle (split)
-       uint64_t tail = b->offset + b->length - (offset + length);
+       uint64_t tail = b->end() - end;
        if (b->data.length()) {
          bufferlist bl;
          bl.substr_of(b->data, b->length - tail, tail);
@@ -621,12 +621,14 @@ void BlueStore::BufferSpace::_discard(uint64_t offset, uint64_t length)
        } else {
          _add_buffer(new Buffer(this, b->state, b->seq, end, tail));
        }
+        assert(cache->buffer_size >= b->length - front);
        cache->buffer_size -= b->length - front;
        b->truncate(front);
        cache->_audit_lru("discard end 1");
        return;
       } else {
        // drop tail
+       assert(cache->buffer_size >= b->length - front);
        cache->buffer_size -= b->length - front;
        b->truncate(front);
        ++i;