[Devel] [PATCH RHEL8 COMMIT] dm-qcow2: Optional allocation of pages in alloc_qvec_with_pages()

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

    dm-qcow2: Optional allocation of pages in alloc_qvec_with_pages()
    
    Add a parameter skipping pages allocation. Bvec is still alloced.
    
    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 | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c
index 4a8be1c2e810..6fa1272bd911 100644
--- a/drivers/md/dm-qcow2-map.c
+++ b/drivers/md/dm-qcow2-map.c
@@ -802,15 +802,15 @@ static void free_qvec_with_pages(struct qcow2_bvec *qvec)
 	}
 }
 
-static struct qcow2_bvec *alloc_qvec_with_pages(ushort nr_pages)
+static struct qcow2_bvec *alloc_qvec_with_pages(ushort nr_pages, bool wants_pages)
 {
 	struct qcow2_bvec *qvec;
 	struct bio_vec *bvec;
 	int i;
 
 	qvec = alloc_qvec_with_data(nr_pages, NULL, 0);
-	if (!qvec)
-		return NULL;
+	if (!qvec || !wants_pages)
+		return qvec;
 
 	bvec = qvec->bvec;
 	for (i = 0; i < nr_pages; i++) {
@@ -829,7 +829,8 @@ static struct qcow2_bvec *alloc_qvec_with_pages(ushort nr_pages)
 }
 
 static struct qio *alloc_qio_with_qvec(struct qcow2 *qcow2, u32 nr_pages,
-			    unsigned int bi_op, struct qcow2_bvec **qvec)
+				       unsigned int bi_op, bool wants_pages,
+				       struct qcow2_bvec **qvec)
 {
 	struct qcow2_target *tgt = qcow2->tgt;
 	struct qio *qio;
@@ -838,7 +839,7 @@ static struct qio *alloc_qio_with_qvec(struct qcow2 *qcow2, u32 nr_pages,
 	if (!qio)
 		return NULL;
 
-	*qvec = alloc_qvec_with_pages(nr_pages);
+	*qvec = alloc_qvec_with_pages(nr_pages, wants_pages);
 	if (!*qvec) {
 		free_qio(qio, tgt->qio_pool);
 		return NULL;
@@ -2807,7 +2808,7 @@ static void submit_read_whole_cow_clu(struct qcow2_map *map, struct qio *qio)
 	WARN_ON_ONCE(map->level & L2_LEVEL);
 
 	nr_pages = clu_size >> PAGE_SHIFT;
-	qvec = alloc_qvec_with_pages(nr_pages);
+	qvec = alloc_qvec_with_pages(nr_pages, true);
 	if (!qvec) {
 		qio->bi_status = BLK_STS_RESOURCE;
 		qio_endio(qio); /* Frees ext */
@@ -3003,7 +3004,7 @@ static void submit_read_compressed(struct qcow2_map *map, struct qio *qio,
 		qio->ext->cow_segs = nr_segs;
 	}
 
-	qvec = alloc_qvec_with_pages(nr_alloc);
+	qvec = alloc_qvec_with_pages(nr_alloc, true);
 	/* COW may already allocate qio->ext */
 	if (!qvec || (!qio->ext && alloc_qio_ext(qio) < 0)) {
 		free_qvec_with_pages(qvec);
@@ -3119,7 +3120,7 @@ static void submit_read_sliced_clu(struct qcow2_map *map, struct qio *qio,
 		goto out;
 	}
 
-	read_qio = alloc_qio_with_qvec(qcow2, nr_pages, REQ_OP_READ, &qvec);
+	read_qio = alloc_qio_with_qvec(qcow2, nr_pages, REQ_OP_READ, true, &qvec);
 	if (!read_qio)
 		goto err_alloc;
 	read_qio->flags |= QIO_FREE_ON_ENDIO_FL;


More information about the Devel mailing list