From: Jason Dillaman Date: Mon, 10 Aug 2015 13:34:42 +0000 (-0400) Subject: common: bit_vector extent calculation incorrect for last page X-Git-Tag: v0.94.4~78^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fca78765366f3ac365cfa98224aca5fb79b2a7fe;p=ceph.git common: bit_vector extent calculation incorrect for last page It's highly probable that the last page in the bit vector will not be a full page size. As a result, the computed extents will extend beyond the data portion of the bit vector, resulting in a end_of_buffer exception. Fixes: #12611 Backport: hammer Signed-off-by: Jason Dillaman (cherry picked from commit c6d98992691683524d3d96def83a90a6f5fe7f93) --- diff --git a/src/common/bit_vector.hpp b/src/common/bit_vector.hpp index 55403c5d35cd..f66294b54752 100644 --- a/src/common/bit_vector.hpp +++ b/src/common/bit_vector.hpp @@ -261,7 +261,10 @@ void BitVector<_b>::get_data_extents(uint64_t offset, uint64_t length, end_offset += (CEPH_PAGE_SIZE - (end_offset % CEPH_PAGE_SIZE)); assert(*byte_offset <= end_offset); - *byte_length = MIN(end_offset - *byte_offset, m_data.length()); + *byte_length = end_offset - *byte_offset; + if (*byte_offset + *byte_length > m_data.length()) { + *byte_length = m_data.length() - *byte_offset; + } } template