Skip to content

Commit

Permalink
Filter the result for find_prev_non_zero_value_fast to make sure it i…
Browse files Browse the repository at this point in the history
…s in the search range (#1192)
  • Loading branch information
qinsoon authored Sep 2, 2024
1 parent fa53275 commit 61987ea
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/util/metadata/side_metadata/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,8 @@ impl SideMetadataSpec {
let end_addr = data_addr;

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

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

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

0 comments on commit 61987ea

Please sign in to comment.