From: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
To: Alexander Ivanov <alexander.ivanov@virtuozzo.com>,
khorenko@virtuozzo.com
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH hci-8.1 v3 4/8] dm-qcow2: add per-qio work infrastructure
Date: Wed, 25 Nov 2026 10:18:14 +0100 [thread overview]
Message-ID: <aae97b02-b1cc-4e3a-91ea-23d185dca2b6@virtuozzo.com> (raw)
In-Reply-To: <2d7d8fb6-49e9-4a62-86b4-9ac3cb70da98@virtuozzo.com>
On 11/25/26 08:22, Alexander Ivanov wrote:
>
> On 11/13/26 12:11, Andrey Zhadchenko wrote:
>> dm-qcow2 was created to run non-concurrently, so qio never had
>> per work struct field. Let's add one and use it to queue first
>> dm-qcow2 pipeline step: qio preparation. It requires no metadata,
>> so everything is simple here.
>> We would later move more pipeline steps into qio.
>>
>> 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>
>> ---
>> v2: updated QLIST_EMBEDDED comment
>> v3: no changes
>>
>> drivers/md/dm-qcow2-map.c | 60 ++++++++++++++++++++++++++++-----------
>> drivers/md/dm-qcow2.h | 12 ++++++--
>> 2 files changed, 54 insertions(+), 18 deletions(-)
>>
>> diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c
>> index b9daa258285e6..496fbcc613488 100644
>> --- a/drivers/md/dm-qcow2-map.c
>> +++ b/drivers/md/dm-qcow2-map.c
>> @@ -362,6 +362,8 @@ struct qio *qcow2_alloc_qio(mempool_t *pool, bool
>> zero)
>> }
>> ALLOW_ERROR_INJECTION(qcow2_alloc_qio, NULL);
>> +static void do_qio_work(struct work_struct *ws);
>> +
>> void qcow2_init_qio(struct qio *qio, unsigned int bi_op, struct
>> qcow2 *qcow2)
>> {
>> qio->qcow2 = qcow2;
>> @@ -374,7 +376,9 @@ void qcow2_init_qio(struct qio *qio, unsigned int
>> bi_op, struct qcow2 *qcow2)
>> qio->flags = 0;
>> qio->ref_index = REF_INDEX_INVALID;
>> qio->writer_gen = 0;
>> + qio->state = QIO_STATE_START;
>> atomic_set(&qio->remaining, 1);
>> + INIT_WORK(&qio->worker, do_qio_work);
>> /*
>> * Initially set into BLK_STS_OK, while aio complete,
>> @@ -3985,10 +3989,10 @@ static void qio_init_iter_from_rq(struct qio
>> *qio, struct request *rq)
>> qio->bi_iter.bi_bvec_done = 0;
>> }
>> -static void prepare_one_embedded_qio(struct qcow2 *qcow2, struct qio
>> *qio,
>> - struct list_head *deferred_qios)
>> +static void prepare_one_embedded_qio(struct qio *qio, struct
>> list_head *deferred_qios)
>> {
>> struct qcow2_rq *qrq = qio->endio_cb_data;
>> + struct qcow2 *qcow2 = qio->qcow2;
>> struct request *rq = qrq->rq;
>> struct bio_vec *bvec = NULL;
>> LIST_HEAD(list);
>> @@ -4033,15 +4037,6 @@ static void prepare_one_embedded_qio(struct
>> qcow2 *qcow2, struct qio *qio,
>> qio_endio(qio);
>> }
>> -static void process_embedded_qios(struct qcow2 *qcow2, struct
>> list_head *qios,
>> - struct list_head *deferred_qios)
>> -{
>> - struct qio *qio;
>> -
>> - while ((qio = qio_list_pop(qios)))
>> - prepare_one_embedded_qio(qcow2, qio, deferred_qios);
>> -}
>> -
>> static void process_deferred_qios(struct qcow2 *qcow2, struct
>> list_head *qios)
>> {
>> struct qio *qio;
>> @@ -4561,7 +4556,6 @@ static void process_seek_qios(struct qcow2
>> *qcow, struct list_head *qios)
>> void do_qcow2_work(struct work_struct *ws)
>> {
>> struct qcow2 *qcow2 = container_of(ws, struct qcow2, worker);
>> - LIST_HEAD(embedded_qios);
>> LIST_HEAD(deferred_qios);
>> LIST_HEAD(zread_qios);
>> LIST_HEAD(bwrite_qios);
>> @@ -4574,7 +4568,6 @@ void do_qcow2_work(struct work_struct *ws)
>> current->flags |= PF_LOCAL_THROTTLE|PF_MEMALLOC_NOIO;
>> spin_lock_irq(&qcow2->deferred_lock);
>> - list_splice_init(&qcow2->qios[QLIST_EMBEDDED], &embedded_qios);
>> list_splice_init(&qcow2->qios[QLIST_DEFERRED], &deferred_qios);
>> list_splice_init(&qcow2->qios[QLIST_ZREAD], &zread_qios);
>> list_splice_init(&qcow2->qios[QLIST_BMERGE_WRITE], &bwrite_qios);
>> @@ -4585,7 +4578,6 @@ void do_qcow2_work(struct work_struct *ws)
>> list_splice_init(&qcow2->qios[QLIST_SEEK], &seek_qios);
>> spin_unlock_irq(&qcow2->deferred_lock);
>> - process_embedded_qios(qcow2, &embedded_qios, &deferred_qios);
>> process_deferred_qios(qcow2, &deferred_qios);
>> process_compressed_read(&zread_qios, &cow_data_qios);
>> process_backward_merge_write(qcow2, &bwrite_qios);
>> @@ -4710,7 +4702,7 @@ static void qcow2_submit_embedded_qio(struct
>> qcow2_target *tgt, struct qio *qio)
>> if (blk_rq_bytes(rq)) {
>> queue_list_id = QLIST_EMBEDDED;
>> - worker = &qcow2->worker;
>> + worker = &qio->worker;
>> } else {
>> WARN_ON_ONCE(qio->bi_op != REQ_OP_FLUSH);
>> queue_list_id = QLIST_FLUSH;
>> @@ -4726,7 +4718,10 @@ static void qcow2_submit_embedded_qio(struct
>> qcow2_target *tgt, struct qio *qio)
>> qio->qcow2 = qcow2;
>> qio->queue_list_id = queue_list_id;
>> qio->ref_index = ref_index;
>> - list_add_tail(&qio->link, &qcow2->qios[qio->queue_list_id]);
>> + if (queue_list_id == QLIST_EMBEDDED)
>> + qio->state = QIO_STATE_START;
>> + else
>> + list_add_tail(&qio->link, &qcow2->qios[qio->queue_list_id]);
>> }
>> spin_unlock_irqrestore(&qcow2->deferred_lock, flags);
>> @@ -4822,6 +4817,39 @@ static void handle_cleanup_mask(struct qio *qio)
>> }
>> }
>> +static void do_qio_work(struct work_struct *ws)
>> +{
>> + struct qio *qio = container_of(ws, struct qio, worker);
>> + struct qcow2 *qcow2 = qio->qcow2;
>> + struct qcow2_target *tgt = qcow2->tgt;
>> + unsigned int pflags = current->flags;
>> +
>> + current->flags |= PF_LOCAL_THROTTLE|PF_MEMALLOC_NOIO;
>> +
>> + switch (qio->state) {
>> + case QIO_STATE_START: {
>> + LIST_HEAD(deferred_qios);
>> +
>> + prepare_one_embedded_qio(qio, &deferred_qios);
>> + if (list_empty(&deferred_qios))
>> + break;
>> +
>> + spin_lock_irq(&qcow2->deferred_lock);
>> + list_splice_tail(&deferred_qios, &qcow2->qios[QLIST_DEFERRED]);
>> + spin_unlock_irq(&qcow2->deferred_lock);
>> + queue_work(tgt->wq, &qcow2->worker);
>> + break;
>> + }
>> +
>> + default:
>> + qio->bi_status = BLK_STS_IOERR;
>> + qio_endio(qio);
>> + break;
>> + }
>> +
>> + current_restore_flags(pflags, PF_LOCAL_THROTTLE|PF_MEMALLOC_NOIO);
>> +}
>> +
>> struct qio_data_llseek_hole {
>> struct completion compl;
>> struct qio *higher;
>> diff --git a/drivers/md/dm-qcow2.h b/drivers/md/dm-qcow2.h
>> index 3f1d5b5eef26f..ff46cce8587e2 100644
>> --- a/drivers/md/dm-qcow2.h
>> +++ b/drivers/md/dm-qcow2.h
>> @@ -227,8 +227,10 @@ struct qcow2_target {
>> enum {
>> QLIST_EMBEDDED = 0, /*
>> - * List for initial setup embedded qios
>> - * related to prq (in process context).
>> + * Only a queue_list_id, qios are never
>> + * linked to this list: it marks embedded
>> + * qios related to prq, which are set up
>> + * outside main kwork.
>> * This is used only for top qcow2 image.
>> */
>> QLIST_DEFERRED,
>> @@ -245,6 +247,10 @@ enum {
>> QLIST_INVALID = QLIST_COUNT,
>> };
>> +enum {
>> + QIO_STATE_START = 0,
>> +};
>> +
>> struct qcow2 {
>> struct qcow2_target *tgt;
>> struct file *file;
>> @@ -386,6 +392,8 @@ struct qio {
>> struct qcow2 *qcow2;
>> qcow2_endio_t endio_cb;
>> void *endio_cb_data;
>> + struct work_struct worker;
> You add the `worker` field to the struct, but then remove it in patch 7.
> Maybe it would make sense to do it without that field from the start?
For me the chain 'single work -> per-qio work -> per-cpu work batching'
is fine as it is and logically sound. Dropping the middle link is of
course possible but this will require patch squashing. So I would rather
not do that to avoid increasing complexity.
>> + int state;
>> };
>> #define CLU_OFF(qcow2, pos) (pos & (qcow2->clu_size - 1))
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-11-25 9:19 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 11:11 [Devel] [PATCH hci-8.1 v3 0/8] dm-qcow2: per-qio fast path Andrey Zhadchenko
2026-11-13 11:11 ` [Devel] [PATCH hci-8.1 v3 1/8] dm-qcow2: repeat md page lookup if it was inserted in parallel Andrey Zhadchenko
2026-11-13 11:22 ` no-reply
2026-11-13 19:48 ` Konstantin Khorenko
2026-11-13 11:11 ` [Devel] [PATCH hci-8.1 v3 2/8] dm-qcow2: prepare process_one_qio() for fastpath Andrey Zhadchenko
2026-11-13 11:26 ` no-reply
2026-11-13 11:11 ` [Devel] [PATCH hci-8.1 v3 3/8] dm-qcow2: count fast path writes in parse_metadata() Andrey Zhadchenko
2026-11-13 11:27 ` no-reply
2026-11-13 19:48 ` Konstantin Khorenko
2026-11-13 11:11 ` [Devel] [PATCH hci-8.1 v3 4/8] dm-qcow2: add per-qio work infrastructure Andrey Zhadchenko
2026-11-13 11:30 ` no-reply
2026-11-25 7:22 ` Alexander Ivanov
2026-11-25 9:18 ` Andrey Zhadchenko [this message]
2026-11-13 11:11 ` [Devel] [PATCH hci-8.1 v3 5/8] dm-qcow2: implement per-qio fast processing Andrey Zhadchenko
2026-11-13 11:31 ` no-reply
2026-11-13 19:48 ` Konstantin Khorenko
2026-11-13 11:11 ` [Devel] [PATCH hci-8.1 v3 6/8] dm-qcow2: add fast_path module parameter Andrey Zhadchenko
2026-11-13 11:31 ` no-reply
2026-11-13 11:11 ` [Devel] [PATCH hci-8.1 v3 7/8] dm-qcow2: process fast path qios in per-cpu batches on a workqueue Andrey Zhadchenko
2026-11-13 11:33 ` no-reply
2026-11-13 19:48 ` Konstantin Khorenko
2026-11-13 11:11 ` [Devel] [PATCH hci-8.1 v3 8/8] dm-qcow2: declare DM_TARGET_NOWAIT Andrey Zhadchenko
2026-11-13 11:33 ` no-reply
2026-11-13 19:48 ` [Devel] [PATCH hci-8.1 v3 0/8] dm-qcow2: per-qio fast path Konstantin Khorenko
2026-11-25 0:14 ` Andrey Zhadchenko
2026-11-25 12:10 ` Alexander Ivanov
2026-11-27 17:50 ` 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=aae97b02-b1cc-4e3a-91ea-23d185dca2b6@virtuozzo.com \
--to=andrey.zhadchenko@virtuozzo.com \
--cc=alexander.ivanov@virtuozzo.com \
--cc=devel@openvz.org \
--cc=khorenko@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