[Devel] [RFC PATCH vz9 v6 62/62] dm-ploop: rework logic in pio processing

Alexander Atanasov alexander.atanasov at virtuozzo.com
Fri Dec 6 00:56:35 MSK 2024


improve how and when we wait for pios to complete
before proceeding with next pios.
force writing of pending md pages in case we have a sync pios.
remove now unused functions.

https://virtuozzo.atlassian.net/browse/VSTOR-91821
Signed-off-by: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
---
 drivers/md/dm-ploop-map.c | 91 ++++++++-------------------------------
 1 file changed, 19 insertions(+), 72 deletions(-)

diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index 9da996935945..a4b101d8d737 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -1610,17 +1610,6 @@ static void ploop_process_one_delta_cow(struct ploop *ploop, struct pio *aux_pio
 	}
 }
 
-static void ploop_process_delta_cow(struct ploop *ploop,
-				    struct llist_node *cow_llist)
-{
-	struct llist_node *pos, *t;
-	struct pio *aux_pio;
-
-	llist_for_each_safe(pos, t, cow_llist) {
-		aux_pio = list_entry((struct list_head *)pos, typeof(*aux_pio), list);
-		ploop_process_one_delta_cow(ploop, aux_pio);
-	}
-}
 /*
  * This allocates a new clu (if clu wb is not pending yet),
  * or tries to attach a bio to a planned page index wb.
@@ -1884,20 +1873,6 @@ static void ploop_prepare_embedded_pios(struct ploop *ploop,
 	}
 }
 
-static void ploop_process_deferred_pios(struct ploop *ploop,
-					struct llist_head *pios)
-{
-	struct pio *pio;
-
-	struct llist_node *pos, *t;
-
-	llist_for_each_safe(pos, t, pios->first) {
-		pio = list_entry((struct list_head *)pos, typeof(*pio), list);
-		INIT_LIST_HEAD(&pio->list); /* until type is changed */
-		ploop_process_one_deferred_bio(ploop, pio);
-	}
-}
-
 static void ploop_process_one_discard_pio(struct ploop *ploop, struct pio *pio)
 {
 	bool bat_update_prepared = false;
@@ -1954,39 +1929,10 @@ static void ploop_process_one_discard_pio(struct ploop *ploop, struct pio *pio)
 	ploop_pio_endio(pio);
 }
 
-static void ploop_process_discard_pios(struct ploop *ploop,
-				       struct llist_node *discpios)
-{
-	struct pio *pio;
-	struct llist_node *pos, *t;
-
-	llist_for_each_safe(pos, t, discpios) {
-		pio = list_entry((struct list_head *)pos, typeof(*pio), list);
-		INIT_LIST_HEAD(&pio->list);
-		ploop_process_one_discard_pio(ploop, pio);
-	}
-}
-
-static void ploop_process_resubmit_pios(struct ploop *ploop,
-					struct llist_node *llpios)
-{
-	struct pio *pio;
-	struct llist_node *pos, *t;
-
-	llist_for_each_safe(pos, t, llpios) {
-		pio = list_entry((struct list_head *)pos, typeof(*pio), list);
-		pio->queue_list_id = PLOOP_LIST_INVALID;
-		INIT_LIST_HEAD(&pio->list); /* Until type is changed */
-		ploop_submit_rw_mapped(ploop, pio);
-	}
-}
-
-#ifdef USE_RUNNERS
 static inline int ploop_runners_have_pending(struct ploop *ploop)
 {
 	return atomic_read(&ploop->kt_worker->inflight_pios);
 }
-#endif
 
 static inline int ploop_submit_metadata_writeback(struct ploop *ploop, int force,
 						  unsigned long old_flags)
@@ -2087,11 +2033,8 @@ static inline int ploop_runners_add_work_list(struct ploop *ploop, struct llist_
 	return 0;
 }
 
-#endif
-
 void do_ploop_run_work(struct ploop *ploop)
 {
-	struct ploop_worker *wrkr = ploop->kt_worker;
 	LLIST_HEAD(deferred_pios);
 	struct llist_node *llembedded_pios;
 	struct llist_node *lldeferred_pios;
@@ -2100,8 +2043,8 @@ void do_ploop_run_work(struct ploop *ploop)
 	struct llist_node *llresubmit;
 	struct llist_node *llflush_pios;
 	unsigned int old_flags = current->flags;
-	struct llist_node *pos, *t;
 	int npios;
+	int force_md_update;
 
 	current->flags |= PF_IO_THREAD|PF_LOCAL_THROTTLE|PF_MEMALLOC_NOIO;
 
@@ -2117,8 +2060,7 @@ void do_ploop_run_work(struct ploop *ploop)
 		ploop_runners_add_work_list(ploop, lldeferred_pios);
 
 	if (llembedded_pios)
-		ploop_prepare_embedded_pios(ploop, llist_reverse_order(llembedded_pios),
-					    &deferred_pios);
+		ploop_prepare_embedded_pios(ploop, llembedded_pios, &deferred_pios);
 
 	smp_wmb(); /* */
 	llflush_pios = llist_del_all(&ploop->pios[PLOOP_LIST_FLUSH]);
@@ -2134,23 +2076,28 @@ void do_ploop_run_work(struct ploop *ploop)
 	if (llcow_pios)
 		ploop_runners_add_work_list(ploop, llcow_pios);
 
-	/* wait for all pios to be executed before metadata updates */
+	/*
+	 * put stick in the wheel - wait for all pios to be executed before doing metadata
+	 * we could gain a bit more iops if we can skip this wait but for now we can not
+	 */
 	current->flags = old_flags;
-	wait_event_interruptible(ploop->dispatcher_wq_data, (!ploop_runners_have_pending(ploop)));
+	wait_event_interruptible(ploop->dispatcher_wq_data,
+				 (!ploop_runners_have_pending(ploop)));
 	current->flags |= PF_IO_THREAD|PF_LOCAL_THROTTLE|PF_MEMALLOC_NOIO;
 
 	/* if we have a flush we must sync md data too */
-	npios = ploop_submit_metadata_writeback(ploop, !!llflush_pios | ploop->force_md_writeback, old_flags);
+	force_md_update = !!llflush_pios | ploop->force_md_writeback;
+	npios = ploop_submit_metadata_writeback(ploop, force_md_update, old_flags);
 
-	if (llflush_pios) {
-		if (npios) {
-			/* wait for metadata writeback to complete */
-			current->flags = old_flags;
-			/* First wait all pios to be processed */
-			wait_event_interruptible(ploop->dispatcher_wq_data,
-						 (!ploop_runners_have_pending(ploop)));
-			current->flags |= PF_IO_THREAD|PF_LOCAL_THROTTLE|PF_MEMALLOC_NOIO;
-		}
+	if (npios) {
+		/* wait for metadata writeback to complete */
+		current->flags = old_flags;
+		/* First wait all pios to be processed */
+		wait_event_interruptible(ploop->dispatcher_wq_data,
+					 (!ploop_runners_have_pending(ploop)));
+		current->flags |= PF_IO_THREAD|PF_LOCAL_THROTTLE|PF_MEMALLOC_NOIO;
+	}
+	if (llflush_pios || npios) {
 		/* Now process fsync pios after we have done all other */
 		npios = process_ploop_fsync_work(ploop, llflush_pios);
 		/* Since dispatcher is single thread no other work can be queued */
-- 
2.43.0



More information about the Devel mailing list