[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 10/17] block: Add new BDRV_ZERO_OPEN flag
From: |
Eric Blake |
Subject: |
Re: [PATCH 10/17] block: Add new BDRV_ZERO_OPEN flag |
Date: |
Fri, 31 Jan 2020 12:03:31 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 |
On 1/31/20 11:44 AM, Eric Blake wrote:
Knowing that a file reads as all zeroes when created is useful, but
limited in scope to drivers that can create images. However, there
are also situations where pre-existing images can quickly be
determined to read as all zeroes, even when the image was not just
created by the same process. The optimization used in qemu-img
convert to avoid a pre-zeroing pass on the destination is just as
useful in such a scenario. As such, it is worth the block layer
adding another bit to bdrv_known_zeroes().
Note that while BDRV_ZERO_CREATE cannot chase through backing layers
(because it only applies at creation time, but the backing layer was
not created at the same time as the active layer being created), it IS
okay for BDRV_ZERO_OPEN to chase through layers (as long as all layers
currently read as zero, the image reads as zero).
Upcoming patches will update the qcow2, file-posix, and nbd drivers to
advertise the new bit when appropriate.
Signed-off-by: Eric Blake <address@hidden>
---
[Is it bad when I review my own patches?]
+++ b/block.c
@@ -5078,7 +5078,7 @@ int bdrv_known_zeroes_truncate(BlockDriverState *bs)
int bdrv_known_zeroes(BlockDriverState *bs)
{
- int mask = BDRV_ZERO_CREATE | BDRV_ZERO_TRUNCATE;
+ int mask = BDRV_ZERO_CREATE | BDRV_ZERO_TRUNCATE | BDRV_ZERO_OPEN;
if (!bs->drv) {
return 0;
@@ -5100,17 +5100,17 @@ int bdrv_known_zeroes(BlockDriverState *bs)
* ZERO_CREATE is not viable. If the current layer is smaller
* than the backing layer, truncation may expose backing data,
* restricting ZERO_TRUNCATE; treat failure to query size in the
- * same manner. Otherwise, we can trust the driver.
+ * same manner. For ZERO_OPEN, we insist that both backing and
+ * current layer report the bit.
*/
-
if (bs->backing) {
Spurious line deletion caused by rebasing.
+++ b/include/block/block.h
@@ -105,6 +105,16 @@ typedef enum {
* for drivers that set .bdrv_co_truncate.
*/
BDRV_ZERO_TRUNCATE = 0x2,
+
+ /*
+ * bdrv_known_zeroes() should include this bit if an image is
+ * known to read as all zeroes when first opened; this bit should
+ * not be relied on after any writes to the image. This can be
+ * set even if BDRV_ZERO_INIT is clear, but should only be set if
Rebasing snafu - I renamed that bit BDRV_ZERO_CREATE in patch 9.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
- [PATCH 00/17] Improve qcow2 all-zero detection, Eric Blake, 2020/01/31
- [PATCH 01/17] qcow2: Comment typo fixes, Eric Blake, 2020/01/31
- [PATCH 04/17] block: Improve documentation of .bdrv_has_zero_init, Eric Blake, 2020/01/31
- [PATCH 02/17] qcow2: List autoclear bit names in header, Eric Blake, 2020/01/31
- [PATCH 05/17] block: Don't advertise zero_init_truncate with encryption, Eric Blake, 2020/01/31
- [PATCH 07/17] gluster: Drop useless has_zero_init callback, Eric Blake, 2020/01/31
- [PATCH 06/17] block: Improve bdrv_has_zero_init_truncate with backing file, Eric Blake, 2020/01/31
- [PATCH 08/17] sheepdog: Consistently set bdrv_has_zero_init_truncate, Eric Blake, 2020/01/31
- [PATCH 03/17] qcow2: Avoid feature name extension on small cluster size, Eric Blake, 2020/01/31
- [PATCH 10/17] block: Add new BDRV_ZERO_OPEN flag, Eric Blake, 2020/01/31
- Re: [PATCH 10/17] block: Add new BDRV_ZERO_OPEN flag,
Eric Blake <=
- [PATCH 11/17] file-posix: Support BDRV_ZERO_OPEN, Eric Blake, 2020/01/31
- [PATCH 09/17] block: Refactor bdrv_has_zero_init{,_truncate}, Eric Blake, 2020/01/31
- [PATCH 12/17] gluster: Support BDRV_ZERO_OPEN, Eric Blake, 2020/01/31
- [PATCH 13/17] qcow2: Add new autoclear feature for all zero image, Eric Blake, 2020/01/31
- [PATCH 15/17] qcow2: Implement all-zero autoclear bit, Eric Blake, 2020/01/31
- [PATCH 17/17] qcow2: Let qemu-img check cover all-zero bit, Eric Blake, 2020/01/31
- [PATCH 16/17] iotests: Add new test for qcow2 all-zero bit, Eric Blake, 2020/01/31
- [PATCH 14/17] qcow2: Expose all zero bit through .bdrv_known_zeroes, Eric Blake, 2020/01/31