From: Fam Zheng <famz@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, kwolf@redhat.com,
stefanha@redhat.com, Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v3 19/22] block: Split bdrv_merge_limits() from bdrv_refresh_limits()
Date: Fri, 24 Jun 2016 14:48:31 +0800 [thread overview]
Message-ID: <20160624064831.GE13266@ad.usersys.redhat.com> (raw)
In-Reply-To: <1466721446-27737-20-git-send-email-eblake@redhat.com>
On Thu, 06/23 16:37, Eric Blake wrote:
> During bdrv_merge_limits(), we were computing initial limits
> based on another BDS in two places. At first glance, the two
> computations are not identical (one is doing straight copying,
> the other is doing merging towards or away from zero) - but
> when you realize that the first round is starting with all-0
> memory, all of the merging happens to work. Factoring out the
> merging makes it easier to track how two BDS limits are merged,
> in case we have future reasons to merge in even more limits.
>
> Signed-off-by: Eric Blake <eblake@redhat.com>
>
> ---
> v3: Split raw block driver changes to its own patch, make new
> function static
> v2: new patch
> ---
> block/io.c | 31 +++++++++++++------------------
> 1 file changed, 13 insertions(+), 18 deletions(-)
>
> diff --git a/block/io.c b/block/io.c
> index 0f15d05..69dbbd3 100644
> --- a/block/io.c
> +++ b/block/io.c
> @@ -67,6 +67,17 @@ static void bdrv_parent_drained_end(BlockDriverState *bs)
> }
> }
>
> +static void bdrv_merge_limits(BlockLimits *dst, const BlockLimits *src)
> +{
> + dst->opt_transfer = MAX(dst->opt_transfer, src->opt_transfer);
> + dst->max_transfer = MIN_NON_ZERO(dst->max_transfer, src->max_transfer);
> + dst->opt_mem_alignment = MAX(dst->opt_mem_alignment,
> + src->opt_mem_alignment);
> + dst->min_mem_alignment = MAX(dst->min_mem_alignment,
> + src->min_mem_alignment);
> + dst->max_iov = MIN_NON_ZERO(dst->max_iov, src->max_iov);
> +}
> +
> void bdrv_refresh_limits(BlockDriverState *bs, Error **errp)
> {
> BlockDriver *drv = bs->drv;
> @@ -88,11 +99,7 @@ void bdrv_refresh_limits(BlockDriverState *bs, Error **errp)
> error_propagate(errp, local_err);
> return;
> }
> - bs->bl.opt_transfer = bs->file->bs->bl.opt_transfer;
> - bs->bl.max_transfer = bs->file->bs->bl.max_transfer;
> - bs->bl.min_mem_alignment = bs->file->bs->bl.min_mem_alignment;
> - bs->bl.opt_mem_alignment = bs->file->bs->bl.opt_mem_alignment;
> - bs->bl.max_iov = bs->file->bs->bl.max_iov;
> + bdrv_merge_limits(&bs->bl, &bs->file->bs->bl);
> } else {
> bs->bl.min_mem_alignment = 512;
> bs->bl.opt_mem_alignment = getpagesize();
> @@ -107,19 +114,7 @@ void bdrv_refresh_limits(BlockDriverState *bs, Error **errp)
> error_propagate(errp, local_err);
> return;
> }
> - bs->bl.opt_transfer = MAX(bs->bl.opt_transfer,
> - bs->backing->bs->bl.opt_transfer);
> - bs->bl.max_transfer = MIN_NON_ZERO(bs->bl.max_transfer,
> - bs->backing->bs->bl.max_transfer);
> - bs->bl.opt_mem_alignment =
> - MAX(bs->bl.opt_mem_alignment,
> - bs->backing->bs->bl.opt_mem_alignment);
> - bs->bl.min_mem_alignment =
> - MAX(bs->bl.min_mem_alignment,
> - bs->backing->bs->bl.min_mem_alignment);
> - bs->bl.max_iov =
> - MIN(bs->bl.max_iov,
> - bs->backing->bs->bl.max_iov);
> + bdrv_merge_limits(&bs->bl, &bs->backing->bs->bl);
> }
>
> /* Then let the driver override it */
> --
> 2.5.5
>
Reviewed-by: Fam Zheng <famz@redhat.com>
next prev parent reply other threads:[~2016-06-24 6:48 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-23 22:37 [Qemu-devel] [PATCH v3 00/22] Byte-based block limits Eric Blake
2016-06-23 22:37 ` [Qemu-devel] [PATCH v3 01/22] block: Tighter assertions on bdrv_aligned_pwritev() Eric Blake
2016-06-23 22:37 ` [Qemu-devel] [PATCH v3 02/22] block: Document supported flags during bdrv_aligned_preadv() Eric Blake
2016-06-23 22:37 ` [Qemu-devel] [PATCH v3 03/22] block: Fix harmless off-by-one in bdrv_aligned_preadv() Eric Blake
2016-06-23 22:37 ` [Qemu-devel] [PATCH v3 04/22] nbd: Allow larger requests Eric Blake
2016-06-23 22:37 ` [Qemu-devel] [PATCH v3 05/22] nbd: Advertise realistic limits to block layer Eric Blake
2016-06-23 22:37 ` [Qemu-devel] [PATCH v3 06/22] iscsi: " Eric Blake
2016-06-23 22:37 ` [Qemu-devel] [PATCH v3 07/22] scsi: Advertise limits by blocksize, not 512 Eric Blake
2016-06-24 5:22 ` Fam Zheng
2016-06-23 22:37 ` [Qemu-devel] [PATCH v3 08/22] block: Give nonzero result to blk_get_max_transfer_length() Eric Blake
2016-06-24 5:24 ` Fam Zheng
2016-06-23 22:37 ` [Qemu-devel] [PATCH v3 09/22] blkdebug: Set request_alignment during .bdrv_refresh_limits() Eric Blake
2016-06-24 5:42 ` Fam Zheng
2016-06-23 22:37 ` [Qemu-devel] [PATCH v3 10/22] iscsi: " Eric Blake
2016-06-23 22:37 ` [Qemu-devel] [PATCH v3 11/22] qcow2: " Eric Blake
2016-06-23 22:37 ` [Qemu-devel] [PATCH v3 12/22] raw-win32: " Eric Blake
2016-06-23 22:37 ` [Qemu-devel] [PATCH v3 13/22] block: " Eric Blake
2016-06-23 22:37 ` [Qemu-devel] [PATCH v3 14/22] block: Set default request_alignment during bdrv_refresh_limits() Eric Blake
2016-06-23 22:37 ` [Qemu-devel] [PATCH v3 15/22] block: Switch transfer length bounds to byte-based Eric Blake
2016-06-24 6:06 ` Fam Zheng
2016-06-23 22:37 ` [Qemu-devel] [PATCH v3 16/22] block: Wording tweaks to write zeroes limits Eric Blake
2016-06-24 6:12 ` Fam Zheng
2016-06-24 14:10 ` Eric Blake
2016-06-23 22:37 ` [Qemu-devel] [PATCH v3 17/22] block: Switch discard length bounds to byte-based Eric Blake
2016-06-24 6:43 ` Fam Zheng
2016-06-24 14:15 ` Eric Blake
2016-06-24 14:29 ` Kevin Wolf
2016-06-23 22:37 ` [Qemu-devel] [PATCH v3 18/22] block: Drop raw_refresh_limits() Eric Blake
2016-06-24 6:44 ` Fam Zheng
2016-06-23 22:37 ` [Qemu-devel] [PATCH v3 19/22] block: Split bdrv_merge_limits() from bdrv_refresh_limits() Eric Blake
2016-06-24 6:48 ` Fam Zheng [this message]
2016-06-23 22:37 ` [Qemu-devel] [PATCH v3 20/22] block: Move request_alignment into BlockLimit Eric Blake
2016-06-24 7:07 ` Fam Zheng
2016-06-24 13:45 ` Kevin Wolf
2016-06-24 14:17 ` Eric Blake
2016-06-23 22:37 ` [Qemu-devel] [PATCH v3 21/22] block: Fix error message style Eric Blake
2016-06-24 7:09 ` Fam Zheng
2016-06-23 22:37 ` [Qemu-devel] [PATCH v3 22/22] block: Use bool as appropriate for BDS members Eric Blake
2016-06-24 7:12 ` Fam Zheng
2016-06-24 14:32 ` [Qemu-devel] [PATCH v3 00/22] Byte-based block limits Kevin Wolf
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=20160624064831.GE13266@ad.usersys.redhat.com \
--to=famz@redhat.com \
--cc=eblake@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).