From: xie xingguo Date: Tue, 19 Jul 2016 12:02:48 +0000 (+0800) Subject: os/bluestore: add a boundary check of cache read X-Git-Tag: ses5-milestone5~297^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3bc31746b5d9983920ae68eded1bef2a32ac342a;p=ceph.git os/bluestore: add a boundary check of cache read 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 --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index c4ba07b251af..4e0c93ac40da 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -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; }