From fca78765366f3ac365cfa98224aca5fb79b2a7fe Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Mon, 10 Aug 2015 09:34:42 -0400 Subject: [PATCH] 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) --- src/common/bit_vector.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/common/bit_vector.hpp b/src/common/bit_vector.hpp index 55403c5d35cdb..f66294b54752e 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 -- 2.39.5