Skip to content

Commit

Permalink
os/bluestore: add a boundary check of cache read
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
xiexingguo committed Jul 20, 2016
1 parent d1f681a commit 3bc3174
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/os/bluestore/BlueStore.cc
Expand Up @@ -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;
}
Expand Down

0 comments on commit 3bc3174

Please sign in to comment.