From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
"open list:Network Block Dev..." <qemu-block@nongnu.org>
Subject: [Qemu-devel] [PULL 1/4] nbd/server: Fix blockstatus trace
Date: Mon, 8 Apr 2019 14:02:30 -0500 [thread overview]
Message-ID: <20190408190233.10321-2-eblake@redhat.com> (raw)
In-Reply-To: <20190408190233.10321-1-eblake@redhat.com>
Don't increment remaining_bytes until we know that we will actually be
including the current block status extent in the reply; otherwise, the
value traced will include a bytes value that is oversized by the
length of the next block status extent which did not get sent because
it instead ended the loop.
Fixes: fb7afc79
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20190403030526.12258-2-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
nbd/server.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/nbd/server.c b/nbd/server.c
index 218a2aa5e65..1b8c8619896 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -1880,17 +1880,12 @@ static int blockstatus_to_extents(BlockDriverState *bs, uint64_t offset,
flags = (ret & BDRV_BLOCK_ALLOCATED ? 0 : NBD_STATE_HOLE) |
(ret & BDRV_BLOCK_ZERO ? NBD_STATE_ZERO : 0);
- offset += num;
- remaining_bytes -= num;
if (first_extent) {
extent->flags = flags;
extent->length = num;
first_extent = false;
- continue;
- }
-
- if (flags == extent->flags) {
+ } else if (flags == extent->flags) {
/* extend current extent */
extent->length += num;
} else {
@@ -1903,6 +1898,8 @@ static int blockstatus_to_extents(BlockDriverState *bs, uint64_t offset,
extent->flags = flags;
extent->length = num;
}
+ offset += num;
+ remaining_bytes -= num;
}
extents_end = extent + 1;
--
2.20.1
next prev parent reply other threads:[~2019-04-08 19:02 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-08 19:02 [Qemu-devel] [PULL 0/4] NBD patches for 4.0-rc3 Eric Blake
2019-04-08 19:02 ` Eric Blake
2019-04-08 19:02 ` Eric Blake [this message]
2019-04-08 19:02 ` [Qemu-devel] [PULL 1/4] nbd/server: Fix blockstatus trace Eric Blake
2019-04-08 19:02 ` [Qemu-devel] [PULL 2/4] nbd/server: Trace client noncompliance on unaligned requests Eric Blake
2019-04-08 19:02 ` Eric Blake
2019-04-08 19:02 ` [Qemu-devel] [PULL 3/4] nbd/server: Don't fail NBD_OPT_INFO for byte-aligned sources Eric Blake
2019-04-08 19:02 ` Eric Blake
2019-04-08 19:02 ` [Qemu-devel] [PULL 4/4] nbd/client: Fix error message for server with unusable sizing Eric Blake
2019-04-08 19:02 ` Eric Blake
2019-04-09 9:02 ` [Qemu-devel] [PULL 0/4] NBD patches for 4.0-rc3 Peter Maydell
2019-04-09 9:02 ` Peter Maydell
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=20190408190233.10321-2-eblake@redhat.com \
--to=eblake@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--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).