On Thu, Apr 17, 2025 at 05:10:53PM -0400, Stefan Hajnoczi wrote:
> The Linux BLKZEROOUT ioctl is only invoked when BDRV_O_NOCACHE is set
> because old kernels did not invalidate the page cache. In that case
> mixing BLKZEROOUT with buffered I/O could lead to corruption.
> 
> However, Linux 4.9 commit 22dd6d356628 ("block: invalidate the page
> cache when issuing BLKZEROOUT") made BLKZEROOUT coherent with the page
> cache.
> 
> I have checked that Linux 4.9+ kernels are shipped at least as far back
> as Debian 10 (buster), openSUSE Leap 15.2, and RHEL/CentOS 8.
> 
> Use BLKZEROOUT with buffered I/O, mostly so `qemu-img ... -t
> writeback` can offload write zeroes.
> 
> Cc: Paolo Bonzini <pbonz...@redhat.com>
> Cc: Christoph Hellwig <h...@lst.de>
> Signed-off-by: Stefan Hajnoczi <stefa...@redhat.com>
> ---
>  block/file-posix.c | 11 -----------
>  1 file changed, 11 deletions(-)

Reviewed-by: Eric Blake <ebl...@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.
Virtualization:  qemu.org | libguestfs.org


Reply via email to