Skip to content

virtio-block VIRTIO_BLK_T_FLUSH implementation #399

@ZideChen0

Description

@ZideChen0

Currently Cloud-hypervisor call disk.flush for guest VIRTIO_BLK_T_FLUSH request:

RequestType::Flush => match disk.flush() {
}

Which actually doesn't nothing:
https://github.com/rust-lang/rust/blob/master/src/libstd/sys/unix/fs.rs#L791
pub fn flush(&self) -> io::Result<()> { Ok(()) }

Probably this is not compliant with virtio spec:
"If the device is backed by persistent storage, the device MUST ensure that stable writes are committed to it, before reporting completion of the write (cases 1 and 2) or the flush (case 3). Failure to do so can cause data loss in case of a crash."

I'd like to propose to use nix::sys::aio::fsync() for this purpose, which has better performance then the synchronous counterpart std::fs::File::sync_all()/sync_data().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions