[space_map (rust)] Fix cache hit with async-io
This commit is contained in:
parent
5dd2e81bf0
commit
361d19adaa
@ -77,7 +77,7 @@ fn adjust_counts(
|
||||
let nr_free = ie.nr_free - (end - begin) as u32;
|
||||
|
||||
// Read the bitmap
|
||||
let bitmap_block = w.engine.read(ie.blocknr)?;
|
||||
let bitmap_block = w.read(ie.blocknr)?;
|
||||
let (_, mut bitmap) = Bitmap::unpack(bitmap_block.get_data())?;
|
||||
|
||||
// Update all the entries
|
||||
|
@ -109,6 +109,14 @@ impl WriteBatcher {
|
||||
pub fn write(&mut self, b: Block, kind: checksum::BT) -> Result<()> {
|
||||
checksum::write_checksum(&mut b.get_data(), kind)?;
|
||||
|
||||
for blk in self.queue.iter().rev() {
|
||||
if blk.loc == b.loc {
|
||||
// write hit
|
||||
blk.get_data().copy_from_slice(b.get_data());
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
||||
if self.queue.len() == self.batch_size {
|
||||
let mut tmp = Vec::new();
|
||||
std::mem::swap(&mut tmp, &mut self.queue);
|
||||
|
Loading…
Reference in New Issue
Block a user