[Devel] [PATCH RHEL8 COMMIT] ploop: Use initial pio for COW

Konstantin Khorenko khorenko at virtuozzo.com
Tue Jun 29 16:08:12 MSK 2021


The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.vz8.5.50
------>
commit 27438251a9d49027e2284d6e7e23551524eee766
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Tue Jun 29 16:08:12 2021 +0300

    ploop: Use initial pio for COW
    
    We don't have to allocate a new pio inside cow,
    which just owns a lock.
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
    
    ==========================
    Preparation for #PSBM-124550 (part 2)
    
    Kirill Tkhai (14):
          ploop: Kill "get_delta_name" alias
          ploop: Use initial pio for COW
          ploop: Rename cluster_pio into aux_pio
          ploop: Shorten variable names
          ploop: Rename in submit_cluster_write()
          ploop: Use defer_pios() instead of manual code
          ploop: Use array of pios instead of separate lists
          ploop: Generalize dispatch_pios usage
          ploop: Unify process_delta_wb()
          ploop: Remove unused struct member
          ploop: Rename page_nr
          ploop: Return md page from ploop_bat_entries()
          ploop: Kill dead check in ploop_attach_end_action()
          ploop: Delay bio if md page is BUSY
---
 drivers/md/dm-ploop-map.c | 50 ++++++++++++++++++++++-------------------------
 drivers/md/dm-ploop.h     |  5 +----
 2 files changed, 24 insertions(+), 31 deletions(-)

diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index d4bd646ef1d9..15654d8bcf99 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -563,18 +563,31 @@ static void ploop_discard_index_pio_end(struct ploop *ploop, struct pio *pio)
 	del_cluster_lk(ploop, pio);
 }
 
+static void queue_or_fail(struct ploop *ploop, int err, void *data)
+{
+	struct pio *pio = data;
+
+	/* FIXME: do we use BLK_STS_AGAIN? */
+	if (err && err != BLK_STS_AGAIN) {
+		pio->bi_status = errno_to_blk_status(err);
+		pio_endio(pio);
+	} else {
+		defer_pios(ploop, pio, NULL);
+	}
+}
+
 static void complete_cow(struct ploop_cow *cow, blk_status_t bi_status)
 {
 	unsigned int dst_cluster = cow->dst_cluster;
 	struct pio *cluster_pio = cow->cluster_pio;
 	struct ploop *ploop = cow->ploop;
 	unsigned long flags;
-	struct pio *aux_pio;
+	struct pio *cow_pio;
 
 	WARN_ON_ONCE(!list_empty(&cluster_pio->list));
-	aux_pio = &cow->aux_pio;
+	cow_pio = cow->cow_pio;
 
-	del_cluster_lk(ploop, aux_pio);
+	del_cluster_lk(ploop, cow_pio);
 
 	if (dst_cluster != BAT_ENTRY_NONE && bi_status != BLK_STS_OK) {
 		read_lock_irqsave(&ploop->bat_rwlock, flags);
@@ -582,8 +595,7 @@ static void complete_cow(struct ploop_cow *cow, blk_status_t bi_status)
 		read_unlock_irqrestore(&ploop->bat_rwlock, flags);
 	}
 
-	if (cow->end_fn)
-		cow->end_fn(ploop, blk_status_to_errno(bi_status), cow->data);
+	queue_or_fail(ploop, blk_status_to_errno(bi_status), cow_pio);
 
 	queue_work(ploop->wq, &ploop->worker);
 	free_pio_with_pages(ploop, cow->cluster_pio);
@@ -1154,7 +1166,7 @@ static bool postpone_if_cluster_locked(struct ploop *ploop, struct pio *pio,
 
 static int submit_cluster_cow(struct ploop *ploop, unsigned int level,
 			      unsigned int cluster, unsigned int dst_cluster,
-			      void (*end_fn)(struct ploop *, int, void *), void *data)
+			      struct pio *cow_pio)
 {
 	struct ploop_cow *cow = NULL;
 	struct pio *pio = NULL;
@@ -1172,11 +1184,9 @@ static int submit_cluster_cow(struct ploop *ploop, unsigned int level,
 	cow->ploop = ploop;
 	cow->dst_cluster = BAT_ENTRY_NONE;
 	cow->cluster_pio = pio;
-	cow->end_fn = end_fn;
-	cow->data = data;
+	cow->cow_pio = cow_pio;
 
-	init_pio(ploop, REQ_OP_WRITE, &cow->aux_pio);
-	add_cluster_lk(ploop, &cow->aux_pio, cluster);
+	add_cluster_lk(ploop, cow_pio, cluster);
 
 	/* Stage #0: read secondary delta full cluster */
 	map_and_submit_rw(ploop, dst_cluster, pio, level);
@@ -1188,24 +1198,10 @@ static int submit_cluster_cow(struct ploop *ploop, unsigned int level,
 	return -ENOMEM;
 }
 
-static void queue_or_fail(struct ploop *ploop, int err, void *data)
-{
-	struct pio *pio = data;
-
-	/* FIXME: do we use BLK_STS_AGAIN? */
-	if (err && err != BLK_STS_AGAIN) {
-		pio->bi_status = errno_to_blk_status(err);
-		pio_endio(pio);
-	} else {
-		defer_pios(ploop, pio, NULL);
-	}
-}
-
 static void initiate_cluster_cow(struct ploop *ploop, unsigned int level,
 		unsigned int cluster, unsigned int dst_cluster, struct pio *pio)
 {
-	if (!submit_cluster_cow(ploop, level, cluster, dst_cluster,
-				queue_or_fail, pio))
+	if (!submit_cluster_cow(ploop, level, cluster, dst_cluster, pio))
 		return;
 
 	pio->bi_status = BLK_STS_RESOURCE;
@@ -1238,8 +1234,8 @@ static void submit_cluster_write(struct ploop_cow *cow)
 static void submit_cow_index_wb(struct ploop_cow *cow,
 				struct ploop_index_wb *piwb)
 {
-	struct pio *aux_pio = &cow->aux_pio;
-	unsigned int cluster = aux_pio->cluster;
+	struct pio *cow_pio = cow->cow_pio;
+	unsigned int cluster = cow_pio->cluster;
 	struct ploop *ploop = cow->ploop;
 	unsigned int page_nr;
 	map_index_t *to;
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index cf2680d55ddf..4e132156ff90 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -256,10 +256,7 @@ struct ploop_cow {
 	struct pio *cluster_pio;
 	unsigned int dst_cluster;
 
-	struct pio aux_pio;
-
-	void (*end_fn)(struct ploop *, int, void *);
-	void *data; /* Second argument of end_fn */
+	struct pio *cow_pio;
 };
 
 extern bool ignore_signature_disk_in_use;


More information about the Devel mailing list