]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: add a boundary check of cache read 10349/head
authorxie xingguo <xie.xingguo@zte.com.cn>
Tue, 19 Jul 2016 12:02:48 +0000 (20:02 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Wed, 20 Jul 2016 02:37:16 +0000 (10:37 +0800)
By trapping the "==" case and break, we can finish
the cache read just in time. As a result, we can avoid
two extra operations(adjusting "offset" and "length") and
the final loop check.

Since this is one of key methods of cache, it deserves this
fix.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/os/bluestore/BlueStore.cc

index c4ba07b251af50f52d98df5c919c8388634b5ee9..4e0c93ac40dab6d04b488925fc2a70522f2cfd85 100644 (file)
@@ -1008,6 +1008,8 @@ void BlueStore::BufferSpace::read(
       } else {
        res[offset].append(b->data);
        res_intervals.insert(offset, b->length);
+        if (b->length == length)
+          break;
        offset += b->length;
        length -= b->length;
       }