|
|
383d26 |
From 9e909e2a2640b08e7bf10232321a1b1dc81df69c Mon Sep 17 00:00:00 2001
|
|
|
383d26 |
From: John Snow <jsnow@redhat.com>
|
|
|
383d26 |
Date: Fri, 22 Mar 2019 03:22:16 +0100
|
|
|
383d26 |
Subject: [PATCH 049/163] nbd/client: Relax handling of large
|
|
|
383d26 |
NBD_CMD_BLOCK_STATUS reply
|
|
|
383d26 |
|
|
|
383d26 |
RH-Author: John Snow <jsnow@redhat.com>
|
|
|
383d26 |
Message-id: <20190322032241.8111-4-jsnow@redhat.com>
|
|
|
383d26 |
Patchwork-id: 85090
|
|
|
383d26 |
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 03/28] nbd/client: Relax handling of large NBD_CMD_BLOCK_STATUS reply
|
|
|
383d26 |
Bugzilla: 1691563
|
|
|
383d26 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
383d26 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
383d26 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
383d26 |
|
|
|
383d26 |
From: Eric Blake <eblake@redhat.com>
|
|
|
383d26 |
|
|
|
383d26 |
The NBD spec is proposing a relaxation of NBD_CMD_BLOCK_STATUS
|
|
|
383d26 |
where a server may have the final extent per context give a
|
|
|
383d26 |
length beyond the original request, if it can easily prove that
|
|
|
383d26 |
subsequent bytes have the same status, on the grounds that a
|
|
|
383d26 |
client can take advantage of this information for fewer block
|
|
|
383d26 |
status requests. Since qemu 2.12 as a client always sends
|
|
|
383d26 |
NBD_CMD_FLAG_REQ_ONE, and rejects a server that sends extra
|
|
|
383d26 |
length, the upstream NBD spec will probably limit this behavior
|
|
|
383d26 |
to clients that don't request REQ_ONE semantics; but it doesn't
|
|
|
383d26 |
hurt to relax qemu to always be permissive of this server
|
|
|
383d26 |
behavior, even if it continues to use REQ_ONE.
|
|
|
383d26 |
|
|
|
383d26 |
CC: qemu-stable@nongnu.org
|
|
|
383d26 |
Signed-off-by: Eric Blake <eblake@redhat.com>
|
|
|
383d26 |
Message-Id: <20180503222626.1303410-1-eblake@redhat.com>
|
|
|
383d26 |
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
|
|
|
383d26 |
(cherry picked from commit acfd8f7a5f92e703d2d046cbe3d510008a697194)
|
|
|
383d26 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
383d26 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
383d26 |
---
|
|
|
383d26 |
block/nbd-client.c | 10 +++++++---
|
|
|
383d26 |
1 file changed, 7 insertions(+), 3 deletions(-)
|
|
|
383d26 |
|
|
|
383d26 |
diff --git a/block/nbd-client.c b/block/nbd-client.c
|
|
|
383d26 |
index 80d3625..76e9ca3 100644
|
|
|
383d26 |
--- a/block/nbd-client.c
|
|
|
383d26 |
+++ b/block/nbd-client.c
|
|
|
383d26 |
@@ -259,14 +259,18 @@ static int nbd_parse_blockstatus_payload(NBDClientSession *client,
|
|
|
383d26 |
|
|
|
383d26 |
if (extent->length == 0 ||
|
|
|
383d26 |
(client->info.min_block && !QEMU_IS_ALIGNED(extent->length,
|
|
|
383d26 |
- client->info.min_block)) ||
|
|
|
383d26 |
- extent->length > orig_length)
|
|
|
383d26 |
- {
|
|
|
383d26 |
+ client->info.min_block))) {
|
|
|
383d26 |
error_setg(errp, "Protocol error: server sent status chunk with "
|
|
|
383d26 |
"invalid length");
|
|
|
383d26 |
return -EINVAL;
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
+ /* The server is allowed to send us extra information on the final
|
|
|
383d26 |
+ * extent; just clamp it to the length we requested. */
|
|
|
383d26 |
+ if (extent->length > orig_length) {
|
|
|
383d26 |
+ extent->length = orig_length;
|
|
|
383d26 |
+ }
|
|
|
383d26 |
+
|
|
|
383d26 |
return 0;
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
--
|
|
|
383d26 |
1.8.3.1
|
|
|
383d26 |
|