Revise the naming of all sync/async io APIs

This commit is contained in:
Shaowei Song 2024-07-30 09:31:02 +00:00 committed by Tate, Hongliang Tian
parent 6847181553
commit 20a856b07f
9 changed files with 66 additions and 68 deletions

View File

@ -364,23 +364,23 @@ impl ExfatFS {
} }
impl PageCacheBackend for ExfatFS { impl PageCacheBackend for ExfatFS {
fn read_page(&self, idx: usize, frame: &Frame) -> Result<BioWaiter> { fn read_page_async(&self, idx: usize, frame: &Frame) -> Result<BioWaiter> {
if self.fs_size() < idx * PAGE_SIZE { if self.fs_size() < idx * PAGE_SIZE {
return_errno_with_message!(Errno::EINVAL, "invalid read size") return_errno_with_message!(Errno::EINVAL, "invalid read size")
} }
let waiter = self let waiter = self
.block_device .block_device
.read_block(BlockId::new(idx as u64), frame)?; .read_block_async(BlockId::new(idx as u64), frame)?;
Ok(waiter) Ok(waiter)
} }
fn write_page(&self, idx: usize, frame: &Frame) -> Result<BioWaiter> { fn write_page_async(&self, idx: usize, frame: &Frame) -> Result<BioWaiter> {
if self.fs_size() < idx * PAGE_SIZE { if self.fs_size() < idx * PAGE_SIZE {
return_errno_with_message!(Errno::EINVAL, "invalid write size") return_errno_with_message!(Errno::EINVAL, "invalid write size")
} }
let waiter = self let waiter = self
.block_device .block_device
.write_block(BlockId::new(idx as u64), frame)?; .write_block_async(BlockId::new(idx as u64), frame)?;
Ok(waiter) Ok(waiter)
} }

View File

@ -135,20 +135,20 @@ struct ExfatInodeInner {
} }
impl PageCacheBackend for ExfatInode { impl PageCacheBackend for ExfatInode {
fn read_page(&self, idx: usize, frame: &Frame) -> Result<BioWaiter> { fn read_page_async(&self, idx: usize, frame: &Frame) -> Result<BioWaiter> {
let inner = self.inner.read(); let inner = self.inner.read();
if inner.size < idx * PAGE_SIZE { if inner.size < idx * PAGE_SIZE {
return_errno_with_message!(Errno::EINVAL, "Invalid read size") return_errno_with_message!(Errno::EINVAL, "Invalid read size")
} }
let sector_id = inner.get_sector_id(idx * PAGE_SIZE / inner.fs().sector_size())?; let sector_id = inner.get_sector_id(idx * PAGE_SIZE / inner.fs().sector_size())?;
let waiter = inner.fs().block_device().read_block( let waiter = inner.fs().block_device().read_block_async(
BlockId::from_offset(sector_id * inner.fs().sector_size()), BlockId::from_offset(sector_id * inner.fs().sector_size()),
frame, frame,
)?; )?;
Ok(waiter) Ok(waiter)
} }
fn write_page(&self, idx: usize, frame: &Frame) -> Result<BioWaiter> { fn write_page_async(&self, idx: usize, frame: &Frame) -> Result<BioWaiter> {
let inner = self.inner.read(); let inner = self.inner.read();
let sector_size = inner.fs().sector_size(); let sector_size = inner.fs().sector_size();
@ -156,7 +156,7 @@ impl PageCacheBackend for ExfatInode {
// FIXME: We may need to truncate the file if write_page fails. // FIXME: We may need to truncate the file if write_page fails.
// To fix this issue, we need to change the interface of the PageCacheBackend trait. // To fix this issue, we need to change the interface of the PageCacheBackend trait.
let waiter = inner.fs().block_device().write_block( let waiter = inner.fs().block_device().write_block_async(
BlockId::from_offset(sector_id * inner.fs().sector_size()), BlockId::from_offset(sector_id * inner.fs().sector_size()),
frame, frame,
)?; )?;
@ -1274,10 +1274,7 @@ impl Inode for ExfatInode {
for _ in Bid::from_offset(read_off)..Bid::from_offset(read_off + read_len) { for _ in Bid::from_offset(read_off)..Bid::from_offset(read_off + read_len) {
let physical_bid = let physical_bid =
Bid::from_offset(cur_cluster.cluster_id() as usize * cluster_size + cur_offset); Bid::from_offset(cur_cluster.cluster_id() as usize * cluster_size + cur_offset);
inner inner.fs().block_device().read_block(physical_bid, &frame)?;
.fs()
.block_device()
.read_block_sync(physical_bid, &frame)?;
frame.read_bytes(0, &mut buf[buf_offset..buf_offset + BLOCK_SIZE])?; frame.read_bytes(0, &mut buf[buf_offset..buf_offset + BLOCK_SIZE])?;
buf_offset += BLOCK_SIZE; buf_offset += BLOCK_SIZE;
@ -1388,7 +1385,7 @@ impl Inode for ExfatInode {
let physical_bid = let physical_bid =
Bid::from_offset(cur_cluster.cluster_id() as usize * cluster_size + cur_offset); Bid::from_offset(cur_cluster.cluster_id() as usize * cluster_size + cur_offset);
let fs = inner.fs(); let fs = inner.fs();
fs.block_device().write_block_sync(physical_bid, &frame)?; fs.block_device().write_block(physical_bid, &frame)?;
buf_offset += BLOCK_SIZE; buf_offset += BLOCK_SIZE;
cur_offset += BLOCK_SIZE; cur_offset += BLOCK_SIZE;

View File

@ -318,12 +318,12 @@ impl Debug for BlockGroup {
} }
impl PageCacheBackend for BlockGroupImpl { impl PageCacheBackend for BlockGroupImpl {
fn read_page(&self, idx: usize, frame: &Frame) -> Result<BioWaiter> { fn read_page_async(&self, idx: usize, frame: &Frame) -> Result<BioWaiter> {
let bid = self.inode_table_bid + idx as Ext2Bid; let bid = self.inode_table_bid + idx as Ext2Bid;
self.fs.upgrade().unwrap().read_block_async(bid, frame) self.fs.upgrade().unwrap().read_block_async(bid, frame)
} }
fn write_page(&self, idx: usize, frame: &Frame) -> Result<BioWaiter> { fn write_page_async(&self, idx: usize, frame: &Frame) -> Result<BioWaiter> {
let bid = self.inode_table_bid + idx as Ext2Bid; let bid = self.inode_table_bid + idx as Ext2Bid;
self.fs.upgrade().unwrap().write_block_async(bid, frame) self.fs.upgrade().unwrap().write_block_async(bid, frame)
} }

View File

@ -49,7 +49,7 @@ impl Ext2 {
let segment = FrameAllocOptions::new(npages) let segment = FrameAllocOptions::new(npages)
.uninit(true) .uninit(true)
.alloc_contiguous()?; .alloc_contiguous()?;
match block_device.read_blocks_sync(super_block.group_descriptors_bid(0), &segment)? { match block_device.read_blocks(super_block.group_descriptors_bid(0), &segment)? {
BioStatus::Complete => (), BioStatus::Complete => (),
err_status => { err_status => {
return Err(Error::from(err_status)); return Err(Error::from(err_status));
@ -300,7 +300,7 @@ impl Ext2 {
pub(super) fn read_blocks(&self, bid: Ext2Bid, segment: &Segment) -> Result<()> { pub(super) fn read_blocks(&self, bid: Ext2Bid, segment: &Segment) -> Result<()> {
let status = self let status = self
.block_device .block_device
.read_blocks_sync(Bid::new(bid as u64), segment)?; .read_blocks(Bid::new(bid as u64), segment)?;
match status { match status {
BioStatus::Complete => Ok(()), BioStatus::Complete => Ok(()),
err_status => Err(Error::from(err_status)), err_status => Err(Error::from(err_status)),
@ -311,15 +311,13 @@ impl Ext2 {
pub(super) fn read_blocks_async(&self, bid: Ext2Bid, segment: &Segment) -> Result<BioWaiter> { pub(super) fn read_blocks_async(&self, bid: Ext2Bid, segment: &Segment) -> Result<BioWaiter> {
let waiter = self let waiter = self
.block_device .block_device
.read_blocks(Bid::new(bid as u64), segment)?; .read_blocks_async(Bid::new(bid as u64), segment)?;
Ok(waiter) Ok(waiter)
} }
/// Reads one block indicated by the `bid` synchronously. /// Reads one block indicated by the `bid` synchronously.
pub(super) fn read_block(&self, bid: Ext2Bid, frame: &Frame) -> Result<()> { pub(super) fn read_block(&self, bid: Ext2Bid, frame: &Frame) -> Result<()> {
let status = self let status = self.block_device.read_block(Bid::new(bid as u64), frame)?;
.block_device
.read_block_sync(Bid::new(bid as u64), frame)?;
match status { match status {
BioStatus::Complete => Ok(()), BioStatus::Complete => Ok(()),
err_status => Err(Error::from(err_status)), err_status => Err(Error::from(err_status)),
@ -328,7 +326,9 @@ impl Ext2 {
/// Reads one block indicated by the `bid` asynchronously. /// Reads one block indicated by the `bid` asynchronously.
pub(super) fn read_block_async(&self, bid: Ext2Bid, frame: &Frame) -> Result<BioWaiter> { pub(super) fn read_block_async(&self, bid: Ext2Bid, frame: &Frame) -> Result<BioWaiter> {
let waiter = self.block_device.read_block(Bid::new(bid as u64), frame)?; let waiter = self
.block_device
.read_block_async(Bid::new(bid as u64), frame)?;
Ok(waiter) Ok(waiter)
} }
@ -336,7 +336,7 @@ impl Ext2 {
pub(super) fn write_blocks(&self, bid: Ext2Bid, segment: &Segment) -> Result<()> { pub(super) fn write_blocks(&self, bid: Ext2Bid, segment: &Segment) -> Result<()> {
let status = self let status = self
.block_device .block_device
.write_blocks_sync(Bid::new(bid as u64), segment)?; .write_blocks(Bid::new(bid as u64), segment)?;
match status { match status {
BioStatus::Complete => Ok(()), BioStatus::Complete => Ok(()),
err_status => Err(Error::from(err_status)), err_status => Err(Error::from(err_status)),
@ -347,15 +347,13 @@ impl Ext2 {
pub(super) fn write_blocks_async(&self, bid: Ext2Bid, segment: &Segment) -> Result<BioWaiter> { pub(super) fn write_blocks_async(&self, bid: Ext2Bid, segment: &Segment) -> Result<BioWaiter> {
let waiter = self let waiter = self
.block_device .block_device
.write_blocks(Bid::new(bid as u64), segment)?; .write_blocks_async(Bid::new(bid as u64), segment)?;
Ok(waiter) Ok(waiter)
} }
/// Writes one block indicated by the `bid` synchronously. /// Writes one block indicated by the `bid` synchronously.
pub(super) fn write_block(&self, bid: Ext2Bid, frame: &Frame) -> Result<()> { pub(super) fn write_block(&self, bid: Ext2Bid, frame: &Frame) -> Result<()> {
let status = self let status = self.block_device.write_block(Bid::new(bid as u64), frame)?;
.block_device
.write_block_sync(Bid::new(bid as u64), frame)?;
match status { match status {
BioStatus::Complete => Ok(()), BioStatus::Complete => Ok(()),
err_status => Err(Error::from(err_status)), err_status => Err(Error::from(err_status)),
@ -364,7 +362,9 @@ impl Ext2 {
/// Writes one block indicated by the `bid` asynchronously. /// Writes one block indicated by the `bid` asynchronously.
pub(super) fn write_block_async(&self, bid: Ext2Bid, frame: &Frame) -> Result<BioWaiter> { pub(super) fn write_block_async(&self, bid: Ext2Bid, frame: &Frame) -> Result<BioWaiter> {
let waiter = self.block_device.write_block(Bid::new(bid as u64), frame)?; let waiter = self
.block_device
.write_block_async(Bid::new(bid as u64), frame)?;
Ok(waiter) Ok(waiter)
} }
@ -388,7 +388,7 @@ impl Ext2 {
self.block_device self.block_device
.write_bytes_async(SUPER_BLOCK_OFFSET, raw_super_block.as_bytes())?, .write_bytes_async(SUPER_BLOCK_OFFSET, raw_super_block.as_bytes())?,
); );
bio_waiter.concat(self.block_device.write_blocks( bio_waiter.concat(self.block_device.write_blocks_async(
super_block.group_descriptors_bid(0), super_block.group_descriptors_bid(0),
&self.group_descriptors_segment, &self.group_descriptors_segment,
)?); )?);
@ -407,7 +407,7 @@ impl Ext2 {
super_block.bid(idx as usize).to_offset(), super_block.bid(idx as usize).to_offset(),
raw_super_block_backup.as_bytes(), raw_super_block_backup.as_bytes(),
)?); )?);
bio_waiter.concat(self.block_device.write_blocks( bio_waiter.concat(self.block_device.write_blocks_async(
super_block.group_descriptors_bid(idx as usize), super_block.group_descriptors_bid(idx as usize),
&self.group_descriptors_segment, &self.group_descriptors_segment,
)?); )?);

View File

@ -1941,12 +1941,12 @@ impl InodeImpl {
} }
impl PageCacheBackend for InodeImpl { impl PageCacheBackend for InodeImpl {
fn read_page(&self, idx: usize, frame: &Frame) -> Result<BioWaiter> { fn read_page_async(&self, idx: usize, frame: &Frame) -> Result<BioWaiter> {
let bid = idx as Ext2Bid; let bid = idx as Ext2Bid;
self.read_blocks_async(bid, &Segment::from(frame.clone())) self.read_blocks_async(bid, &Segment::from(frame.clone()))
} }
fn write_page(&self, idx: usize, frame: &Frame) -> Result<BioWaiter> { fn write_page_async(&self, idx: usize, frame: &Frame) -> Result<BioWaiter> {
let bid = idx as Ext2Bid; let bid = idx as Ext2Bid;
self.write_blocks_async(bid, &Segment::from(frame.clone())) self.write_blocks_async(bid, &Segment::from(frame.clone()))
} }

View File

@ -481,13 +481,13 @@ impl RamInode {
} }
impl PageCacheBackend for RamInode { impl PageCacheBackend for RamInode {
fn read_page(&self, _idx: usize, frame: &Frame) -> Result<BioWaiter> { fn read_page_async(&self, _idx: usize, frame: &Frame) -> Result<BioWaiter> {
// Initially, any block/page in a RamFs inode contains all zeros // Initially, any block/page in a RamFs inode contains all zeros
frame.writer().fill(0); frame.writer().fill(0);
Ok(BioWaiter::new()) Ok(BioWaiter::new())
} }
fn write_page(&self, _idx: usize, _frame: &Frame) -> Result<BioWaiter> { fn write_page_async(&self, _idx: usize, _frame: &Frame) -> Result<BioWaiter> {
// do nothing // do nothing
Ok(BioWaiter::new()) Ok(BioWaiter::new())
} }

View File

@ -305,7 +305,7 @@ impl ReadaheadState {
}; };
for async_idx in window.readahead_range() { for async_idx in window.readahead_range() {
let mut async_page = Page::alloc()?; let mut async_page = Page::alloc()?;
let pg_waiter = backend.read_page(async_idx, async_page.frame())?; let pg_waiter = backend.read_page_async(async_idx, async_page.frame())?;
self.waiter.concat(pg_waiter); self.waiter.concat(pg_waiter);
async_page.set_state(PageState::Uninit); async_page.set_state(PageState::Uninit);
pages.put(async_idx, async_page); pages.put(async_idx, async_page);
@ -341,8 +341,9 @@ impl PageCacheManager {
// Discard pages without writing them back to disk. // Discard pages without writing them back to disk.
pub fn discard_range(&self, range: Range<usize>) { pub fn discard_range(&self, range: Range<usize>) {
let page_idx_range = get_page_idx_range(&range); let page_idx_range = get_page_idx_range(&range);
let mut pages = self.pages.lock();
for idx in page_idx_range { for idx in page_idx_range {
self.pages.lock().pop(&idx); pages.pop(&idx);
} }
} }
@ -356,7 +357,7 @@ impl PageCacheManager {
for idx in page_idx_range.start..page_idx_range.end { for idx in page_idx_range.start..page_idx_range.end {
if let Some(page) = pages.peek(&idx) { if let Some(page) = pages.peek(&idx) {
if *page.state() == PageState::Dirty && idx < backend_npages { if *page.state() == PageState::Dirty && idx < backend_npages {
let waiter = backend.write_page(idx, page.frame())?; let waiter = backend.write_page_async(idx, page.frame())?;
bio_waiter.concat(waiter); bio_waiter.concat(waiter);
} }
} }
@ -407,7 +408,7 @@ impl PageCacheManager {
// Conducts the sync read operation. // Conducts the sync read operation.
let page = if idx < backend.npages() { let page = if idx < backend.npages() {
let mut page = Page::alloc()?; let mut page = Page::alloc()?;
backend.read_page_sync(idx, page.frame())?; backend.read_page(idx, page.frame())?;
page.set_state(PageState::UpToDate); page.set_state(PageState::UpToDate);
page page
} else { } else {
@ -458,7 +459,7 @@ impl Pager for PageCacheManager {
return Ok(()); return Ok(());
}; };
if idx < backend.npages() { if idx < backend.npages() {
backend.write_page_sync(idx, page.frame())?; backend.write_page(idx, page.frame())?;
} }
} }
} }
@ -528,25 +529,25 @@ enum PageState {
/// This trait represents the backend for the page cache. /// This trait represents the backend for the page cache.
pub trait PageCacheBackend: Sync + Send { pub trait PageCacheBackend: Sync + Send {
/// Reads a page from the backend asynchronously. /// Reads a page from the backend asynchronously.
fn read_page(&self, idx: usize, frame: &Frame) -> Result<BioWaiter>; fn read_page_async(&self, idx: usize, frame: &Frame) -> Result<BioWaiter>;
/// Writes a page to the backend asynchronously. /// Writes a page to the backend asynchronously.
fn write_page(&self, idx: usize, frame: &Frame) -> Result<BioWaiter>; fn write_page_async(&self, idx: usize, frame: &Frame) -> Result<BioWaiter>;
/// Returns the number of pages in the backend. /// Returns the number of pages in the backend.
fn npages(&self) -> usize; fn npages(&self) -> usize;
} }
impl dyn PageCacheBackend { impl dyn PageCacheBackend {
/// Reads a page from the backend synchronously. /// Reads a page from the backend synchronously.
fn read_page_sync(&self, idx: usize, frame: &Frame) -> Result<()> { fn read_page(&self, idx: usize, frame: &Frame) -> Result<()> {
let waiter = self.read_page(idx, frame)?; let waiter = self.read_page_async(idx, frame)?;
match waiter.wait() { match waiter.wait() {
Some(BioStatus::Complete) => Ok(()), Some(BioStatus::Complete) => Ok(()),
_ => return_errno!(Errno::EIO), _ => return_errno!(Errno::EIO),
} }
} }
/// Writes a page to the backend synchronously. /// Writes a page to the backend synchronously.
fn write_page_sync(&self, idx: usize, frame: &Frame) -> Result<()> { fn write_page(&self, idx: usize, frame: &Frame) -> Result<()> {
let waiter = self.write_page(idx, frame)?; let waiter = self.write_page_async(idx, frame)?;
match waiter.wait() { match waiter.wait() {
Some(BioStatus::Complete) => Ok(()), Some(BioStatus::Complete) => Ok(()),
_ => return_errno!(Errno::EIO), _ => return_errno!(Errno::EIO),

View File

@ -110,7 +110,7 @@ impl Bio {
/// # Panics /// # Panics
/// ///
/// The caller must not submit a `Bio` more than once. Otherwise, a panic shall be triggered. /// The caller must not submit a `Bio` more than once. Otherwise, a panic shall be triggered.
pub fn submit_sync( pub fn submit_and_wait(
&self, &self,
block_device: &dyn BlockDevice, block_device: &dyn BlockDevice,
) -> Result<BioStatus, BioEnqueueError> { ) -> Result<BioStatus, BioEnqueueError> {

View File

@ -14,61 +14,61 @@ use crate::prelude::*;
// TODO: Add API to submit bio with multiple segments in scatter/gather manner. // TODO: Add API to submit bio with multiple segments in scatter/gather manner.
impl dyn BlockDevice { impl dyn BlockDevice {
/// Synchronously reads contiguous blocks starting from the `bid`. /// Synchronously reads contiguous blocks starting from the `bid`.
pub fn read_blocks_sync( pub fn read_blocks(&self, bid: Bid, segment: &Segment) -> Result<BioStatus, BioEnqueueError> {
&self,
bid: Bid,
segment: &Segment,
) -> Result<BioStatus, BioEnqueueError> {
let bio = create_bio_from_segment(BioType::Read, bid, segment); let bio = create_bio_from_segment(BioType::Read, bid, segment);
let status = bio.submit_sync(self)?; let status = bio.submit_and_wait(self)?;
Ok(status) Ok(status)
} }
/// Asynchronously reads contiguous blocks starting from the `bid`. /// Asynchronously reads contiguous blocks starting from the `bid`.
pub fn read_blocks(&self, bid: Bid, segment: &Segment) -> Result<BioWaiter, BioEnqueueError> { pub fn read_blocks_async(
&self,
bid: Bid,
segment: &Segment,
) -> Result<BioWaiter, BioEnqueueError> {
let bio = create_bio_from_segment(BioType::Read, bid, segment); let bio = create_bio_from_segment(BioType::Read, bid, segment);
bio.submit(self) bio.submit(self)
} }
/// Synchronously reads one block indicated by the `bid`. /// Synchronously reads one block indicated by the `bid`.
pub fn read_block_sync(&self, bid: Bid, frame: &Frame) -> Result<BioStatus, BioEnqueueError> { pub fn read_block(&self, bid: Bid, frame: &Frame) -> Result<BioStatus, BioEnqueueError> {
let bio = create_bio_from_frame(BioType::Read, bid, frame); let bio = create_bio_from_frame(BioType::Read, bid, frame);
let status = bio.submit_sync(self)?; let status = bio.submit_and_wait(self)?;
Ok(status) Ok(status)
} }
/// Asynchronously reads one block indicated by the `bid`. /// Asynchronously reads one block indicated by the `bid`.
pub fn read_block(&self, bid: Bid, frame: &Frame) -> Result<BioWaiter, BioEnqueueError> { pub fn read_block_async(&self, bid: Bid, frame: &Frame) -> Result<BioWaiter, BioEnqueueError> {
let bio = create_bio_from_frame(BioType::Read, bid, frame); let bio = create_bio_from_frame(BioType::Read, bid, frame);
bio.submit(self) bio.submit(self)
} }
/// Synchronously writes contiguous blocks starting from the `bid`. /// Synchronously writes contiguous blocks starting from the `bid`.
pub fn write_blocks_sync( pub fn write_blocks(&self, bid: Bid, segment: &Segment) -> Result<BioStatus, BioEnqueueError> {
&self,
bid: Bid,
segment: &Segment,
) -> Result<BioStatus, BioEnqueueError> {
let bio = create_bio_from_segment(BioType::Write, bid, segment); let bio = create_bio_from_segment(BioType::Write, bid, segment);
let status = bio.submit_sync(self)?; let status = bio.submit_and_wait(self)?;
Ok(status) Ok(status)
} }
/// Asynchronously writes contiguous blocks starting from the `bid`. /// Asynchronously writes contiguous blocks starting from the `bid`.
pub fn write_blocks(&self, bid: Bid, segment: &Segment) -> Result<BioWaiter, BioEnqueueError> { pub fn write_blocks_async(
&self,
bid: Bid,
segment: &Segment,
) -> Result<BioWaiter, BioEnqueueError> {
let bio = create_bio_from_segment(BioType::Write, bid, segment); let bio = create_bio_from_segment(BioType::Write, bid, segment);
bio.submit(self) bio.submit(self)
} }
/// Synchronously writes one block indicated by the `bid`. /// Synchronously writes one block indicated by the `bid`.
pub fn write_block_sync(&self, bid: Bid, frame: &Frame) -> Result<BioStatus, BioEnqueueError> { pub fn write_block(&self, bid: Bid, frame: &Frame) -> Result<BioStatus, BioEnqueueError> {
let bio = create_bio_from_frame(BioType::Write, bid, frame); let bio = create_bio_from_frame(BioType::Write, bid, frame);
let status = bio.submit_sync(self)?; let status = bio.submit_and_wait(self)?;
Ok(status) Ok(status)
} }
/// Asynchronously writes one block indicated by the `bid`. /// Asynchronously writes one block indicated by the `bid`.
pub fn write_block(&self, bid: Bid, frame: &Frame) -> Result<BioWaiter, BioEnqueueError> { pub fn write_block_async(&self, bid: Bid, frame: &Frame) -> Result<BioWaiter, BioEnqueueError> {
let bio = create_bio_from_frame(BioType::Write, bid, frame); let bio = create_bio_from_frame(BioType::Write, bid, frame);
bio.submit(self) bio.submit(self)
} }
@ -106,7 +106,7 @@ impl VmIo for dyn BlockDevice {
) )
}; };
let status = bio.submit_sync(self)?; let status = bio.submit_and_wait(self)?;
match status { match status {
BioStatus::Complete => { BioStatus::Complete => {
let _ = bio_segment.reader().read(&mut buf.into()); let _ = bio_segment.reader().read(&mut buf.into());
@ -148,7 +148,7 @@ impl VmIo for dyn BlockDevice {
) )
}; };
let status = bio.submit_sync(self)?; let status = bio.submit_and_wait(self)?;
match status { match status {
BioStatus::Complete => Ok(()), BioStatus::Complete => Ok(()),
_ => Err(ostd::Error::IoError), _ => Err(ostd::Error::IoError),