Received: from eggs.gnu.org ([2001:4830:134:3::10]:57594) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c7T4U-0006sf-Ll for qemu-devel@nongnu.org; Thu, 17 Nov 2016 15:14:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c7T4T-0003fl-Oa for qemu-devel@nongnu.org; Thu, 17 Nov 2016 15:14:10 -0500 From: Eric Blake Date: Thu, 17 Nov 2016 14:13:54 -0600 Message-Id: <1479413642-22463-2-git-send-email-eblake@redhat.com> In-Reply-To: <1479413642-22463-1-git-send-email-eblake@redhat.com> References: <1479413642-22463-1-git-send-email-eblake@redhat.com> Subject: [Qemu-devel] [PATCH v2 1/9] nbd: Allow unmap and fua during write zeroes List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, kwolf@redhat.com, pbonzini@redhat.com, qemu-stable@nongnu.org, Max Reitz Commit fa778fff wired up support to send the NBD_CMD_WRITE_ZEROES, but forgot to inform the block layer that FUA unmapping of zeroes is supported. Without BDRV_REQ_MAY_UNMAP listed as a supported flag, the block layer will always insist on the NBD layer passing NBD_CMD_FLAG_NO_HOLE, resulting in the server always allocating things even when it was desired to let the server punch holes. Similarly, failing to set BDRV_REQ_FUA means that the client may send unnecessary NBD_CMD_FLUSH when it could have instead used the NBD_CMD_FLAG_FUA bit. CC: qemu-stable@nongnu.org Signed-off-by: Eric Blake --- block/nbd-client.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/block/nbd-client.c b/block/nbd-client.c index 2a302de..3779c6c 100644 --- a/block/nbd-client.c +++ b/block/nbd-client.c @@ -415,6 +415,10 @@ int nbd_client_init(BlockDriverState *bs, } if (client->nbdflags & NBD_FLAG_SEND_FUA) { bs->supported_write_flags = BDRV_REQ_FUA; + bs->supported_zero_flags |= BDRV_REQ_FUA; + } + if (client->nbdflags & NBD_FLAG_SEND_WRITE_ZEROES) { + bs->supported_zero_flags |= BDRV_REQ_MAY_UNMAP; } qemu_co_mutex_init(&client->send_mutex); -- 2.7.4