Skip to content

Commit 61987ea

Browse files
authored
Filter the result for find_prev_non_zero_value_fast to make sure it is in the search range (#1192)
1 parent fa53275 commit 61987ea

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/util/metadata/side_metadata/global.rs

+7
Original file line numberDiff line numberDiff line change
@@ -1066,6 +1066,8 @@ impl SideMetadataSpec {
10661066
let end_addr = data_addr;
10671067

10681068
// Then figure out the start and end metadata address and bits.
1069+
// The start bit may not be accurate, as we map any address in the region to the same bit.
1070+
// We will filter the result at the end to make sure the found address is in the search range.
10691071
let start_meta_addr = address_to_contiguous_meta_address(self, start_addr);
10701072
let start_meta_shift = meta_byte_lshift(self, start_addr);
10711073
let end_meta_addr = address_to_contiguous_meta_address(self, end_addr);
@@ -1120,7 +1122,12 @@ impl SideMetadataSpec {
11201122
&mut visitor,
11211123
);
11221124

1125+
// We have to filter the result. We search between [start_addr, end_addr). But we actually
1126+
// search with metadata bits. It is possible the metadata bit for start_addr is the same bit
1127+
// as an address that is before start_addr. E.g. 0x2010f026360 and 0x2010f026361 are mapped
1128+
// to the same bit, 0x2010f026361 is the start address and 0x2010f026360 is outside the search range.
11231129
res.map(|addr| addr.align_down(1 << self.log_bytes_in_region))
1130+
.filter(|addr| *addr >= start_addr && *addr < end_addr)
11241131
}
11251132

11261133
/// Search for data addresses that have non zero values in the side metadata. This method is

0 commit comments

Comments
 (0)