]> git.proxmox.com Git - mirror_qemu.git/commit - block/file-posix.c
file-posix: Fix write_zeroes with unmap on block devices
authorKevin Wolf <kwolf@redhat.com>
Thu, 26 Jul 2018 09:28:30 +0000 (11:28 +0200)
committerKevin Wolf <kwolf@redhat.com>
Mon, 30 Jul 2018 13:35:37 +0000 (15:35 +0200)
commit34fa110e424e9a6a9b7e0274c3d4bfee766eb7ed
tree9945980f1dc926e3eded753cd982e2778055fd38
parent52ebcb268273de217510bc9ed688c23894ae32a2
file-posix: Fix write_zeroes with unmap on block devices

The BLKDISCARD ioctl doesn't guarantee that the discarded blocks read as
all-zero afterwards, so don't try to abuse it for zero writing. We try
to only use this if BLKDISCARDZEROES tells us that it is safe, but this
is unreliable on older kernels and a constant 0 in newer kernels. In
other words, this code path is never actually used with newer kernels,
so we don't even try to unmap while writing zeros.

This patch removes the abuse of discard for writing zeroes from
file-posix and instead adds a new function that uses interfaces that are
actually meant to deallocate and zero out at the same time. Only if
those fail, it falls back to zeroing out without unmap. We never fall
back to a discard operation any more that may or may not result in
zeros.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/file-posix.c