qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
To: Eric Blake <eblake@redhat.com>
Cc: vsementsov@yandex-team.ru, hreitz@redhat.com, jsnow@redhat.com,
	qemu-block@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [PATCH] hbitmap: fix hbitmap_status() return value for first dirty bit case
Date: Fri, 3 Feb 2023 13:55:21 +0300	[thread overview]
Message-ID: <b03aa8ad-c917-b43f-443e-1fe7ee959b23@virtuozzo.com> (raw)
In-Reply-To: <20230202193944.63qcqpvklyoslode@redhat.com>


On 2/2/23 22:39, Eric Blake wrote:
> On Thu, Feb 02, 2023 at 09:15:23PM +0300, Andrey Zhadchenko via wrote:
>> The last return statement should return true, as we already evaluated that
>> start == next_dirty
>>
>> Also, fix hbitmap_status() description in header
>>
>> Cc: qemu-stable@nongnu.org
>> Fixes: a6426475a75 ("block/dirty-bitmap: introduce bdrv_dirty_bitmap_status()")
>> Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
>> ---
>>   include/qemu/hbitmap.h | 2 +-
>>   util/hbitmap.c         | 2 +-
>>   2 files changed, 2 insertions(+), 2 deletions(-)
> 
> Eww, nasty bug; looks like copy-before-write is the only curernt
> client of this interface.
Also this only happens when copy-before-write is used in conjunction
with snapshot-access (7.0+), so probably not many people is affected.

> 
> Reviewed-by: Eric Blake <eblake@redhat.com>
> 
> Is there any way to enhance an iotest to add coverage for this code?
> 
Looks like yes. copy-before-write uses bcs bitmaps, which is 64k.
So changing existing test

diff --git a/tests/qemu-iotests/tests/image-fleecing 
b/tests/qemu-iotests/tests/image-fleecing
index f6e449d071..7eda9a2c6b 100755
--- a/tests/qemu-iotests/tests/image-fleecing
+++ b/tests/qemu-iotests/tests/image-fleecing
@@ -34,23 +34,23 @@ iotests.script_initialize(
      unsupported_imgopts=['compat']
  )

-patterns = [('0x5d', '0',         '64k'),
-            ('0xd5', '1M',        '64k'),
-            ('0xdc', '32M',       '64k'),
-            ('0xcd', '0x3ff0000', '64k')]  # 64M - 64K
+patterns = [('0x5d', '0',         '128k'),
+            ('0xd5', '1M',        '128k'),
+            ('0xdc', '32M',       '128k'),
+            ('0xcd', '0x3fe0000', '128k')]  # 64M - 128K

-overwrite = [('0xab', '0',         '64k'), # Full overwrite
-             ('0xad', '0x00f8000', '64k'), # Partial-left (1M-32K)
-             ('0x1d', '0x2008000', '64k'), # Partial-right (32M+32K)
-             ('0xea', '0x3fe0000', '64k')] # Adjacent-left (64M - 128K)
+overwrite = [('0xab', '0',         '128k'), # Full overwrite
+             ('0xad', '0x00f0000', '128k'), # Partial-left (1M-64K)
+             ('0x1d', '0x2010000', '128k'), # Partial-right (32M+64K)
+             ('0xea', '0x3fc0000', '128k')] # Adjacent-left (64M - 256K)

-zeroes = [('0', '0x00f8000', '32k'), # Left-end of partial-left (1M-32K)
-          ('0', '0x2010000', '32k'), # Right-end of partial-right (32M+64K)
-          ('0', '0x3fe0000', '64k')] # overwrite[3]
+zeroes = [('0', '0x00f0000', '64k'), # Left-end of partial-left (1M-64K)
+          ('0', '0x2020000', '64k'), # Right-end of partial-right 
(32M+128K)
+          ('0', '0x3fc0000', '128k')] # overwrite[3]

-remainder = [('0xd5', '0x108000',  '32k'), # Right-end of partial-left [1]
-             ('0xdc', '32M',       '32k'), # Left-end of partial-right [2]
-             ('0xcd', '0x3ff0000', '64k')] # patterns[3]
+remainder = [('0xd5', '0x110000',  '64k'), # Right-end of partial-left [1]
+             ('0xdc', '32M',       '64k'), # Left-end of partial-right [2]
+             ('0xcd', '0x3fe0000', '128k')] # patterns[3]

  def do_test(vm, use_cbw, use_snapshot_access_filter, base_img_path,
              fleece_img_path, nbd_sock_path=None,


 From 64k chunks to 128k chunks (so at the read moment we have N bit 
dirty and N+1 clean) produces the following for one of NBD test cases:

--- Setting up NBD Export ---

{"return": {}}
{"return": {}}

--- Sanity Check ---

read -P0x5d 0 128k
read -P0xd5 1M 128k
read -P0xdc 32M 128k
read -P0xcd 0x3fe0000 128k
read -P0 0x00f0000 64k
read failed: Invalid argument

read -P0 0x2020000 64k
read failed: Invalid argument

read -P0 0x3fc0000 128k
read failed: Invalid argument


I am not good at qemi-io tool, I guess that EINVAL in that case means 
qemu-io found out that image data does not follow requested pattern?

Also this does not trigger for non-nbd tests since backup job is 
probably copying one cluster at a time.


  reply	other threads:[~2023-02-03 10:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-02 18:15 [PATCH] hbitmap: fix hbitmap_status() return value for first dirty bit case Andrey Zhadchenko via
2023-02-02 19:39 ` Eric Blake
2023-02-03 10:55   ` Andrey Zhadchenko [this message]
2023-02-03 11:22     ` Andrey Zhadchenko
2023-02-14 17:13 ` Vladimir Sementsov-Ogievskiy
2023-02-16 11:01 ` Kevin Wolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b03aa8ad-c917-b43f-443e-1fe7ee959b23@virtuozzo.com \
    --to=andrey.zhadchenko@virtuozzo.com \
    --cc=eblake@redhat.com \
    --cc=hreitz@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=vsementsov@yandex-team.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).