[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 5/5] do not apply: Revert "nbd-client: Work around server BLOCK_S
From: |
Eric Blake |
Subject: |
[PATCH 5/5] do not apply: Revert "nbd-client: Work around server BLOCK_STATUS misalignment at EOF" |
Date: |
Thu, 18 Feb 2021 14:15:28 -0600 |
This reverts commit 737d3f524481bb2ef68d3eba1caa636ff143e16a.
This is intended only for testing purposes: if you apply this without
the rest of the series, iotest 241 no longer benefits from the client
side working around server non-compliance.
---
block/nbd.c | 30 ++++--------------------------
1 file changed, 4 insertions(+), 26 deletions(-)
diff --git a/block/nbd.c b/block/nbd.c
index c26dc5a54f52..34c91f68e150 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -937,36 +937,14 @@ static int nbd_parse_blockstatus_payload(BDRVNBDState *s,
extent->length = payload_advance32(&payload);
extent->flags = payload_advance32(&payload);
- if (extent->length == 0) {
+ if (extent->length == 0 ||
+ (s->info.min_block && !QEMU_IS_ALIGNED(extent->length,
+ s->info.min_block))) {
error_setg(errp, "Protocol error: server sent status chunk with "
- "zero length");
+ "invalid length");
return -EINVAL;
}
- /*
- * A server sending unaligned block status is in violation of the
- * protocol, but as qemu-nbd 3.1 is such a server (at least for
- * POSIX files that are not a multiple of 512 bytes, since qemu
- * rounds files up to 512-byte multiples but lseek(SEEK_HOLE)
- * still sees an implicit hole beyond the real EOF), it's nicer to
- * work around the misbehaving server. If the request included
- * more than the final unaligned block, truncate it back to an
- * aligned result; if the request was only the final block, round
- * up to the full block and change the status to fully-allocated
- * (always a safe status, even if it loses information).
- */
- if (s->info.min_block && !QEMU_IS_ALIGNED(extent->length,
- s->info.min_block)) {
- trace_nbd_parse_blockstatus_compliance("extent length is unaligned");
- if (extent->length > s->info.min_block) {
- extent->length = QEMU_ALIGN_DOWN(extent->length,
- s->info.min_block);
- } else {
- extent->length = s->info.min_block;
- extent->flags = 0;
- }
- }
-
/*
* We used NBD_CMD_FLAG_REQ_ONE, so the server should not have
* sent us any more than one extent, nor should it have included
--
2.30.1
[PATCH 3/5] nbd/server: Avoid unaligned read/block_status from backing, Eric Blake, 2021/02/18
[PATCH 4/5] nbd/server: Avoid unaligned dirty-bitmap status, Eric Blake, 2021/02/18
[PATCH 2/5] block: Fix BDRV_BLOCK_RAW status to honor alignment, Eric Blake, 2021/02/18
[PATCH 5/5] do not apply: Revert "nbd-client: Work around server BLOCK_STATUS misalignment at EOF",
Eric Blake <=
Re: [PATCH 0/5] Obey NBD spec regarding block size bounds on reply, no-reply, 2021/02/18