From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, qemu-devel@nongnu.org
Subject: [PULL 4/5] file-posix: allow BLKZEROOUT with -t writeback
Date: Thu, 22 May 2025 20:31:14 +0200 [thread overview]
Message-ID: <20250522183115.246746-5-kwolf@redhat.com> (raw)
In-Reply-To: <20250522183115.246746-1-kwolf@redhat.com>
From: Stefan Hajnoczi <stefanha@redhat.com>
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 <pbonzini@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-ID: <20250417211053.98700-1-stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/file-posix.c | 11 -----------
1 file changed, 11 deletions(-)
diff --git a/block/file-posix.c b/block/file-posix.c
index ec95b74869..5a3532e40b 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -785,17 +785,6 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
}
#endif
- if (S_ISBLK(st.st_mode)) {
-#ifdef __linux__
- /* On Linux 3.10, BLKDISCARD leaves stale data in the page cache. Do
- * not rely on the contents of discarded blocks unless using O_DIRECT.
- * Same for BLKZEROOUT.
- */
- if (!(bs->open_flags & BDRV_O_NOCACHE)) {
- s->has_write_zeroes = false;
- }
-#endif
- }
#ifdef __FreeBSD__
if (S_ISCHR(st.st_mode)) {
/*
--
2.49.0
next prev parent reply other threads:[~2025-05-22 18:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-22 18:31 [PULL 0/5] Block layer patches Kevin Wolf
2025-05-22 18:31 ` [PULL 1/5] scsi-disk: Add native FUA write support Kevin Wolf
2025-05-22 18:31 ` [PULL 2/5] scsi-disk: Advertise FUA support by default Kevin Wolf
2025-05-22 18:31 ` [PULL 3/5] qemu-img: fix offset calculation in bench Kevin Wolf
2025-05-22 18:31 ` Kevin Wolf [this message]
2025-05-22 18:31 ` [PULL 5/5] file-posix: Probe paths and retry SG_IO on potential path errors Kevin Wolf
2025-05-23 15:45 ` [PULL 0/5] Block layer patches Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250522183115.246746-5-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.