rbd: Support BDRV_REQ_ZERO_WRITE for truncate
authorEric Blake <eblake@redhat.com>
Tue, 28 Apr 2020 20:29:00 +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 always returns 1 because rbd always
0-fills; we can use that same knowledge to implement
BDRV_REQ_ZERO_WRITE by ignoring it.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200428202905.770727-5-eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/rbd.c

index f2d52091c702b9687c7d7e5be46dc8dda191cd47..331c45adb2b276a0c4ec6c2d215fd1c76af153bc 100644 (file)
@@ -817,6 +817,9 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
         }
     }
 
+    /* When extending regular files, we get zeros from the OS */
+    bs->supported_truncate_flags = BDRV_REQ_ZERO_WRITE;
+
     r = 0;
     goto out;