-
Notifications
You must be signed in to change notification settings - Fork 566
Description
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().