From: Stefan Hajnoczi <stefanha@redhat.com>
To: Fiona Ebner <f.ebner@proxmox.com>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, hreitz@redhat.com,
kwolf@redhat.com, jsnow@redhat.com, vsementsov@yandex-team.ru,
qemu-stable@nongnu.org, eblake@redhat.com
Subject: Re: [PATCH] block/mirror: check range when setting zero bitmap for sync write
Date: Mon, 19 Jan 2026 15:10:59 -0500 [thread overview]
Message-ID: <20260119201059.GA869317@fedora> (raw)
In-Reply-To: <20260112152544.261923-1-f.ebner@proxmox.com>
[-- Attachment #1: Type: text/plain, Size: 3204 bytes --]
On Mon, Jan 12, 2026 at 04:23:51PM +0100, Fiona Ebner wrote:
> Some Proxmox users reported an occasional assertion failure [0][1] in
> busy VMs when using drive mirror with active mode. In particular, the
> failure may occur for zero writes shorter than the job granularity:
>
> > #0 0x00007b421154b507 in abort ()
> > #1 0x00007b421154b420 in ?? ()
> > #2 0x0000641c582e061f in bitmap_set (map=0x7b4204014e00, start=14, nr=-1)
> > #3 0x0000641c58062824 in do_sync_target_write (job=0x641c7e73d1e0,
> > method=MIRROR_METHOD_ZERO, offset=852480, bytes=4096, qiov=0x0, flags=0)
> > #4 0x0000641c58062250 in bdrv_mirror_top_do_write (bs=0x641c7e62e1f0,
> method=MIRROR_METHOD_ZERO, copy_to_target=true, offset=852480,
> bytes=4096, qiov=0x0, flags=0)
> > #5 0x0000641c58061f31 in bdrv_mirror_top_pwrite_zeroes (bs=0x641c7e62e1f0,
> offset=852480, bytes=4096, flags=0)
>
> The range for the dirty bitmap described by dirty_bitmap_offset and
> dirty_bitmap_end is narrower than the original range and in fact,
> dirty_bitmap_end might be smaller than dirty_bitmap_offset. There
> already is a check for 'dirty_bitmap_offset < dirty_bitmap_end' before
> resetting the dirty bitmap. Add such a check for setting the zero
> bitmap too, which uses the same narrower range.
>
> [0]: https://forum.proxmox.com/threads/177981/
> [1]: https://bugzilla.proxmox.com/show_bug.cgi?id=7222
>
> Cc: qemu-stable@nongnu.org
> Fixes: 7e277545b9 ("mirror: Skip writing zeroes when target is already zero")
> Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
> ---
> block/mirror.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/block/mirror.c b/block/mirror.c
> index b344182c74..bc982cb99a 100644
> --- a/block/mirror.c
> +++ b/block/mirror.c
> @@ -1514,9 +1514,12 @@ do_sync_target_write(MirrorBlockJob *job, MirrorMethod method,
> assert(!qiov);
> ret = blk_co_pwrite_zeroes(job->target, offset, bytes, flags);
> if (job->zero_bitmap && ret >= 0) {
> - bitmap_set(job->zero_bitmap, dirty_bitmap_offset / job->granularity,
> - (dirty_bitmap_end - dirty_bitmap_offset) /
> - job->granularity);
> + if (dirty_bitmap_offset < dirty_bitmap_end) {
> + bitmap_set(job->zero_bitmap,
> + dirty_bitmap_offset / job->granularity,
> + (dirty_bitmap_end - dirty_bitmap_offset) /
> + job->granularity);
> + }
Why does this case clause use dirty_bitmap_offset and dirty_bitmap_end
instead of zero_bitmap_offset and zero_bitmap_end like the other
zero_bitmap operations in this switch statement?
if (job->zero_bitmap && ret >= 0) {
- bitmap_set(job->zero_bitmap, dirty_bitmap_offset / job->granularity,
- (dirty_bitmap_end - dirty_bitmap_offset) /
- job->granularity);
+ bitmap_set(job->zero_bitmap, zero_bitmap_offset,
+ zero_bitmap_end - zero_bitmap_offset);
}
I'm probably missing something, but it's not obvious to me :).
Stefan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2026-01-19 20:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-12 15:23 [PATCH] block/mirror: check range when setting zero bitmap for sync write Fiona Ebner
2026-01-19 15:28 ` Vladimir Sementsov-Ogievskiy
2026-01-20 11:38 ` [PATCH] iotests: test active mirror with unaligned, small write zeroes op Fiona Ebner
2026-01-21 7:05 ` Vladimir Sementsov-Ogievskiy
2026-01-19 20:10 ` Stefan Hajnoczi [this message]
2026-01-20 8:57 ` [PATCH] block/mirror: check range when setting zero bitmap for sync write Fiona Ebner
2026-01-21 19:18 ` Stefan Hajnoczi
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=20260119201059.GA869317@fedora \
--to=stefanha@redhat.com \
--cc=eblake@redhat.com \
--cc=f.ebner@proxmox.com \
--cc=hreitz@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.