nbd/server: Fix blockstatus trace
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>
This commit is contained in:
parent
2c57310627
commit
2178a569be
@ -1880,17 +1880,12 @@ static int blockstatus_to_extents(BlockDriverState *bs, uint64_t offset,
|
|||||||
|
|
||||||
flags = (ret & BDRV_BLOCK_ALLOCATED ? 0 : NBD_STATE_HOLE) |
|
flags = (ret & BDRV_BLOCK_ALLOCATED ? 0 : NBD_STATE_HOLE) |
|
||||||
(ret & BDRV_BLOCK_ZERO ? NBD_STATE_ZERO : 0);
|
(ret & BDRV_BLOCK_ZERO ? NBD_STATE_ZERO : 0);
|
||||||
offset += num;
|
|
||||||
remaining_bytes -= num;
|
|
||||||
|
|
||||||
if (first_extent) {
|
if (first_extent) {
|
||||||
extent->flags = flags;
|
extent->flags = flags;
|
||||||
extent->length = num;
|
extent->length = num;
|
||||||
first_extent = false;
|
first_extent = false;
|
||||||
continue;
|
} else if (flags == extent->flags) {
|
||||||
}
|
|
||||||
|
|
||||||
if (flags == extent->flags) {
|
|
||||||
/* extend current extent */
|
/* extend current extent */
|
||||||
extent->length += num;
|
extent->length += num;
|
||||||
} else {
|
} else {
|
||||||
@ -1903,6 +1898,8 @@ static int blockstatus_to_extents(BlockDriverState *bs, uint64_t offset,
|
|||||||
extent->flags = flags;
|
extent->flags = flags;
|
||||||
extent->length = num;
|
extent->length = num;
|
||||||
}
|
}
|
||||||
|
offset += num;
|
||||||
|
remaining_bytes -= num;
|
||||||
}
|
}
|
||||||
|
|
||||||
extents_end = extent + 1;
|
extents_end = extent + 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user