qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] block: use pwrite_zeroes_alignment when writing first sector
@ 2025-10-02 18:39 Stefan Hajnoczi
  2025-10-02 18:39 ` [PATCH 1/3] file-posix: populate pwrite_zeroes_alignment Stefan Hajnoczi
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Stefan Hajnoczi @ 2025-10-02 18:39 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, qemu-block, Jean-Louis Dupond, Hanna Reitz,
	Stefan Hajnoczi

This series fixes a bug I introduced in commit 5634622bcb33 ("file-posix: allow
BLKZEROOUT with -t writeback"). The Linux fallocate(2) and ioctl(BLKZEROOUT)
syscalls require logical block size alignment of the offset and length, even
when the file is opened in buffered I/O mode where read/write operations do not
require alignment.

The fix is to populate the pwrite_zeroes_alignment block limits field and to
use that limit in create_file_fallback_zero_first_sector().

One issue I want to raise is that pwrite_zeroes_alignment is an "optimal
alignment" hint. Hence create_file_fallback_zero_first_sector() had to be
modified to honor the limit explicitly. The block layer doesn't automatically
apply padding in order to align requests. This is different from how QEMU's
block layer pwrite/pread works, where it does automatically apply padding and
read/modify/write as necessary. If you want consistency, please let me know.

Stefan Hajnoczi (3):
  file-posix: populate pwrite_zeroes_alignment
  block: use pwrite_zeroes_alignment when writing first sector
  iotests: add Linux loop device image creation test

 include/system/block-backend-io.h             |  1 +
 block.c                                       |  3 +-
 block/block-backend.c                         | 11 ++++
 block/file-posix.c                            | 17 ++++++
 tests/qemu-iotests/tests/loop-create-file     | 59 +++++++++++++++++++
 tests/qemu-iotests/tests/loop-create-file.out |  8 +++
 6 files changed, 98 insertions(+), 1 deletion(-)
 create mode 100755 tests/qemu-iotests/tests/loop-create-file
 create mode 100644 tests/qemu-iotests/tests/loop-create-file.out

-- 
2.51.0



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2025-10-07  9:09 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-02 18:39 [PATCH 0/3] block: use pwrite_zeroes_alignment when writing first sector Stefan Hajnoczi
2025-10-02 18:39 ` [PATCH 1/3] file-posix: populate pwrite_zeroes_alignment Stefan Hajnoczi
2025-10-03  7:55   ` Vladimir Sementsov-Ogievskiy
2025-10-06 14:57     ` Stefan Hajnoczi
2025-10-07  9:08       ` Vladimir Sementsov-Ogievskiy
2025-10-03  8:04   ` Vladimir Sementsov-Ogievskiy
2025-10-06 14:46     ` Stefan Hajnoczi
2025-10-02 18:39 ` [PATCH 2/3] block: use pwrite_zeroes_alignment when writing first sector Stefan Hajnoczi
2025-10-03  7:56   ` Vladimir Sementsov-Ogievskiy
2025-10-02 18:40 ` [PATCH 3/3] iotests: add Linux loop device image creation test Stefan Hajnoczi
2025-10-03  7:52 ` [PATCH 0/3] block: use pwrite_zeroes_alignment when writing first sector Vladimir Sementsov-Ogievskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).