From: Stefan Hajnoczi <stefanha@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org,
vsementsov@yandex-team.ru, Kevin Wolf <kwolf@redhat.com>,
Hanna Reitz <hreitz@redhat.com>, John Snow <jsnow@redhat.com>,
Fam Zheng <fam@euphon.net>,
Ronnie Sahlberg <ronniesahlberg@gmail.com>,
Paolo Bonzini <pbonzini@redhat.com>, Peter Lieven <pl@dlhnet.de>,
"Denis V. Lunev" <den@openvz.org>,
Alberto Garcia <berto@igalia.com>,
Ilya Dryomov <idryomov@gmail.com>, Stefan Weil <sw@weilnetz.de>,
"open list:GLUSTER" <integration@gluster.org>
Subject: Re: [PATCH v2 01/11] block: Expand block status mode from bool to enum
Date: Thu, 17 Apr 2025 16:17:55 -0400 [thread overview]
Message-ID: <20250417201755.GA85491@fedora> (raw)
In-Reply-To: <20250417184133.105746-14-eblake@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 5411 bytes --]
On Thu, Apr 17, 2025 at 01:39:06PM -0500, Eric Blake wrote:
> This patch is purely mechanical, changing bool want_zero into a new
> enum BlockStatusMode. As of this patch, all implementations are
> unchanged (the old want_zero==true is now mode==BDRV_BSTAT_PRECISE),
> but the callers in io.c are set up so that future patches will be able
> to differente between whether the caller cares more about allocation
differentiate
> or about reads-as-zero, for driver implementations that will actually
> want to behave differently for those 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). The next
> patches will add a generic algorithm for seeing if an entire file
> reads as zeroes, as well as tweak the file-posix driver to react to
> the new hints.
>
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
> block/coroutines.h | 4 +--
> include/block/block-common.h | 26 ++++++++++++++++
> include/block/block_int-common.h | 25 +++++++++-------
> include/block/block_int-io.h | 4 +--
> block/io.c | 51 ++++++++++++++++----------------
> block/blkdebug.c | 6 ++--
> block/copy-before-write.c | 4 +--
> block/file-posix.c | 4 +--
> block/gluster.c | 4 +--
> block/iscsi.c | 6 ++--
> block/nbd.c | 4 +--
> block/null.c | 6 ++--
> block/parallels.c | 6 ++--
> block/qcow.c | 2 +-
> block/qcow2.c | 6 ++--
> block/qed.c | 6 ++--
> block/quorum.c | 4 +--
> block/raw-format.c | 4 +--
> block/rbd.c | 6 ++--
> block/snapshot-access.c | 4 +--
> block/vdi.c | 4 +--
> block/vmdk.c | 2 +-
> block/vpc.c | 2 +-
> block/vvfat.c | 6 ++--
> tests/unit/test-block-iothread.c | 2 +-
> 25 files changed, 114 insertions(+), 84 deletions(-)
>
> diff --git a/block/coroutines.h b/block/coroutines.h
> index 79e5efbf752..c8323aa67e6 100644
> --- a/block/coroutines.h
> +++ b/block/coroutines.h
> @@ -47,7 +47,7 @@ int coroutine_fn GRAPH_RDLOCK
> bdrv_co_common_block_status_above(BlockDriverState *bs,
> BlockDriverState *base,
> bool include_base,
> - bool want_zero,
> + enum BlockStatusMode mode,
> int64_t offset,
> int64_t bytes,
> int64_t *pnum,
> @@ -78,7 +78,7 @@ int co_wrapper_mixed_bdrv_rdlock
> bdrv_common_block_status_above(BlockDriverState *bs,
> BlockDriverState *base,
> bool include_base,
> - bool want_zero,
> + enum BlockStatusMode mode,
> int64_t offset,
> int64_t bytes,
> int64_t *pnum,
> diff --git a/include/block/block-common.h b/include/block/block-common.h
> index 0b831ef87b1..619e75b9c8d 100644
> --- a/include/block/block-common.h
> +++ b/include/block/block-common.h
> @@ -508,6 +508,32 @@ enum BdrvChildRoleBits {
> | BDRV_CHILD_PRIMARY,
> };
>
> +/* Modes for block status calls */
> +enum BlockStatusMode {
> + /*
> + * Status should be as accurate as possible: _OFFSET_VALID
> + * and_OFFSET_ZERO should each be set where efficiently possible,
"and _OFFSET_ZERO"
> + * extents may be smaller, and iteration through the entire block
> + * device may take more calls.
> + */
> + BDRV_BSTAT_PRECISE,
> +
> + /*
> + * The caller is primarily concerned about overall allocation:
> + * favor larger *pnum, perhaps by coalescing extents and reporting
> + * _DATA instead of _ZERO, and without needing to read data or
> + * bothering with _OFFSET_VALID.
> + */
> + BDRV_BSTAT_ALLOCATED,
> +
> + /*
> + * The caller is primarily concerned about whether the device
> + * reads as zero: favor a result of _ZERO, even if it requires
> + * reading a few sectors to verify, without needing _OFFSET_VALID.
> + */
> + BDRV_BSTAT_ZERO,
> +};
I have trouble understanding what the exact semantics are of these modes
are. Would it be possible to pass flags to block status calls that can
be ORed together instead: WANT_OFFSET_VALID, WANT_ZERO, etc? The flags
would be orthogonal and easier to understand than modes that seem to
combine multiple flag behaviors.
Stefan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2025-04-17 20:19 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-17 18:39 [PATCH v2 00/11] Make blockdev-mirror dest sparse in more cases Eric Blake
2025-04-17 18:39 ` [PATCH v2 01/11] block: Expand block status mode from bool to enum Eric Blake
2025-04-17 20:17 ` Stefan Hajnoczi [this message]
2025-04-18 19:02 ` Eric Blake
2025-04-18 21:55 ` Eric Blake
2025-04-17 18:39 ` [PATCH v2 02/11] file-posix: Handle zero block status hint better Eric Blake
2025-04-17 20:58 ` Stefan Hajnoczi
2025-04-17 18:39 ` [PATCH v2 03/11] block: Let bdrv_co_is_zero_fast consolidate adjacent extents Eric Blake
2025-04-17 20:21 ` Stefan Hajnoczi
2025-04-17 18:39 ` [PATCH v2 04/11] block: Add new bdrv_co_is_all_zeroes() function Eric Blake
2025-04-17 20:35 ` Stefan Hajnoczi
2025-04-18 19:07 ` Eric Blake
2025-04-17 18:39 ` [PATCH v2 05/11] iotests: Improve iotest 194 to mirror data Eric Blake
2025-04-17 20:39 ` Stefan Hajnoczi
2025-04-17 18:39 ` [PATCH v2 06/11] mirror: Minor refactoring Eric Blake
2025-04-17 20:42 ` Stefan Hajnoczi
2025-04-17 18:39 ` [PATCH v2 07/11] mirror: Skip pre-zeroing destination if it is already zero Eric Blake
2025-04-17 20:46 ` Stefan Hajnoczi
2025-04-24 17:10 ` Eric Blake
2025-04-17 18:39 ` [PATCH v2 08/11] mirror: Skip writing zeroes when target " Eric Blake
2025-04-17 20:54 ` Stefan Hajnoczi
2025-04-23 16:42 ` Sunny Zhu
2025-04-23 19:12 ` Eric Blake
2025-04-17 18:39 ` [PATCH v2 09/11] iotests/common.rc: add disk_usage function Eric Blake
2025-04-17 20:54 ` Stefan Hajnoczi
2025-04-17 18:39 ` [PATCH v2 10/11] tests: Add iotest mirror-sparse for recent patches Eric Blake
2025-04-17 20:55 ` Stefan Hajnoczi
2025-04-17 18:39 ` [PATCH v2 11/11] mirror: Allow QMP override to declare target already zero Eric Blake
2025-04-17 20:57 ` Stefan Hajnoczi
2025-04-18 4:47 ` Markus Armbruster
2025-04-17 20:59 ` [PATCH v2 00/11] Make blockdev-mirror dest sparse in more cases Stefan Hajnoczi
2025-04-18 21:52 ` [PATCH v2.5 01/11] block: Expand block status mode from bool to flags Eric Blake
2025-04-18 21:52 ` [PATCH v2.5 02/11] file-posix, gluster: Handle zero block status hint better Eric Blake
2025-04-22 14:43 ` Stefan Hajnoczi
2025-04-22 14:43 ` [PATCH v2.5 01/11] block: Expand block status mode from bool to flags Stefan Hajnoczi
2025-04-24 18:08 ` Eric Blake
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=20250417201755.GA85491@fedora \
--to=stefanha@redhat.com \
--cc=berto@igalia.com \
--cc=den@openvz.org \
--cc=eblake@redhat.com \
--cc=fam@euphon.net \
--cc=hreitz@redhat.com \
--cc=idryomov@gmail.com \
--cc=integration@gluster.org \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=pl@dlhnet.de \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=ronniesahlberg@gmail.com \
--cc=sw@weilnetz.de \
--cc=vsementsov@yandex-team.ru \
/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.