crosvm/qcow
Daniel Verkamp 510c783c84 sys_util: add trait to fsync File and QcowFile
File exposes sync_all() and sync_data() functions, which map to fsync()
and fdatasync(), but these functions are not in a trait (they are just
implemented directly on File), so they can't be implemented and used in
a generic way for QcowFile.

Add a new trait, FileSync, that exposes a fsync() function that may be
used in the virtio block model.  Previously, we were translating a block
flush request into a call to File's flush() function, but this just
flushes internal Rust library buffers to the file descriptor; it didn't
actually result in a fsync() call.  Using the new trait, we can cause an
actual fsync() to occur for raw files, as intended.  QcowFile was
already safe, since its flush() function actually calls sync_all() under
the hood.

BUG=None
TEST=sync with raw disk and verify fsync() in strace output

Change-Id: I9bee2c0d2df3747aac1e7d9ec7d9b46a7862dc48
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1297839
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2018-10-26 17:19:10 -07:00
..
src sys_util: add trait to fsync File and QcowFile 2018-10-26 17:19:10 -07:00
Cargo.toml qcow: implement WriteZeroes for QcowFile 2018-09-05 01:25:50 -07:00