From: Fam Zheng <famz@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-devel@nongnu.org, kwolf@redhat.com, jsnow@redhat.com,
qemu-block@nongnu.org, el13635@mail.ntua.gr,
Stefan Hajnoczi <stefanha@redhat.com>,
Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [RFC PATCH v2 16/15] block: Add .bdrv_co_block_status() callback
Date: Tue, 4 Jul 2017 19:30:10 +0800 [thread overview]
Message-ID: <20170704113010.GA16860@lemon.lan> (raw)
In-Reply-To: <20170703222015.31507-1-eblake@redhat.com>
On Mon, 07/03 17:20, Eric Blake wrote:
> We are gradually moving away from sector-based interfaces, towards
> byte-based. Now that the block layer exposes byte-based allocation,
> it's time to tackle the drivers. Add a new callback that operates
> on as small as byte boundaries. Subsequent patches will then update
> individual drivers, then finally remove .bdrv_co_get_block_status().
> The old code now uses a goto in order to minimize churn at that later
> removal.
>
> The new code also passes through the 'allocation' hint, which will
> allow subsequent patches to further optimize callers that only care
> about how much of the image is allocated, rather than which offsets
> the allocation actually maps to.
>
> Note that most drivers give sector-aligned answers, except at
> end-of-file, even when request_alignment is smaller than a sector.
> However, bdrv_getlength() is sector-aligned (even though it gives a
> byte answer), often by exceeding the actual file size. If we were to
> give back strict results, at least file-posix.c would report a
> transition from DATA to HOLE at the end of a file even in the middle
> of a sector, which can throw off callers; so we intentionally lie and
> state that any partial sector at the end of a file has the same
> status for the entire sector.
>
> Signed-off-by: Eric Blake <eblake@redhat.com>
>
> ---
> v2: improve alignment handling, add additional 'allocation' argument
> for future optimization potential, ensure all iotests still pass
>
> Sending as an RFC as part of my third series; this patch is technically
> the start of my fourth series, but given the rebase churn I've had
> elsewhere, it can't hurt to get the interface looked at in case it
> needs tweaking
> ---
> include/block/block_int.h | 9 ++++++++-
> block/io.c | 27 ++++++++++++++++++++++++---
> 2 files changed, 32 insertions(+), 4 deletions(-)
>
> diff --git a/include/block/block_int.h b/include/block/block_int.h
> index 5f6ba5d..45ff534 100644
> --- a/include/block/block_int.h
> +++ b/include/block/block_int.h
> @@ -172,13 +172,20 @@ struct BlockDriver {
> * bdrv_is_allocated[_above]. The driver should answer only
> * according to the current layer, and should not set
> * BDRV_BLOCK_ALLOCATED, but may set BDRV_BLOCK_RAW. See block.h
> - * for the meaning of _DATA, _ZERO, and _OFFSET_VALID. The block
> + * for the meaning of _DATA, _ZERO, and _OFFSET_VALID. As a hint,
> + * the flag allocation is true if the caller cares more about
> + * learning how much of the image is allocated, without regards to
> + * a breakdown by offset (a driver may either ignore the hint, or
> + * avoid _OFFSET_VALID to provide a larger *pnum). The block
> * layer guarantees input aligned to request_alignment, as well as
> * non-NULL pnum and file.
> */
> int64_t coroutine_fn (*bdrv_co_get_block_status)(BlockDriverState *bs,
> int64_t sector_num, int nb_sectors, int *pnum,
> BlockDriverState **file);
> + int64_t coroutine_fn (*bdrv_co_block_status)(BlockDriverState *bd,
> + bool allocation, int64_t offset, int64_t bytes, int64_t *pnum,
> + BlockDriverState **file);
Apart from my earlier question regarding the naming of "allocation", looks fine.
I haven't reviewed the implementation though.
Fam
prev parent reply other threads:[~2017-07-04 11:30 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-03 22:14 [Qemu-devel] [PATCH v2 00/15] make bdrv_get_block_status byte-based Eric Blake
2017-07-03 22:14 ` [Qemu-devel] [PATCH v2 01/15] block: add default implementations for bdrv_co_get_block_status() Eric Blake
2017-07-04 7:33 ` Fam Zheng
2017-07-05 22:00 ` Eric Blake
2017-07-03 22:14 ` [Qemu-devel] [PATCH v2 02/15] block: Allow NULL file for bdrv_get_block_status() Eric Blake
2017-07-04 7:33 ` Fam Zheng
2017-07-03 22:14 ` [Qemu-devel] [PATCH v2 03/15] block: Add flag to avoid wasted work in bdrv_is_allocated() Eric Blake
2017-07-04 7:06 ` Fam Zheng
2017-07-05 11:56 ` Eric Blake
2017-07-05 12:07 ` Fam Zheng
2017-07-05 14:01 ` Eric Blake
2017-07-05 14:21 ` Fam Zheng
2017-07-06 2:35 ` Eric Blake
2017-07-03 22:14 ` [Qemu-devel] [PATCH v2 04/15] block: Make bdrv_round_to_clusters() signature more useful Eric Blake
2017-07-04 7:34 ` Fam Zheng
2017-07-03 22:14 ` [Qemu-devel] [PATCH v2 05/15] qcow2: Switch is_zero_sectors() to byte-based Eric Blake
2017-07-04 7:34 ` Fam Zheng
2017-07-03 22:14 ` [Qemu-devel] [PATCH v2 06/15] block: Switch bdrv_make_zero() " Eric Blake
2017-07-04 7:35 ` Fam Zheng
2017-07-03 22:14 ` [Qemu-devel] [PATCH v2 07/15] qemu-img: Switch get_block_status() " Eric Blake
2017-07-04 7:40 ` Fam Zheng
2017-07-03 22:14 ` [Qemu-devel] [PATCH v2 08/15] block: Convert bdrv_get_block_status() to bytes Eric Blake
2017-07-04 8:40 ` Fam Zheng
2017-07-03 22:14 ` [Qemu-devel] [PATCH v2 09/15] block: Switch bdrv_co_get_block_status() to byte-based Eric Blake
2017-07-04 8:59 ` Fam Zheng
2017-07-03 22:14 ` [Qemu-devel] [PATCH v2 10/15] block: Switch BdrvCoGetBlockStatusData " Eric Blake
2017-07-04 9:00 ` Fam Zheng
2017-07-03 22:14 ` [Qemu-devel] [PATCH v2 11/15] block: Switch bdrv_common_block_status_above() " Eric Blake
2017-07-04 9:02 ` Fam Zheng
2017-07-03 22:14 ` [Qemu-devel] [PATCH v2 12/15] block: Switch bdrv_co_get_block_status_above() " Eric Blake
2017-07-04 9:28 ` Fam Zheng
2017-07-03 22:14 ` [Qemu-devel] [PATCH v2 13/15] block: Convert bdrv_get_block_status_above() to bytes Eric Blake
2017-07-04 9:32 ` Fam Zheng
2017-07-03 22:14 ` [Qemu-devel] [PATCH v2 14/15] block: Align block status requests Eric Blake
2017-07-04 9:44 ` Fam Zheng
2017-07-05 12:01 ` Eric Blake
2017-07-05 12:12 ` Fam Zheng
2017-07-03 22:14 ` [Qemu-devel] [PATCH v2 15/15] qemu-io: Relax 'alloc' now that block-status doesn't assert Eric Blake
2017-07-04 9:50 ` Fam Zheng
2017-07-03 22:20 ` [Qemu-devel] [RFC PATCH v2 16/15] block: Add .bdrv_co_block_status() callback Eric Blake
2017-07-04 11:30 ` Fam Zheng [this message]
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=20170704113010.GA16860@lemon.lan \
--to=famz@redhat.com \
--cc=eblake@redhat.com \
--cc=el13635@mail.ntua.gr \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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 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).