[Devel] [RFC PATCH vz9 v6 30/62] dm-ploop: BAT use only one list for writeback

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


remove the wb_batch_list_prio, use only wb_batch_list and
use the md high_prio flag for immediate submission.

https://virtuozzo.atlassian.net/browse/VSTOR-91817
Signed-off-by: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
---
 drivers/md/dm-ploop-map.c    | 70 +++++++++++++++---------------------
 drivers/md/dm-ploop-target.c |  1 -
 drivers/md/dm-ploop.h        |  1 -
 3 files changed, 29 insertions(+), 43 deletions(-)

diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index 55c10d21d8eb..4d64c98d2bc1 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -577,10 +577,6 @@ static void ploop_md_up_prio(struct ploop *ploop, struct md_page *md)
 
 	md->high_prio = true;
 	WARN_ON_ONCE(!test_bit(MD_DIRTY, &md->status));
-
-	list_del(&md->wb_link);
-	list_add(&md->wb_link, &ploop->wb_batch_list_prio);
-
 out:
 	write_unlock_irqrestore(&ploop->bat_rwlock, flags);
 }
@@ -1817,43 +1813,41 @@ static void ploop_process_resubmit_pios(struct ploop *ploop,
 	}
 }
 
-static void ploop_submit_metadata_writeback_from_list(struct ploop *ploop,
-						      struct list_head *list)
+static void ploop_submit_metadata_writeback(struct ploop *ploop)
 {
-	struct md_page *md;
+	ktime_t ktime, ktimeout;
+	LIST_HEAD(ll_skipped);
+	struct md_page *md, *mtmp;
+	int send_all;
 
-	while (1) {
+	ktime = ktime_get();
+	ktimeout = ktime_add_ms(ktime, ploop->md_submit_delay_ms);
+	send_all = ktime_after(ktime, ktimeout);
+	/*
+	 * Pages are set dirty so no one must touch lists
+	 * if new md entries are dirtied they are added at the start of the list
+	 */
+	list_for_each_entry_safe(md, mtmp, &ploop->wb_batch_list, wb_link) {
 		write_lock_irq(&ploop->bat_rwlock);
-		md = list_first_entry_or_null(list, struct md_page, wb_link);
-		if (!md) {
+		list_del_init(&md->wb_link);
+		if (md->high_prio || send_all) {
+			/* L1L2 mustn't be redirtyed, when wb in-flight! */
+			WARN_ON_ONCE(!test_bit(MD_DIRTY, &md->status));
+			WARN_ON_ONCE(test_bit(MD_WRITEBACK, &md->status));
+			set_bit(MD_WRITEBACK, &md->status);
+			clear_bit(MD_DIRTY, &md->status);
+			md->high_prio = false;
+			write_unlock_irq(&ploop->bat_rwlock);
+			ploop_index_wb_submit(ploop, md->piwb);
+		} else {
+			list_add_tail(&md->wb_link, &ll_skipped);
 			write_unlock_irq(&ploop->bat_rwlock);
-			break;
 		}
-		list_del_init(&md->wb_link);
-		/* L1L2 mustn't be redirtyed, when wb in-flight! */
-
-		WARN_ON_ONCE(!test_bit(MD_DIRTY, &md->status));
-		WARN_ON_ONCE(test_bit(MD_WRITEBACK, &md->status));
-		set_bit(MD_WRITEBACK, &md->status);
-		clear_bit(MD_DIRTY, &md->status);
-		md->high_prio = false;
-		write_unlock_irq(&ploop->bat_rwlock);
-
-		ploop_index_wb_submit(ploop, md->piwb);
 	}
-}
-
-static void ploop_submit_metadata_writeback(struct ploop *ploop)
-{
-	ktime_t time;
-
-	ploop_submit_metadata_writeback_from_list(ploop, &ploop->wb_batch_list_prio);
+	write_lock_irq(&ploop->bat_rwlock);
+	list_splice(&ll_skipped, &ploop->wb_batch_list);
+	write_unlock_irq(&ploop->bat_rwlock);
 
-	time = ktime_get();
-	if (ktime_after(time, ktime_add_ms(ploop->last_md_submit, ploop->md_submit_delay_ms))) {
-		ploop->last_md_submit = time;
-		ploop_submit_metadata_writeback_from_list(ploop, &ploop->wb_batch_list);
-	}
 }
 
 static void process_ploop_fsync_work(struct ploop *ploop, struct llist_node *llflush_pios)
@@ -2009,16 +2003,10 @@ static void ploop_prepare_flush(struct ploop *ploop, struct pio *pio)
 
 	write_lock_irq(&ploop->bat_rwlock);
 
-	list_for_each_entry(md, &ploop->wb_batch_list_prio, wb_link) {
-		md_inflight++;
-		md->piwb->flush_pio = flush_pio;
-	}
-
 	list_for_each_entry_safe(md, n, &ploop->wb_batch_list, wb_link) {
 		md_inflight++;
 		md->piwb->flush_pio = flush_pio;
-		list_del(&md->wb_link);
-		list_add_tail(&md->wb_link, &ploop->wb_batch_list_prio);
+		md->high_prio = true;
 	}
 
 	atomic_set(&flush_pio->md_inflight, md_inflight);
diff --git a/drivers/md/dm-ploop-target.c b/drivers/md/dm-ploop-target.c
index 67e3719c9378..0b691ff031e2 100644
--- a/drivers/md/dm-ploop-target.c
+++ b/drivers/md/dm-ploop-target.c
@@ -438,7 +438,6 @@ static int ploop_ctr(struct dm_target *ti, unsigned int argc, char **argv)
 	INIT_LIST_HEAD(&ploop->cluster_lk_list);
 	init_llist_head(&ploop->wb_batch_llist);
 	INIT_LIST_HEAD(&ploop->wb_batch_list);
-	INIT_LIST_HEAD(&ploop->wb_batch_list_prio);
 	ploop->last_md_submit = 0;
 	ploop->md_submit_delay_ms = PLOOP_DEFAULT_METADATA_SUBMIT_DELAY;
 
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index 0851b99c2ec6..e4dd7f382896 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -179,7 +179,6 @@ struct ploop {
 
 	struct llist_head wb_batch_llist;
 	struct list_head wb_batch_list;
-	struct list_head wb_batch_list_prio;
 
 	ktime_t last_md_submit;
 #define PLOOP_DEFAULT_METADATA_SUBMIT_DELAY 10000
-- 
2.43.0



More information about the Devel mailing list