From: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
To: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>,
ptikhomirov@virtuozzo.com
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH hci-8.1 3/7] drivers/md/dm-qcow2: prepare process_one_qio() for fastpath
Date: Mon, 2 Nov 2026 18:28:12 +0100 [thread overview]
Message-ID: <1f77cb6d-986f-4a1b-8e2d-9527a0f46512@virtuozzo.com> (raw)
In-Reply-To: <20261029140346.465768-4-andrey.zhadchenko@virtuozzo.com>
On 10/29/26 15:03, Andrey Zhadchenko wrote:
> dm-qcow2 heavily relies on main kwork do_qcow2_work() being
> sequential. All metadata change happens there and cannot
> run in parallel. Unfortunately that caps dm-qcow2 performance.
> But if the request does not require metadata changes we should
> be able to immediately dispatch it.
> process_one_qio() and handle_metadata() already know what to
> do: just add avoid_metadata_changes() flag and return codes.
Looks lake a typo, avoid_metadata_changes is not a function.
> While at it, just return in handle_metadata() instead of
> setting ret to 0 and jumping to if (ret < 0) label.
>
> Also exclude compressed clusters as there are some complications
> with wpc_readers.
>
> https://virtuozzo.atlassian.net/browse/VSTOR-95494
> Feature: dm-qcow2: block device over QCOW2 files driver
> Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
> ---
> drivers/md/dm-qcow2-map.c | 35 +++++++++++++++++++++++++----------
> 1 file changed, 25 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c
> index 1023224484f5b..c5d68b6b21f12 100644
> --- a/drivers/md/dm-qcow2-map.c
> +++ b/drivers/md/dm-qcow2-map.c
> @@ -3534,7 +3534,7 @@ static int prepare_cluster_discard(struct qcow2 *qcow2, struct qio **qio,
> }
>
> static int handle_metadata(struct qcow2 *qcow2, struct qio **qio,
> - struct qcow2_map *map)
> + struct qcow2_map *map, bool avoid_metadata_changes)
> {
> bool write = op_is_write((*qio)->bi_op);
> int ret;
> @@ -3543,15 +3543,20 @@ static int handle_metadata(struct qcow2 *qcow2, struct qio **qio,
> if (ret < 0 || !*qio) /* Error or postponed */
> goto check_err;
>
> + if (avoid_metadata_changes && map->compressed)
> + return 2;
Looks like a magic constant. Maybe enum/define?
> +
> ret = 1;
> if (unlikely(qcow2->backward_merge_in_process)) {
> + if (avoid_metadata_changes)
> + return 2;
> /* Keep in mind the below may replace *qio */
> ret = prepare_backward_merge(qcow2, qio, map, write);
> } else if (unlikely(fake_l1cow_qio(*qio)) &&
> (!map->clu_is_cow || (map->level & L2_LEVEL))) {
> /* Nothing to COW or L1 is mapped exactly once */
> qio_endio(*qio);
> - ret = 0;
> + return 0;
> } else if (unlikely(op_is_discard((*qio)->bi_op))) {
> /*
> * Discard carries no data and is advisory. If it does not
> @@ -3559,13 +3564,17 @@ static int handle_metadata(struct qcow2 *qcow2, struct qio **qio,
> * is not present, end early.
> */
> if (qio_discard_updates_metadata(qcow2, *qio, map)) {
> + if (avoid_metadata_changes)
> + return 2;
> ret = prepare_cluster_discard(qcow2, qio, map);
> } else if (!map->data_clu_alloced || map->clu_is_cow) {
> qio_endio(*qio);
> - ret = 0;
> + return 0;
> }
> } else if (write &&
> (!qio_is_fully_alloced(qcow2, *qio, map) || map->clu_is_cow)) {
> + if (avoid_metadata_changes)
> + return 2;
> if (map->clu_is_cow) {
> /* COW to compressed or shared with snapshot cluster */
> ret = prepare_l1l2_replace(qcow2, *qio, map);
> @@ -3677,13 +3686,17 @@ static void process_read_qio(struct qcow2 *qcow2, struct qio *qio,
> qio_endio(qio);
> }
>
> -static void process_one_qio(struct qcow2 *qcow2, struct qio *qio)
> +static int process_one_qio(struct qcow2 *qcow2, struct qio *qio, bool avoid_metadata_changes)
> {
> struct qcow2_map map = { .qcow2 = qcow2, };
> bool write;
> + int ret;
>
> - if (!handle_metadata(qcow2, &qio, &map))
> - return;
> + ret = handle_metadata(qcow2, &qio, &map, avoid_metadata_changes);
> + if (!ret)
> + return 0;
> + else if (ret == 2)
> + return 1;
>
> /*
> * Merge machinery makes out of order merges for present
> @@ -3695,7 +3708,7 @@ static void process_one_qio(struct qcow2 *qcow2, struct qio *qio)
> if (unlikely(qcow2->backward_merge_in_process) &&
> (fake_merge_qio(qio) || qcow2_file_is_writable(qcow2))) {
> submit_top_delta_read(&map, qio);
> - return;
> + return 0;
> }
>
> write = op_is_write(qio->bi_op);
> @@ -3703,13 +3716,13 @@ static void process_one_qio(struct qcow2 *qcow2, struct qio *qio)
> /* Process discard early. Don't do COW just to discard */
> if (unlikely(op_is_discard(qio->bi_op))) {
> issue_discard(&map, qio);
> - return;
> + return 0;
> }
>
> if (unlikely(map.compressed)) {
> /* Compressed qio never uses sub-clus */
> submit_read_compressed(&map, qio, write);
> - return;
> + return 0;
> }
>
> if (!write) {
> @@ -3722,6 +3735,8 @@ static void process_one_qio(struct qcow2 *qcow2, struct qio *qio)
> else
> perform_rw_mapped(&map, qio);
> }
> +
> + return 0;
> }
>
> static struct bio_vec *create_bvec_from_rq(struct request *rq)
> @@ -3824,7 +3839,7 @@ static void process_deferred_qios(struct qcow2 *qcow2, struct list_head *qios)
> continue;
> }
>
> - process_one_qio(qcow2, qio);
> + process_one_qio(qcow2, qio, false);
> }
> }
>
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-11-02 17:29 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-29 14:03 [Devel] [PATCH 0/7] drivers/md/dm-qcow2: per-qio fast path Andrey Zhadchenko
2026-10-29 14:03 ` [Devel] [PATCH hci-8.1 1/7] drivers/md/dm-qcow2: repeat md page lookup if it was inserted in parallel Andrey Zhadchenko
2026-10-29 14:13 ` no-reply
2026-11-04 21:35 ` Konstantin Khorenko
2026-10-29 14:03 ` [Devel] [PATCH hci-8.1 2/7] drivers/md/dm-qcow2: check MD_DIRTY and md->wbd under lock in perform_rw_mapped() Andrey Zhadchenko
2026-10-29 14:13 ` no-reply
2026-11-04 21:35 ` Konstantin Khorenko
2026-10-29 14:03 ` [Devel] [PATCH hci-8.1 3/7] drivers/md/dm-qcow2: prepare process_one_qio() for fastpath Andrey Zhadchenko
2026-10-29 14:16 ` no-reply
2026-11-02 17:28 ` Alexander Ivanov [this message]
2026-11-04 21:35 ` Konstantin Khorenko
2026-10-29 14:03 ` [Devel] [PATCH hci-8.1 4/7] drivers/md/dm-qcow2: add per-qio work infrastructure Andrey Zhadchenko
2026-10-29 14:18 ` no-reply
2026-11-04 21:35 ` Konstantin Khorenko
2026-10-29 14:03 ` [Devel] [PATCH hci-8.1 5/7] drivers/md/dm-qcow2: implement per-qio fast processing Andrey Zhadchenko
2026-10-29 14:22 ` no-reply
2026-11-04 21:35 ` Konstantin Khorenko
2026-10-29 14:03 ` [Devel] [PATCH hci-8.1 6/7] drivers/md/dm-qcow2: declare DM_TARGET_NOWAIT Andrey Zhadchenko
2026-10-29 14:19 ` no-reply
2026-11-03 8:33 ` Alexander Ivanov
2026-11-04 21:35 ` Konstantin Khorenko
2026-10-29 14:03 ` [Devel] [PATCH hci-8.1 7/7] drivers/md/dm-qcow2: process fast path qios in per-cpu batches on a workqueue Andrey Zhadchenko
2026-10-29 14:22 ` no-reply
2026-11-02 10:49 ` Andrey Zhadchenko
2026-11-04 21:35 ` Konstantin Khorenko
2026-11-03 9:36 ` [Devel] [PATCH 0/7] drivers/md/dm-qcow2: per-qio fast path Alexander Ivanov
2026-11-04 21:35 ` Konstantin Khorenko
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=1f77cb6d-986f-4a1b-8e2d-9527a0f46512@virtuozzo.com \
--to=alexander.ivanov@virtuozzo.com \
--cc=andrey.zhadchenko@virtuozzo.com \
--cc=devel@openvz.org \
--cc=ptikhomirov@virtuozzo.com \
/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