[GEDI] [PATCH 12/17] gluster: Support BDRV_ZERO_OPEN
Niels de Vos
ndevos at redhat.com
Mon Feb 17 08:16:50 UTC 2020
On Fri, Jan 31, 2020 at 11:44:31AM -0600, Eric Blake wrote:
> 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 <eblake at redhat.com>
> ---
> 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
Actually, Gluster dropped support for volumes backed by block devices
(LVM) a few releases back. Nobody could be found that used it, and it
could not be combined with other Gluster features. All contents on a
Gluster volume is now always backed by 'normal' files on a filesystem.
Creation or truncation should behave just as on a file on a local
filesystem. So maybe qemu_gluster_known_zeroes is not needed at all?
Niels
> + * 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
>
> _______________________________________________
> integration mailing list
> integration at gluster.org
> https://lists.gluster.org/mailman/listinfo/integration
>
More information about the integration
mailing list