]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common: bit_vector extent calculation incorrect for last page
authorJason Dillaman <dillaman@redhat.com>
Mon, 10 Aug 2015 13:34:42 +0000 (09:34 -0400)
committerJason Dillaman <dillaman@redhat.com>
Thu, 13 Aug 2015 03:13:45 +0000 (23:13 -0400)
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>
(cherry picked from commit c6d98992691683524d3d96def83a90a6f5fe7f93)

src/common/bit_vector.hpp

index 55403c5d35cdb3a5868001402e9de073f1543db0..f66294b54752ef097a47189c07ccc03b6d528356 100644 (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>