FileBlockReader::fill_buffer make it obvious that we need to switch to async API

This commit is contained in:
Christian Schwarz
2023-08-31 11:49:08 +02:00
committed by Arpad Müller
parent cfabd8b598
commit 92b7d7f466

View File

@@ -154,7 +154,7 @@ impl FileBlockReader<VirtualFile> {
}
/// Read a page from the underlying file into given buffer.
fn fill_buffer(&self, buf: &mut [u8], blkno: u32) -> Result<(), std::io::Error> {
async fn fill_buffer(&self, buf: &mut [u8], blkno: u32) -> Result<(), std::io::Error> {
assert!(buf.len() == PAGE_SZ);
self.file.read_exact_at(buf, blkno as u64 * PAGE_SZ as u64)
}
@@ -178,7 +178,7 @@ impl FileBlockReader<VirtualFile> {
ReadBufResult::Found(guard) => break Ok(guard.into()),
ReadBufResult::NotFound(mut write_guard) => {
// Read the page from disk into the buffer
self.fill_buffer(write_guard.deref_mut(), blknum)?;
self.fill_buffer(write_guard.deref_mut(), blknum).await?;
write_guard.mark_valid();
// Swap for read lock