qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] block/backup-top: fix flags handling


From: Eric Blake
Subject: Re: [PATCH] block/backup-top: fix flags handling
Date: Fri, 31 Jan 2020 13:38:39 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1

On 1/31/20 12:48 PM, Vladimir Sementsov-Ogievskiy wrote:
backup-top "supports" write-unchanged, by skipping CBW operation in
backup_top_co_pwritev. But it forgets to do the same in
backup_top_co_pwrite_zeroes, as well as declare support for
BDRV_REQ_WRITE_UNCHANGED.

Fix this, and, while being here, declare also support for flags
supported by source child.

Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
---
  block/backup-top.c | 28 ++++++++++++++++++----------
  1 file changed, 18 insertions(+), 10 deletions(-)


@@ -197,6 +201,10 @@ BlockDriverState *bdrv_backup_top_append(BlockDriverState 
*source,
top->total_sectors = source->total_sectors;
      state = top->opaque;
+    top->supported_write_flags =
+        BDRV_REQ_WRITE_UNCHANGED | source->supported_write_flags;
+    top->supported_zero_flags =
+        BDRV_REQ_WRITE_UNCHANGED | source->supported_zero_flags;

Elsewhere, in block/filter-compress.c we do:

    bs->supported_write_flags = BDRV_REQ_WRITE_UNCHANGED |
        (BDRV_REQ_FUA & bs->file->bs->supported_write_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);

That's slightly more robust (if the block layer adds new BDRV_REQ_ bits, we don't have to revisit filter-compress.c to decide if blindly exposing those bits breaks for some reason, but rahter DO have to amend the line to opt-in to supporting the new bits). Whereas your code does NOT need editing if passing on the new bit is safe, but risks a subtle breakage if we forget to filter out the new bit when passing it on would be unsafe. I tend to lean towards safety and opt-in over blind pass-through that works with the current set of defined bits, but not enough to withhold:

Reviewed-by: Eric Blake <address@hidden>

--
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]