Skip to content

Commit

Permalink
disk_layered: populate read caches (#683)
Browse files Browse the repository at this point in the history
Populate read cache layers in the read path.
  • Loading branch information
jstarks authored Jan 17, 2025
1 parent d1413d9 commit 7a9d0e0
Show file tree
Hide file tree
Showing 5 changed files with 335 additions and 6 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1242,8 +1242,11 @@ dependencies = [
"futures",
"guestmem",
"inspect",
"pal_async",
"parking_lot",
"scsi_buffers",
"thiserror 2.0.0",
"tracelimit",
"vm_resource",
]

Expand Down
6 changes: 6 additions & 0 deletions vm/devices/storage/disk_layered/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@ scsi_buffers.workspace = true
guestmem.workspace = true
vm_resource.workspace = true
inspect = { workspace = true, features = ["std"] }
tracelimit.workspace = true

anyhow.workspace = true
async-trait.workspace = true
futures.workspace = true
thiserror.workspace = true

[dev-dependencies]
pal_async.workspace = true

parking_lot.workspace = true

[lints]
workspace = true
13 changes: 13 additions & 0 deletions vm/devices/storage/disk_layered/src/bitmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,19 @@ impl SectorBitmapRange<'_> {
pub fn set_count(&self) -> usize {
self.set_count
}

pub(crate) fn unset_iter(&self) -> impl '_ + Iterator<Item = Range<u64>> {
let mut n = self.start_sector;
self.bits.chunk_by(|&a, &b| a == b).filter_map(move |bits| {
let start = n;
n += bits.len() as u64;
if bits.first().is_some_and(|&x| !x) {
Some(start..n)
} else {
None
}
})
}
}

/// A type to mark sectors that have been read by a layer as part of a
Expand Down
Loading

0 comments on commit 7a9d0e0

Please sign in to comment.