[Devel] [PATCH hci-8.2 v2 1/8] dm-qcow2: drop the qio argument of endio callbacks
Denis V. Lunev
den at openvz.org
Mon Nov 23 18:36:33 MSK 2026
From: Denis V. Lunev <den at 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 at 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
More information about the Devel
mailing list