From: Kevin Wolf <kwolf@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: luzhipeng <luzhipeng@cestc.cn>,
qemu-block@nongnu.org, John Snow <jsnow@redhat.com>,
Hanna Reitz <hreitz@redhat.com>,
qemu-devel@nongnu.org
Subject: Re: [PATCH] mirror: Optimize mirroring for zero blocks in mirror_read_complete
Date: Mon, 17 Nov 2025 18:35:30 +0100 [thread overview]
Message-ID: <aRtc4u3FVlaN73yR@redhat.com> (raw)
In-Reply-To: <2pfcwex4mzczvrezsv5mmlnd5elfgg2yt5akymfe7dslksnlbr@yyjlkqoibnpb>
Am 22.09.2025 um 14:53 hat Eric Blake geschrieben:
> Then a higher-level question. Should we teach blk_co_pwritev() to
> have a flag that ANY caller can set to request write-zero
> optimizations, rather than having to open-code a check and call to
> blk_co_pwrite_zeroes() at every call-site that might benefit?
>
> Optimizing to a write zero is often nice, but using BDRV_REQ_MAY_UNMAP
> may break use cases that have explicitly requested full allocation.
> The more we can consolidate all of the decisions about whether or not
> to use write zeroes, and whether or not to allow unmap in that
> attempt, into a single common function rather than duplicated out at
> every call site that might benefit, the easier it will be to maintain
> the code down the road.
>
> Thus, I'm wondering if it might be better to introduce a new BDRV_REQ_
> flag for passing to blk_co_pwritev for deciding to trigger potential
> write-zero optimizations.
We already have the detect-zeroes=on|off|unmap option, which is used in
bdrv_aligned_pwritev() to enable this kind of optimisation. I think we
should reuse this code in some way. We also should configure the mirror
job in a similar way, adding a new detect-zeroes=on|off|unmap option to
blockdev-mirror (and off will stay the default).
One option is, as you say, that we introduce BDRV_REQ_* flags that could
take effect even when the BlockDriverState isn't configured to detect
zeroes. For a three-way option, we'd need a combination of two flags,
though, or a two-bit field. I'm not sure how much I like this.
The other option is that you just set detect-zeroes on the target node
that mirror points to. What makes this a bit harder is that mirror only
owns the BlockBackend, but no node on the target side (on the source
side, we have the mirror_top filter), and suddenly inserting new nodes
isn't great either. So this is probably something that mirror can't do
for you, but you as the user would have to configure the target node
explicitly this way.
Kevin
next prev parent reply other threads:[~2025-11-17 17:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-22 11:36 [PATCH] mirror: Optimize mirroring for zero blocks in mirror_read_complete luzhipeng
2025-09-22 11:36 ` luzhipeng
2025-09-22 12:53 ` Eric Blake
2025-11-17 17:35 ` Kevin Wolf [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-11-14 2:11 [PATCH] block: add single-check guard in throttle_group_restart_queue to address race with schedule_next_request luzhipeng
2025-11-14 2:11 ` [PATCH] mirror: Optimize mirroring for zero blocks in mirror_read_complete luzhipeng
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=aRtc4u3FVlaN73yR@redhat.com \
--to=kwolf@redhat.com \
--cc=eblake@redhat.com \
--cc=hreitz@redhat.com \
--cc=jsnow@redhat.com \
--cc=luzhipeng@cestc.cn \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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).