From: "Denis V. Lunev" <den@openvz.org>
To: andrey.zhadchenko@virtuozzo.com, alexander.ivanov@virtuozzo.com,
vasileios.almpanis@virtuozzo.com
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.2 v2 1/8] dm-qcow2: drop the qio argument of endio callbacks
Date: Mon, 23 Nov 2026 16:36:33 +0100 [thread overview]
Message-ID: <20261123153640.128227-2-den@openvz.org> (raw)
In-Reply-To: <20261123153640.128227-1-den@openvz.org>
From: Denis V. Lunev <den@openvz.org>
The endio callbacks get the qio that completes, but only qrq_endio()
uses it, and that qio is embedded in the qrq it already receives. The
other callbacks ignore it, and their direct callers pass NULL.
Drop the argument, so that the next patch can free a qio before its
callback runs. qrq_endio() finds the embedded qio behind its qrq.
https://virtuozzo.atlassian.net/browse/VSTOR-156036
Feature: dm-qcow2: block device over QCOW2 files driver
Signed-off-by: Denis V. Lunev <den@openvz.org>
---
drivers/md/dm-qcow2-cmd.c | 2 +-
drivers/md/dm-qcow2-map.c | 34 +++++++++++++++++-----------------
drivers/md/dm-qcow2.h | 4 +---
3 files changed, 19 insertions(+), 21 deletions(-)
diff --git a/drivers/md/dm-qcow2-cmd.c b/drivers/md/dm-qcow2-cmd.c
index 00b33ccaab10..47a002320e6b 100644
--- a/drivers/md/dm-qcow2-cmd.c
+++ b/drivers/md/dm-qcow2-cmd.c
@@ -42,7 +42,7 @@ int qcow2_inflight_ref_switch(struct qcow2_target *tgt)
return 0;
}
-static void service_qio_endio(struct qcow2_target *tgt, struct qio *qio,
+static void service_qio_endio(struct qcow2_target *tgt,
void *data, blk_status_t status)
{
blk_status_t *status_ptr = data;
diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c
index 853e7a1230ee..90e699050131 100644
--- a/drivers/md/dm-qcow2-map.c
+++ b/drivers/md/dm-qcow2-map.c
@@ -418,7 +418,7 @@ static void do_qio_endio(struct qio *qio)
qio->ref_index = REF_INDEX_INVALID;
/* Note, that this may free qio or its container memory */
if (endio_cb)
- endio_cb(tgt, qio, endio_cb_data, qio->bi_status);
+ endio_cb(tgt, endio_cb_data, qio->bi_status);
if (ref_index < REF_INDEX_INVALID)
qcow2_ref_dec(tgt, ref_index);
@@ -474,7 +474,7 @@ static void end_qios(struct list_head *qio_list, blk_status_t status)
}
}
-static void qio_chain_endio(struct qcow2_target *tgt, struct qio *qio,
+static void qio_chain_endio(struct qcow2_target *tgt,
void *parent_ptr, blk_status_t bi_status)
{
struct qio *parent = parent_ptr;
@@ -2861,7 +2861,7 @@ static int prepare_l1l2_replace(struct qcow2 *qcow2, struct qio *qio,
map->cow_clu_end, L2_LEVEL);
}
-static void backward_merge_write_complete(struct qcow2_target *tgt, struct qio *unused,
+static void backward_merge_write_complete(struct qcow2_target *tgt,
void *qio_ptr, blk_status_t bi_status)
{
struct qio *qio = qio_ptr;
@@ -2886,7 +2886,7 @@ static void backward_merge_write_complete(struct qcow2_target *tgt, struct qio *
qcow2_dispatch_qios(qcow2, qio, NULL);
}
-static void backward_merge_read_complete(struct qcow2_target *tgt, struct qio *unused,
+static void backward_merge_read_complete(struct qcow2_target *tgt,
void *qio_ptr, blk_status_t bi_status)
{
struct qio *qio = qio_ptr;
@@ -2902,7 +2902,7 @@ static void backward_merge_read_complete(struct qcow2_target *tgt, struct qio *u
qcow2_dispatch_qios(qcow2, qio, NULL);
}
-static void requeue_if_ok(struct qcow2_target *tgt, struct qio *unused,
+static void requeue_if_ok(struct qcow2_target *tgt,
void *qio_ptr, blk_status_t bi_status)
{
struct qio *qio = qio_ptr;
@@ -3108,7 +3108,7 @@ static void perform_rw_mapped(struct qcow2_map *map, struct qio *qio)
map_and_submit_rw(qcow2, map->data_clu_pos, qio);
}
-static void cow_read_endio(struct qcow2_target *tgt, struct qio *unused,
+static void cow_read_endio(struct qcow2_target *tgt,
void *qio_ptr, blk_status_t bi_status)
{
@@ -3333,7 +3333,7 @@ static int prepare_zcow_slices(void *buf, struct qio *qio)
return 0;
}
-static void compressed_read_endio(struct qcow2_target *tgt, struct qio *unused,
+static void compressed_read_endio(struct qcow2_target *tgt,
void *qio_ptr, blk_status_t bi_status)
{
@@ -3425,9 +3425,9 @@ static void submit_read_compressed(struct qcow2_map *map, struct qio *qio,
*/
if (merge) {
dec_wpc_readers(qcow2, l2_md);
- backward_merge_read_complete(tgt, NULL, qio, BLK_STS_OK);
+ backward_merge_read_complete(tgt, qio, BLK_STS_OK);
} else {
- cow_read_endio(tgt, NULL, qio, BLK_STS_OK);
+ cow_read_endio(tgt, qio, BLK_STS_OK);
}
qcow2_free_qio(read_qio, tgt->qio_pool);
return;
@@ -3445,7 +3445,7 @@ static void submit_read_compressed(struct qcow2_map *map, struct qio *qio,
__submit_rw_mapped(qcow2, read_qio, nr_pages);
}
-static void sliced_cow_read_complete(struct qcow2_target *tgt, struct qio *read_qio,
+static void sliced_cow_read_complete(struct qcow2_target *tgt,
void *qio_ptr, blk_status_t bi_status)
{
struct qio *qio = qio_ptr;
@@ -3522,7 +3522,7 @@ static void submit_read_sliced_clu(struct qcow2_map *map, struct qio *qio,
if (!nr_segs) { /* Full overwrite */
qio->data = NULL; /* qvec */
- endio_cb(qcow2->tgt, NULL, qio, BLK_STS_OK);
+ endio_cb(qcow2->tgt, qio, BLK_STS_OK);
goto out;
}
@@ -4189,8 +4189,7 @@ static void process_compressed_read(struct list_head *read_list,
}
if (backward_merge_qio(qcow2, qio)) {
- backward_merge_read_complete(qcow2->tgt, NULL, qio,
- BLK_STS_OK);
+ backward_merge_read_complete(qcow2->tgt, qio, BLK_STS_OK);
continue;
}
@@ -4281,7 +4280,7 @@ static void process_backward_merge_write(struct qcow2 *qcow2, struct list_head *
}
}
-static void cow_data_write_endio(struct qcow2_target *tgt, struct qio *unused,
+static void cow_data_write_endio(struct qcow2_target *tgt,
void *qio_ptr, blk_status_t bi_status)
{
@@ -4329,7 +4328,7 @@ static void submit_cow_data_write(struct qcow2 *qcow2, struct qio *qio, loff_t p
__submit_rw_mapped(qcow2, write_qio, clu_size >> PAGE_SHIFT);
}
-static void sliced_cow_data_write_complete(struct qcow2_target *tgt, struct qio *unused,
+static void sliced_cow_data_write_complete(struct qcow2_target *tgt,
void *qio_ptr, blk_status_t bi_status)
{
@@ -4651,10 +4650,11 @@ static bool qcow2_try_delay_enospc(struct qcow2_target *tgt, struct qcow2_rq *qr
return delayed;
}
-static void qrq_endio(struct qcow2_target *tgt, struct qio *qio,
+static void qrq_endio(struct qcow2_target *tgt,
void *qrq_ptr, blk_status_t bi_status)
{
struct qcow2_rq *qrq = qrq_ptr;
+ struct qio *qio = (void *)qrq + sizeof(*qrq);
struct request *rq = qrq->rq;
if (qrq->bvec)
@@ -4838,7 +4838,7 @@ static void seek_qio_set_sector(struct qio *qio, sector_t bi_sector)
}
/* A failed md page read ends the qios waiting for it */
-static void seek_qio_endio(struct qcow2_target *tgt, struct qio *qio,
+static void seek_qio_endio(struct qcow2_target *tgt,
void *data, blk_status_t bi_status)
{
complete(&((struct qio_data_llseek_hole *)data)->compl);
diff --git a/drivers/md/dm-qcow2.h b/drivers/md/dm-qcow2.h
index 4acddbe7c95f..9c41e1a48e09 100644
--- a/drivers/md/dm-qcow2.h
+++ b/drivers/md/dm-qcow2.h
@@ -344,9 +344,7 @@ struct qcow2_rq {
struct bio_vec *bvec;
};
-struct qio;
-typedef void (*qcow2_endio_t)(struct qcow2_target *, struct qio *,
- void *, blk_status_t);
+typedef void (*qcow2_endio_t)(struct qcow2_target *, void *, blk_status_t);
struct qio {
struct bvec_iter bi_iter;
--
2.55.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-11-23 15:38 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 15:36 [Devel] [PATCH hci-8.2 v2 0/8] dm-qcow2: fix image I/O completions using a freed target Denis V. Lunev
2026-11-23 15:36 ` Denis V. Lunev [this message]
2026-11-23 15:40 ` [Devel] [PATCH hci-8.2 v2 1/8] dm-qcow2: drop the qio argument of endio callbacks no-reply
2026-11-23 15:36 ` [Devel] [PATCH hci-8.2 v2 2/8] dm-qcow2: fix do_qio_endio() freeing a qio into a destroyed pool Denis V. Lunev
2026-11-23 15:41 ` no-reply
2026-11-23 15:36 ` [Devel] [PATCH hci-8.2 v2 3/8] dm-qcow2: fix queue_work() after the target or image is freed Denis V. Lunev
2026-11-23 15:42 ` no-reply
2026-11-23 15:36 ` [Devel] [PATCH hci-8.2 v2 4/8] dm-qcow2: fix service_qio_endio() waking a freed target Denis V. Lunev
2026-11-23 15:43 ` no-reply
2026-11-23 15:36 ` [Devel] [PATCH hci-8.2 v2 5/8] dm-qcow2: fix qcow2_flush_deferred_activity() skipping a running timer Denis V. Lunev
2026-11-23 15:45 ` no-reply
2026-11-23 15:36 ` [Devel] [PATCH hci-8.2 v2 6/8] dm-qcow2: stop slow_wb_timer and flush the workers before freeing an image Denis V. Lunev
2026-11-23 15:45 ` no-reply
2026-11-23 15:36 ` [Devel] [PATCH hci-8.2 v2 7/8] dm-qcow2: cancel the backward merge before destroying the workqueue Denis V. Lunev
2026-11-23 15:47 ` no-reply
2026-11-23 15:36 ` [Devel] [PATCH hci-8.2 v2 8/8] dm-qcow2: flush the backward merge work before freeing the target Denis V. Lunev
2026-11-23 15:48 ` no-reply
2026-11-24 10:57 ` [Devel] [PATCH hci-8.2 v2 0/8] dm-qcow2: fix image I/O completions using a freed target Alexander Ivanov
2026-11-30 16:14 ` 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=20261123153640.128227-2-den@openvz.org \
--to=den@openvz.org \
--cc=alexander.ivanov@virtuozzo.com \
--cc=andrey.zhadchenko@virtuozzo.com \
--cc=devel@openvz.org \
--cc=vasileios.almpanis@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 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.