]> git.ipfire.org Git - thirdparty/qemu.git/commit
block: Expand block status mode from bool to flags
authorEric Blake <eblake@redhat.com>
Fri, 9 May 2025 20:40:18 +0000 (15:40 -0500)
committerEric Blake <eblake@redhat.com>
Wed, 14 May 2025 20:33:34 +0000 (15:33 -0500)
commitc33159dec79069514f78faecfe268439226b0f5b
tree651e46b5273c37edbe34f125d607998dc01743a8
parent864813878951b44e964eb4c012d832fd21f8cc0c
block: Expand block status mode from bool to flags

This patch is purely mechanical, changing bool want_zero into an
unsigned int for bitwise-or of flags.  As of this patch, all
implementations are unchanged (the old want_zero==true is now
mode==BDRV_WANT_PRECISE which is a superset of BDRV_WANT_ZERO); but
the callers in io.c that used to pass want_zero==false are now
prepared for future driver changes that can now distinguish bewteen
BDRV_WANT_ZERO vs. BDRV_WANT_ALLOCATED.  The next patch will actually
change the file-posix driver along those lines, now that we have
more-specific hints.

As for the background why this patch is useful: right now, the
file-posix driver recognizes that if allocation is being queried, the
entire image can be reported as allocated (there is no backing file to
refer to) - but this throws away information on whether the entire
image reads as zero (trivially true if lseek(SEEK_HOLE) at offset 0
returns -ENXIO, a bit more complicated to prove if the raw file was
created with 'qemu-img create' since we intentionally allocate a small
chunk of all-zero data to help with alignment probing).  Later patches
will add a generic algorithm for seeing if an entire file reads as
zeroes.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-ID: <20250509204341.3553601-16-eblake@redhat.com>
25 files changed:
block/blkdebug.c
block/copy-before-write.c
block/coroutines.h
block/file-posix.c
block/gluster.c
block/io.c
block/iscsi.c
block/nbd.c
block/null.c
block/parallels.c
block/qcow.c
block/qcow2.c
block/qed.c
block/quorum.c
block/raw-format.c
block/rbd.c
block/snapshot-access.c
block/vdi.c
block/vmdk.c
block/vpc.c
block/vvfat.c
include/block/block-common.h
include/block/block_int-common.h
include/block/block_int-io.h
tests/unit/test-block-iothread.c