From: Kevin Wolf <kwolf@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Cc: fam@euphon.net, qemu-block@nongnu.org, qemu-devel@nongnu.org,
mreitz@redhat.com, stefanha@redhat.com, den@openvz.org
Subject: Re: [PATCH 1/4] block/io: fix bdrv_co_block_status_above
Date: Mon, 25 Nov 2019 17:00:37 +0100 [thread overview]
Message-ID: <20191125160037.GD4638@linux.fritz.box> (raw)
In-Reply-To: <20191116163410.12129-2-vsementsov@virtuozzo.com>
Am 16.11.2019 um 17:34 hat Vladimir Sementsov-Ogievskiy geschrieben:
> bdrv_co_block_status_above has several problems with handling short
> backing files:
>
> 1. With want_zeros=true, it may return ret with BDRV_BLOCK_ZERO but
> without BDRV_BLOCK_ALLOCATED flag, when actually short backing file
> which produces these after-EOF zeros is inside requested backing
> sequesnce.
s/sequesnce/sequence/
>
> 2. With want_zeros=false, it will just stop inside requested region, if
> we have unallocated region in top node when underlying backing is
> short.
I honestly don't understand this one. Can you rephrase/explain in more
detail what you mean by "stop inside [the] requested region"?
> Fix these things, making logic about short backing files clearer.
>
> Note that 154 output changed, because now bdrv_block_status_above don't
> merge unallocated zeros with zeros after EOF (which are actually
> "allocated" in POV of read from backing-chain top) and is_zero() just
> don't understand that the whole head or tail is zero. We may update
> is_zero to call bdrv_block_status_above several times, or add flag to
> bdrv_block_status_above that we are not interested in ALLOCATED flag,
> so ranges with different ALLOCATED status may be merged, but actually,
> it seems that we'd better don't care about this corner case.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
> block/io.c | 41 ++++++++++++++++++++++++++++----------
> tests/qemu-iotests/154.out | 4 ++--
> 2 files changed, 32 insertions(+), 13 deletions(-)
>
> diff --git a/block/io.c b/block/io.c
> index f75777f5ea..4d7fa99bd2 100644
> --- a/block/io.c
> +++ b/block/io.c
> @@ -2434,25 +2434,44 @@ static int coroutine_fn bdrv_co_block_status_above(BlockDriverState *bs,
> ret = bdrv_co_block_status(p, want_zero, offset, bytes, pnum, map,
> file);
> if (ret < 0) {
> - break;
> + return ret;
> }
> - if (ret & BDRV_BLOCK_ZERO && ret & BDRV_BLOCK_EOF && !first) {
> + if (*pnum == 0) {
> + if (first) {
> + return ret;
> + }
> +
> /*
> - * Reading beyond the end of the file continues to read
> - * zeroes, but we can only widen the result to the
> - * unallocated length we learned from an earlier
> - * iteration.
> + * Reads from bs for selected region will return zeroes, produced
> + * because current level is short. We should consider it as
> + * allocated.
"the selected region"
"the current level"
> + * TODO: Should we report p as file here?
I think that would make sense.
> */
> + assert(ret & BDRV_BLOCK_EOF);
Can this assertion be moved above the if (first)?
> *pnum = bytes;
> + return BDRV_BLOCK_ZERO | BDRV_BLOCK_ALLOCATED;
> }
> - if (ret & (BDRV_BLOCK_ZERO | BDRV_BLOCK_DATA)) {
> - break;
> + if (ret & BDRV_BLOCK_ALLOCATED) {
> + /* We've found the node and the status, we must return. */
> +
> + if (ret & BDRV_BLOCK_ZERO && ret & BDRV_BLOCK_EOF && !first) {
> + /*
> + * This level also responsible for reads after EOF inside
> + * unallocated region in previous level.
"is also responsible"
"the unallocated region in the previous level"
> + */
> + *pnum = bytes;
> + }
> +
> + return ret;
> }
> - /* [offset, pnum] unallocated on this layer, which could be only
> - * the first part of [offset, bytes]. */
Any reason for deleting this comment? I think it's still valid.
> - bytes = MIN(bytes, *pnum);
> +
> + /* Proceed to backing */
> + assert(*pnum <= bytes);
> + bytes = *pnum;
> first = false;
> }
> +
> return ret;
> }
Kevin
next prev parent reply other threads:[~2019-11-25 16:03 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-16 16:34 [PATCH 0/4] fix & merge block_status_above and is_allocated_above Vladimir Sementsov-Ogievskiy
2019-11-16 16:34 ` [PATCH 1/4] block/io: fix bdrv_co_block_status_above Vladimir Sementsov-Ogievskiy
2019-11-25 16:00 ` Kevin Wolf [this message]
2019-11-26 7:26 ` Vladimir Sementsov-Ogievskiy
2019-11-26 14:20 ` Kevin Wolf
2019-11-16 16:34 ` [PATCH 2/4] block/io: bdrv_common_block_status_above: support include_base Vladimir Sementsov-Ogievskiy
2019-11-25 16:19 ` Kevin Wolf
2019-11-16 16:34 ` [PATCH 3/4] block/io: bdrv_common_block_status_above: support bs == base Vladimir Sementsov-Ogievskiy
2019-11-25 16:23 ` Kevin Wolf
2019-11-16 16:34 ` [PATCH 4/4] block/io: fix bdrv_is_allocated_above Vladimir Sementsov-Ogievskiy
2019-11-19 10:22 ` [PATCH 0/4] fix & merge block_status_above and is_allocated_above Max Reitz
2019-11-19 12:02 ` Denis V. Lunev
2019-11-19 12:12 ` Vladimir Sementsov-Ogievskiy
2019-11-19 12:20 ` Max Reitz
2019-11-19 12:30 ` Vladimir Sementsov-Ogievskiy
2019-11-19 13:28 ` Kevin Wolf
2019-11-19 12:05 ` Kevin Wolf
2019-11-19 12:17 ` Vladimir Sementsov-Ogievskiy
2019-11-19 12:32 ` Vladimir Sementsov-Ogievskiy
2019-11-19 12:34 ` Vladimir Sementsov-Ogievskiy
2019-11-19 12:49 ` Vladimir Sementsov-Ogievskiy
2019-11-19 14:21 ` Kevin Wolf
2019-11-19 14:54 ` Kevin Wolf
2019-11-19 16:58 ` Stefan Hajnoczi
2019-11-19 17:11 ` Vladimir Sementsov-Ogievskiy
2019-11-20 10:20 ` Vladimir Sementsov-Ogievskiy
2019-11-20 11:44 ` Kevin Wolf
2019-11-20 12:04 ` Vladimir Sementsov-Ogievskiy
2019-11-20 13:30 ` Kevin Wolf
2019-11-20 13:51 ` Vladimir Sementsov-Ogievskiy
2019-11-20 13:37 ` Vladimir Sementsov-Ogievskiy
2019-11-20 16:24 ` [PATCH 5/4] iotests: add commit top->base cases to 274 Vladimir Sementsov-Ogievskiy
2019-11-25 10:08 ` [PATCH 0/4] fix & merge block_status_above and is_allocated_above Vladimir Sementsov-Ogievskiy
2019-11-25 15:46 ` Kevin Wolf
2019-11-26 7:27 ` Vladimir Sementsov-Ogievskiy
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=20191125160037.GD4638@linux.fritz.box \
--to=kwolf@redhat.com \
--cc=den@openvz.org \
--cc=fam@euphon.net \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=vsementsov@virtuozzo.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).