Upstream NBD protocol implementation supports an efficient zero out mechanism over the wire, along with the ability to check whether a client allows using a hole.
Accordingly, since PWRITE_ZERO doesn't involve any payload on the wire, increase a maximum size of the PWRITE_ZERO request up to 1Gb (aligned). Moreover, such change will decrease the number of PWRITE_ZERO NBD commands in comparison with the current 32M limit. The benefits of the larger constraint can be examined in a block mirroring over NBD. Signed-off-by: Edgar Kaziakhmedov <edgar.kaziakhme...@virtuozzo.com> --- block/nbd.c | 2 +- include/block/nbd.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/block/nbd.c b/block/nbd.c index 94220f6d14..3641d9244e 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -477,7 +477,7 @@ static void nbd_refresh_limits(BlockDriverState *bs, Error **errp) uint32_t max = MIN_NON_ZERO(NBD_MAX_BUFFER_SIZE, s->info.max_block); bs->bl.max_pdiscard = max; - bs->bl.max_pwrite_zeroes = max; + bs->bl.max_pwrite_zeroes = NBD_MAX_PWRITE_ZERO_SIZE; bs->bl.max_transfer = max; if (s->info.opt_block && diff --git a/include/block/nbd.h b/include/block/nbd.h index ee74ec391a..e2f18e2332 100644 --- a/include/block/nbd.h +++ b/include/block/nbd.h @@ -182,6 +182,9 @@ enum { /* Maximum size of a single READ/WRITE data buffer */ #define NBD_MAX_BUFFER_SIZE (32 * 1024 * 1024) +/* Maximum size of a single PWRITE_ZERO request 1Gb */ +#define NBD_MAX_PWRITE_ZERO_SIZE (1024 * 1024 * 1024) + /* Maximum size of an export name. The NBD spec requires 256 and * suggests that servers support up to 4096, but we stick to only the * required size so that we can stack-allocate the names, and because -- 2.11.0