]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
ssh: Support BDRV_REQ_ZERO_WRITE for truncate
authorEric Blake <eblake@redhat.com>
Tue, 28 Apr 2020 20:29:02 +0000 (15:29 -0500)
committerKevin Wolf <kwolf@redhat.com>
Fri, 8 May 2020 11:26:35 +0000 (13:26 +0200)
Our .bdrv_has_zero_init_truncate can detect when the remote side
always zero fills; we can reuse that same knowledge to implement
BDRV_REQ_ZERO_WRITE by ignoring it when the server gives it to us for
free.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200428202905.770727-7-eblake@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/ssh.c

index 9eb33df8598c51bfb27085a819250054f19f8068..f9e08a4900692a938d23d95b23a38a68652292a1 100644 (file)
@@ -883,6 +883,10 @@ static int ssh_file_open(BlockDriverState *bs, QDict *options, int bdrv_flags,
     /* Go non-blocking. */
     ssh_set_blocking(s->session, 0);
 
+    if (s->attrs->type == SSH_FILEXFER_TYPE_REGULAR) {
+        bs->supported_truncate_flags = BDRV_REQ_ZERO_WRITE;
+    }
+
     qapi_free_BlockdevOptionsSsh(opts);
 
     return 0;