Sparked by my question on whether we were handling zero-length reads correctly according to the NBD spec, but grew to fix other things as well such as some typos, tracing weaknesses, and better handling of read-only exports.
The order these patches are listed here is bisection-friendly, but applying the patches out of order (for example, applying 7/8 before any short-circuiting patches stop the client from sending 0-length requests, and before the server is fixed to stop botching replies to 0-length requests) proved important to my ability to test that the patches are needed. One of the patches is not strictly NBD, and begs the question of whether other filter drivers (mirror, throttle, etc) should also be reflecting the read-only status of their underlying BDS. Some of my testing included setting up a read-only NBD server and a read-write qemu-io session, then attempting 'w 0 0', 'w -z 0 0', and 'd 0 0'; these should not succeed if the corresponding 'w 0 1' fails, but the end goal is that the server shouldn't even need to be involved in these corner cases. Eric Blake (8): nbd-client: Fix error message typos nbd/client: Nicer trace of structured reply raw: Reflect read-only protocol layer nbd-client: Honor server read-only advertisement nbd: Fix struct name for structured reads nbd-client: Short-circuit 0-length operations nbd-client: Stricter enforcing of structured reply spec nbd/server: Fix structured read of length 0 include/block/nbd.h | 18 +++++++++++++----- block/nbd-client.c | 38 +++++++++++++++++++++++++++++++------- block/raw-format.c | 6 ++++++ nbd/client.c | 4 +++- nbd/server.c | 23 +++++++++++++++++++++-- nbd/trace-events | 3 ++- 6 files changed, 76 insertions(+), 16 deletions(-) -- 2.13.6