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 <dillaman@redhat.com>
This commit is contained in:
Jason Dillaman 2015-08-10 09:34:42 -04:00
parent e35d27fc69
commit c6d9899269

View File

@ -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 <uint8_t _b>