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