Skip to content

Obey NBD spec regarding block size bounds on reply

Eric Blake qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 9 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5iotests: Update 241 to expose backing layer fragmentationtests/qemu-iotests/241 tests/qemu-iotests/241.out+76 -55 replies
2/5block: Fix BDRV_BLOCK_RAW status to honor alignmentblock/io.c tests/qemu-iotests/221 tests/qemu-iotests/221.out +1 more+161 -63 replies
3/5nbd/server: Avoid unaligned read/block_status from backingblock/coroutines.h block/io.c block/quorum.c +4 more+77 -250 replies
4/5nbd/server: Avoid unaligned dirty-bitmap statusnbd/server.c tests/qemu-iotests/241 tests/qemu-iotests/241.out+29 -80 replies
5/5do not apply: Revert "nbd-client: Work around server BLOCK_STATUS misalignment at EOF"block/nbd.c+4 -260 replies

Reviews trailers per patch

1 of 5 patches has a Reviewed-by or Acked-by.

PatchVladimir Sementsov-Ogievskiy
1/5R-b
2/5
3/5
4/5
5/5

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/5] Obey NBD spec regarding block size bounds on reply

We've had some known long-standing compliance bugs in our NBD server not always honoring a minimum block size in its response to client requests, when dealing with an image with a large block size backed by another image with a smaller block size (for example, an encrypted qcow2 image has a minimum block size of 512, backed by a file whose size is not a multiple of 512). Fragmenting our reply to NBD_CMD_READ or NBD_CMD_BLOCK_STATUS to something smaller than our advertised minimum block size can confuse a client (in fact, qemu 3.2 would abort() on such messages, although we patched the client to be tolerant of non-compliant servers for qemu 4.0). Thankfully, most day-to-day uses of NBD don't run into these cases.

Back in 2019, I did propose a fix for the server[1], but it was incomplete at the time because I couldn't write a reliable iotest (using blkdebug failed, because it was a filter that blocked access to exposing the dirty bitmap), and the patches were too close to the 4.0 release for a corner case that did not occur frequently in practice, so it moved to my back burner. But now that we have fixed the ability to see through the blkdebug filter, and have in the meantime added the qemu:allocation-depth context that also suffers from the same problem, I have finally updated this series to a state that I'm happy with.

[1] https://lists.gnu.org/archive/html/qemu-devel/2019-04/msg00589.html

Patch 5 is merely to aid in testing, by disabling the client workaround that has been present since qemu 4.0 (since the revert is no longer trivial).

Eric Blake (5):
iotests: Update 241 to expose backing layer fragmentation
block: Fix BDRV_BLOCK_RAW status to honor alignment nbd/server: Avoid unaligned read/block_status from backing nbd/server: Avoid unaligned dirty-bitmap status
do not apply: Revert "nbd-client: Work around server BLOCK_STATUS
misalignment at EOF"

 block/coroutines.h         |   2 +
 include/block/block.h      |   2 +
 block/io.c                 | 210 ++++++++++++++++++++++++++++++++++---
 block/nbd.c                |  30 +-----
 block/quorum.c             |   7 +-
 nbd/server.c               |  42 ++++++--
 tests/qemu-iotests/221     |  13 +++
 tests/qemu-iotests/221.out |   9 ++
 tests/qemu-iotests/241     |  58 +++++++++-
 tests/qemu-iotests/241.out |  24 ++++-
 10 files changed, 337 insertions(+), 60 deletions(-)
Signature · 1 line
2.30.1