• E
    nbd: Implement NBD_INFO_BLOCK_SIZE on server · 0c1d50bd
    Eric Blake 提交于
    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: NEric Blake <eblake@redhat.com>
    Message-Id: <20170707203049.534-9-eblake@redhat.com>
    Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
    0c1d50bd
server.c 45.9 KB