[Devel] [PATCH RHEL8 COMMIT] dm-qcow2: Use submit_rw_mapped() in submit_cow_data_write()

Konstantin Khorenko khorenko at virtuozzo.com
Fri Aug 13 15:26:55 MSK 2021


The commit is pushed to "branch-rh8-4.18.0-305.3.1.vz8.7.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-305.3.1.vz8.7.6
------>
commit 6be3991157063b8ccec45deb3c997070d73af2ac
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Fri Aug 13 15:26:55 2021 +0300

    dm-qcow2: Use submit_rw_mapped() in submit_cow_data_write()
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
    
    ====================
    It's a preparation for https://jira.sw.ru/browse/PSBM-132049
---
 drivers/md/dm-qcow2-map.c | 41 ++++++++++++++++++++++++++++-------------
 1 file changed, 28 insertions(+), 13 deletions(-)

diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c
index fa9a73a0591a..479a5b2411e6 100644
--- a/drivers/md/dm-qcow2-map.c
+++ b/drivers/md/dm-qcow2-map.c
@@ -3643,17 +3643,17 @@ static void process_backward_merge_write(struct qcow2 *qcow2, struct list_head *
 	}
 }
 
-static void cow_data_write_complete(struct qio *qio)
+static void cow_data_write_endio(struct qcow2_target *tgt, struct qio *unused,
+				 void *qio_ptr, blk_status_t bi_status)
+
 {
+	struct qio *qio = qio_ptr;
 	struct qcow2 *qcow2 = qio->qcow2;
-	int ret = qio->ret;
 
 	BUG_ON(!qio->ext);
 
-	if (ret > 0 && ret != qcow2->clu_size)
-		ret = -EIO;
-	if (ret < 0) {
-		qio->bi_status = errno_to_blk_status(ret);
+	if (unlikely(bi_status)) {
+		qio->bi_status = bi_status;
 		qio_endio(qio);
 	} else {
 		qio->queue_list_id = QLIST_COW_INDEXES;
@@ -3663,17 +3663,32 @@ static void cow_data_write_complete(struct qio *qio)
 
 static void submit_cow_data_write(struct qcow2 *qcow2, struct qio *qio, loff_t pos)
 {
-	u32 nr_segs, clu_size = qcow2->clu_size;
+	struct qcow2_target *tgt = qcow2->tgt;
 	struct qcow2_bvec *qvec = qio->data;
-	struct iov_iter iter;
+	u32 clu_size = qcow2->clu_size;
+	struct qio *write_qio;
 
-	nr_segs = clu_size >> PAGE_SHIFT;
-	WARN_ON_ONCE(qvec->nr_pages < nr_segs);
+	write_qio = alloc_qio(tgt->qio_pool, true);
+	if (!write_qio) {
+		qio->bi_status = BLK_STS_RESOURCE;
+		qio_endio(qio);
+		return;
+	}
+	init_qio(write_qio, REQ_OP_WRITE, qcow2);
+
+	write_qio->flags |= QIO_FREE_ON_ENDIO_FL;
+	write_qio->bi_io_vec = qvec->bvec;
+	write_qio->bi_iter.bi_size = clu_size;
+	write_qio->bi_iter.bi_idx = 0;
+	write_qio->bi_iter.bi_bvec_done = 0;
+	write_qio->endio_cb = cow_data_write_endio;
+	write_qio->endio_cb_data = qio;
+	write_qio->complete = data_rw_complete;
+	write_qio->data = NULL;
 
-	iov_iter_bvec(&iter, WRITE, qvec->bvec, nr_segs, clu_size);
-	qio->complete = cow_data_write_complete;
+	write_qio->bi_iter.bi_sector = to_sector(pos);
 
-	call_rw_iter(qcow2->file, pos, WRITE, &iter, qio);
+	submit_rw_mapped(qcow2, write_qio);
 }
 
 static void sliced_cow_data_write_complete(struct qcow2_target *tgt, struct qio *unused,


More information about the Devel mailing list