[PATCH v5 5/9] raw-format: Support BDRV_REQ_ZERO_WRITE for truncate

Kevin Wolf posted 9 patches 5 years, 9 months ago
Maintainers: Stefan Weil <sw@weilnetz.de>, John Snow <jsnow@redhat.com>, Max Reitz <mreitz@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Liu Yuan <namei.unix@gmail.com>, "Denis V. Lunev" <den@openvz.org>, Jeff Cody <codyprime@gmail.com>, Fam Zheng <fam@euphon.net>, Stefan Hajnoczi <stefanha@redhat.com>, "Richard W.M. Jones" <rjones@redhat.com>, Markus Armbruster <armbru@redhat.com>, Kevin Wolf <kwolf@redhat.com>, Jason Dillaman <dillaman@redhat.com>, Peter Lieven <pl@kamp.de>, Ronnie Sahlberg <ronniesahlberg@gmail.com>
There is a newer version of this series
[PATCH v5 5/9] raw-format: Support BDRV_REQ_ZERO_WRITE for truncate
Posted by Kevin Wolf 5 years, 9 months ago
The raw format driver can simply forward the flag and let its bs->file
child take care of actually providing the zeros.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/raw-format.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/block/raw-format.c b/block/raw-format.c
index 3465c9a865..351f2d91c6 100644
--- a/block/raw-format.c
+++ b/block/raw-format.c
@@ -387,7 +387,7 @@ static int coroutine_fn raw_co_truncate(BlockDriverState *bs, int64_t offset,
 
     s->size = offset;
     offset += s->offset;
-    return bdrv_co_truncate(bs->file, offset, exact, prealloc, 0, errp);
+    return bdrv_co_truncate(bs->file, offset, exact, prealloc, flags, errp);
 }
 
 static void raw_eject(BlockDriverState *bs, bool eject_flag)
@@ -445,6 +445,8 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags,
     bs->supported_zero_flags = BDRV_REQ_WRITE_UNCHANGED |
         ((BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK) &
             bs->file->bs->supported_zero_flags);
+    bs->supported_truncate_flags = bs->file->bs->supported_truncate_flags &
+                                   BDRV_REQ_ZERO_WRITE;
 
     if (bs->probed && !bdrv_is_read_only(bs)) {
         bdrv_refresh_filename(bs->file->bs);
-- 
2.25.3


Re: [PATCH v5 5/9] raw-format: Support BDRV_REQ_ZERO_WRITE for truncate
Posted by Eric Blake 5 years, 9 months ago
On 4/22/20 10:21 AM, Kevin Wolf wrote:
> The raw format driver can simply forward the flag and let its bs->file
> child take care of actually providing the zeros.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>   block/raw-format.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

> diff --git a/block/raw-format.c b/block/raw-format.c
> index 3465c9a865..351f2d91c6 100644
> --- a/block/raw-format.c
> +++ b/block/raw-format.c
> @@ -387,7 +387,7 @@ static int coroutine_fn raw_co_truncate(BlockDriverState *bs, int64_t offset,
>   
>       s->size = offset;
>       offset += s->offset;
> -    return bdrv_co_truncate(bs->file, offset, exact, prealloc, 0, errp);
> +    return bdrv_co_truncate(bs->file, offset, exact, prealloc, flags, errp);
>   }
>   
>   static void raw_eject(BlockDriverState *bs, bool eject_flag)
> @@ -445,6 +445,8 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags,
>       bs->supported_zero_flags = BDRV_REQ_WRITE_UNCHANGED |
>           ((BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK) &
>               bs->file->bs->supported_zero_flags);
> +    bs->supported_truncate_flags = bs->file->bs->supported_truncate_flags &
> +                                   BDRV_REQ_ZERO_WRITE;
>   
>       if (bs->probed && !bdrv_is_read_only(bs)) {
>           bdrv_refresh_filename(bs->file->bs);
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


Re: [PATCH v5 5/9] raw-format: Support BDRV_REQ_ZERO_WRITE for truncate
Posted by Max Reitz 5 years, 9 months ago
On 22.04.20 17:21, Kevin Wolf wrote:
> The raw format driver can simply forward the flag and let its bs->file
> child take care of actually providing the zeros.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  block/raw-format.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Reviewed-by: Max Reitz <mreitz@redhat.com>