[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 12/17] gluster: Support BDRV_ZERO_OPEN
From: |
Eric Blake |
Subject: |
[PATCH 12/17] gluster: Support BDRV_ZERO_OPEN |
Date: |
Fri, 31 Jan 2020 11:44:31 -0600 |
Since gluster already copies file-posix for lseek usage in block
status, it also makes sense to copy it for learning if the image
currently reads as all zeroes.
Signed-off-by: Eric Blake <address@hidden>
---
block/gluster.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/block/gluster.c b/block/gluster.c
index 9d952c70981b..0417a86547c8 100644
--- a/block/gluster.c
+++ b/block/gluster.c
@@ -1464,6 +1464,22 @@ exit:
return -ENOTSUP;
}
+static int qemu_gluster_known_zeroes(BlockDriverState *bs)
+{
+ /*
+ * GlusterFS volume could be backed by a block device, with no way
+ * to query if regions added by creation or truncation will read
+ * as zeroes. However, we can use lseek(SEEK_DATA) to check if
+ * contents currently read as zero.
+ */
+ off_t data, hole;
+
+ if (find_allocation(bs, 0, &data, &hole) == -ENXIO) {
+ return BDRV_ZERO_OPEN;
+ }
+ return 0;
+}
+
/*
* Returns the allocation status of the specified offset.
*
@@ -1561,6 +1577,7 @@ static BlockDriver bdrv_gluster = {
.bdrv_co_readv = qemu_gluster_co_readv,
.bdrv_co_writev = qemu_gluster_co_writev,
.bdrv_co_flush_to_disk = qemu_gluster_co_flush_to_disk,
+ .bdrv_known_zeroes = qemu_gluster_known_zeroes,
#ifdef CONFIG_GLUSTERFS_DISCARD
.bdrv_co_pdiscard = qemu_gluster_co_pdiscard,
#endif
@@ -1591,6 +1608,7 @@ static BlockDriver bdrv_gluster_tcp = {
.bdrv_co_readv = qemu_gluster_co_readv,
.bdrv_co_writev = qemu_gluster_co_writev,
.bdrv_co_flush_to_disk = qemu_gluster_co_flush_to_disk,
+ .bdrv_known_zeroes = qemu_gluster_known_zeroes,
#ifdef CONFIG_GLUSTERFS_DISCARD
.bdrv_co_pdiscard = qemu_gluster_co_pdiscard,
#endif
@@ -1621,6 +1639,7 @@ static BlockDriver bdrv_gluster_unix = {
.bdrv_co_readv = qemu_gluster_co_readv,
.bdrv_co_writev = qemu_gluster_co_writev,
.bdrv_co_flush_to_disk = qemu_gluster_co_flush_to_disk,
+ .bdrv_known_zeroes = qemu_gluster_known_zeroes,
#ifdef CONFIG_GLUSTERFS_DISCARD
.bdrv_co_pdiscard = qemu_gluster_co_pdiscard,
#endif
@@ -1657,6 +1676,7 @@ static BlockDriver bdrv_gluster_rdma = {
.bdrv_co_readv = qemu_gluster_co_readv,
.bdrv_co_writev = qemu_gluster_co_writev,
.bdrv_co_flush_to_disk = qemu_gluster_co_flush_to_disk,
+ .bdrv_known_zeroes = qemu_gluster_known_zeroes,
#ifdef CONFIG_GLUSTERFS_DISCARD
.bdrv_co_pdiscard = qemu_gluster_co_pdiscard,
#endif
--
2.24.1
- [PATCH 02/17] qcow2: List autoclear bit names in header, (continued)
- [PATCH 02/17] qcow2: List autoclear bit names in header, 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 05/17] block: Don't advertise zero_init_truncate with encryption, Eric Blake, 2020/01/31
- [PATCH 03/17] qcow2: Avoid feature name extension on small cluster size, Eric Blake, 2020/01/31
- [PATCH 08/17] sheepdog: Consistently set bdrv_has_zero_init_truncate, Eric Blake, 2020/01/31
- [PATCH 10/17] block: Add new BDRV_ZERO_OPEN flag, Eric Blake, 2020/01/31
- [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 <=
- [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 14/17] qcow2: Expose all zero bit through .bdrv_known_zeroes, Eric Blake, 2020/01/31
- [PATCH 16/17] iotests: Add new test for qcow2 all-zero bit, Eric Blake, 2020/01/31
- [PATCH 17/17] qcow2: Let qemu-img check cover all-zero bit, Eric Blake, 2020/01/31