diff options
author | Frédéric Danis <frederic.danis@collabora.com> | 2022-01-25 20:14:05 +0300 |
---|---|---|
committer | Richard Weinberger <richard@nod.at> | 2022-03-11 12:46:34 +0300 |
commit | d2a0a616ab2246aab9527eeacf86a033679c8b22 (patch) | |
tree | f20757bf5efbfacc01c905f417b35fadc9eaf9fe /arch/um/os-Linux | |
parent | b35507a4cfb26b7fcc0c97de6367828d5902bbba (diff) | |
download | linux-d2a0a616ab2246aab9527eeacf86a033679c8b22.tar.xz |
um: Fix WRITE_ZEROES in the UBD Driver
Call to fallocate with FALLOC_FL_PUNCH_HOLE on a device backed by a sparse
file can end up by missing data, zeroes data range, if the underlying file
is used with a tool like bmaptool which will referenced only used spaces.
Signed-off-by: Frédéric Danis <frederic.danis@collabora.com>
Acked-by: Anton Ivanov <anton.ivanov@cambridgegreys.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'arch/um/os-Linux')
-rw-r--r-- | arch/um/os-Linux/file.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/arch/um/os-Linux/file.c b/arch/um/os-Linux/file.c index e4421dbc4c36..fc4450db59bd 100644 --- a/arch/um/os-Linux/file.c +++ b/arch/um/os-Linux/file.c @@ -625,6 +625,15 @@ int os_falloc_punch(int fd, unsigned long long offset, int len) return n; } +int os_falloc_zeroes(int fd, unsigned long long offset, int len) +{ + int n = fallocate(fd, FALLOC_FL_ZERO_RANGE|FALLOC_FL_KEEP_SIZE, offset, len); + + if (n < 0) + return -errno; + return n; +} + int os_eventfd(unsigned int initval, int flags) { int fd = eventfd(initval, flags); |