[Devel] [PATCH RHEL8 COMMIT] dm-qcow2: Generalize alloc_clu_read_qio()

Konstantin Khorenko khorenko at virtuozzo.com
Fri Aug 13 15:26:51 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 26a8f56f5c261763d6e915b1a8d5d78459607e35
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Fri Aug 13 15:26:51 2021 +0300

    dm-qcow2: Generalize alloc_clu_read_qio()
    
    ... to allow REQ_OP_WRITE and move this function.
    
    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 | 50 +++++++++++++++++++++++------------------------
 1 file changed, 25 insertions(+), 25 deletions(-)

diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c
index a7b801166546..4a8be1c2e810 100644
--- a/drivers/md/dm-qcow2-map.c
+++ b/drivers/md/dm-qcow2-map.c
@@ -828,6 +828,30 @@ static struct qcow2_bvec *alloc_qvec_with_pages(ushort nr_pages)
 	return NULL;
 }
 
+static struct qio *alloc_qio_with_qvec(struct qcow2 *qcow2, u32 nr_pages,
+			    unsigned int bi_op, struct qcow2_bvec **qvec)
+{
+	struct qcow2_target *tgt = qcow2->tgt;
+	struct qio *qio;
+
+	qio = alloc_qio(tgt->qio_pool, true);
+	if (!qio)
+		return NULL;
+
+	*qvec = alloc_qvec_with_pages(nr_pages);
+	if (!*qvec) {
+		free_qio(qio, tgt->qio_pool);
+		return NULL;
+	}
+
+	init_qio(qio, bi_op, qcow2);
+	qio->bi_io_vec = (*qvec)->bvec;
+	qio->bi_iter.bi_size = nr_pages << PAGE_SHIFT;
+	qio->bi_iter.bi_idx = 0;
+	qio->bi_iter.bi_bvec_done = 0;
+	return qio;
+}
+
 static void free_wbd(struct wb_desc *wbd)
 {
 	if (wbd) {
@@ -2540,30 +2564,6 @@ static int prepare_l1l2_cow(struct qcow2 *qcow2, struct qio *qio,
 				  map->cow_clu_end, L2_LEVEL);
 }
 
-static struct qio *alloc_clu_read_qio(struct qcow2 *qcow2, u32 nr_pages,
-				      struct qcow2_bvec **qvec)
-{
-	struct qcow2_target *tgt = qcow2->tgt;
-	struct qio *qio;
-
-	qio = alloc_qio(tgt->qio_pool, true);
-	if (!qio)
-		return NULL;
-
-	*qvec = alloc_qvec_with_pages(nr_pages);
-	if (!*qvec) {
-		free_qio(qio, tgt->qio_pool);
-		return NULL;
-	}
-
-	init_qio(qio, REQ_OP_READ, qcow2);
-	qio->bi_io_vec = (*qvec)->bvec;
-	qio->bi_iter.bi_size = nr_pages << PAGE_SHIFT;
-	qio->bi_iter.bi_idx = 0;
-	qio->bi_iter.bi_bvec_done = 0;
-	return qio;
-}
-
 static void backward_merge_write_complete(struct qcow2_target *tgt, struct qio *unused,
 					  void *qio_ptr, blk_status_t bi_status)
 {
@@ -3119,7 +3119,7 @@ static void submit_read_sliced_clu(struct qcow2_map *map, struct qio *qio,
 		goto out;
 	}
 
-	read_qio = alloc_clu_read_qio(qcow2, nr_pages, &qvec);
+	read_qio = alloc_qio_with_qvec(qcow2, nr_pages, REQ_OP_READ, &qvec);
 	if (!read_qio)
 		goto err_alloc;
 	read_qio->flags |= QIO_FREE_ON_ENDIO_FL;


More information about the Devel mailing list