diff options
author | Daniel Verkamp <dverkamp@chromium.org> | 2018-09-27 13:47:31 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-10-13 14:55:24 -0700 |
commit | abbe0c8cf0e5c418d46f0c6c4cabbd02b6702bd0 (patch) | |
tree | 8885fa3d838bb80b21c3831f46766554d059ea10 /sys_util | |
parent | 6c765fd2ac2937c5bde286d33e3c9b87505078e9 (diff) | |
download | crosvm-abbe0c8cf0e5c418d46f0c6c4cabbd02b6702bd0.tar crosvm-abbe0c8cf0e5c418d46f0c6c4cabbd02b6702bd0.tar.gz crosvm-abbe0c8cf0e5c418d46f0c6c4cabbd02b6702bd0.tar.bz2 crosvm-abbe0c8cf0e5c418d46f0c6c4cabbd02b6702bd0.tar.lz crosvm-abbe0c8cf0e5c418d46f0c6c4cabbd02b6702bd0.tar.xz crosvm-abbe0c8cf0e5c418d46f0c6c4cabbd02b6702bd0.tar.zst crosvm-abbe0c8cf0e5c418d46f0c6c4cabbd02b6702bd0.zip |
sys_util: use PUNCH_HOLE to implement write_zeroes
Some filesystems do not support FALLOC_FL_ZERO_RANGE; in particular, encrypted files on ext4 fail this request with -EOPNOTSUPP. Use fallocate with FALLOC_FL_PUNCH_HOLE instead, which is more widely supported. BUG=None TEST=strace crosvm using qcow files on encrypted ext4 and verify that fallocate(FALLOC_FL_PUNCH_HOLE) is issued when required. Change-Id: Idffabc75ea0e1153efbb13cec8b4a25570427235 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1250022 Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
Diffstat (limited to 'sys_util')
-rw-r--r-- | sys_util/src/write_zeroes.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/sys_util/src/write_zeroes.rs b/sys_util/src/write_zeroes.rs index 31ea652..15e9344 100644 --- a/sys_util/src/write_zeroes.rs +++ b/sys_util/src/write_zeroes.rs @@ -17,9 +17,9 @@ pub trait WriteZeroes { impl WriteZeroes for File { fn write_zeroes(&mut self, length: usize) -> io::Result<usize> { - // Try to use fallocate(FALLOC_FL_ZERO_RANGE) first. + // Try to use fallocate(FALLOC_FL_PUNCH_HOLE) first. let offset = self.seek(SeekFrom::Current(0))?; - match fallocate(self, FallocateMode::ZeroRange, false, offset, length as u64) { + match fallocate(self, FallocateMode::PunchHole, true, offset, length as u64) { Ok(()) => { // Advance the seek cursor as if we had done a real write(). self.seek(SeekFrom::Current(length as i64))?; |