]> git.proxmox.com Git - mirror_qemu.git/commit
nbd: Implement NBD_INFO_BLOCK_SIZE on server
authorEric Blake <eblake@redhat.com>
Fri, 7 Jul 2017 20:30:48 +0000 (15:30 -0500)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 14 Jul 2017 10:04:42 +0000 (12:04 +0200)
commit0c1d50bda7ae03146b4bf7bc3a12389897ea059c
tree4561bd187c795158a2ce5a0e901ed75596e6b4d8
parent8ecaeae82241b6e317d19e5558e52f9e2f979f74
nbd: Implement NBD_INFO_BLOCK_SIZE on server

The upstream NBD Protocol has defined a new extension to allow
the server to advertise block sizes to the client, as well as
a way for the client to inform the server that it intends to
obey block sizes.

Thanks to a recent fix (commit df7b97ff), our real minimum
transfer size is always 1 (the block layer takes care of
read-modify-write on our behalf), but we're still more efficient
if we advertise 512 when the client supports it, as follows:
- OPT_INFO, but no NBD_INFO_BLOCK_SIZE: advertise 512, then
fail with NBD_REP_ERR_BLOCK_SIZE_REQD; client is free to try
something else since we don't disconnect
- OPT_INFO with NBD_INFO_BLOCK_SIZE: advertise 512
- OPT_GO, but no NBD_INFO_BLOCK_SIZE: advertise 1
- OPT_GO with NBD_INFO_BLOCK_SIZE: advertise 512

We can also advertise the optimum block size (presumably the
cluster size, when exporting a qcow2 file), and our absolute
maximum transfer size of 32M, to help newer clients avoid
EINVAL failures or abrupt disconnects on oversize requests.

We do not reject clients for using the older NBD_OPT_EXPORT_NAME;
we are no worse off for those clients than we used to be.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20170707203049.534-9-eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
nbd/server.c
nbd/trace-events