qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Eric Blake
Subject: Re: [PATCH v4 5/9] raw-format: Support BDRV_REQ_ZERO_WRITE for truncate
Date: Mon, 20 Apr 2020 10:14:18 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0

On 4/20/20 8:32 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 <address@hidden>
---
  block/raw-format.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/block/raw-format.c b/block/raw-format.c
index 3465c9a865..ab69ac46d3 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,7 @@ 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 = BDRV_REQ_ZERO_WRITE;

Shouldn't this be:

bs->supported_truncate_flags = (bs->file->bs->supported_truncate_flags &
                                BDRV_REQ_ZERO_WRITE);

rather than unconditionally advertising something that the underlying layer may lack?

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]