[Devel] [PATCH hci-8.1 1/3] dm-ploop: factor out ploop_dispatch_md_waiters()

Denis V. Lunev den at openvz.org
Mon Nov 9 22:06:02 MSK 2026


From: Denis V. Lunev <den at openvz.org>

Move the loop that hands the pios parked in md->wait_llist back to the
dispatcher out of ploop_advance_local_after_bat_wb() into a helper of
its own, so that the error paths of the BAT updates can use it too.

No functional change.

https://virtuozzo.atlassian.net/browse/VSTOR-154096

Feature: dm-ploop: ploop target driver
Signed-off-by: Denis V. Lunev <den at openvz.org>
---
 drivers/md/dm-ploop-map.c | 32 +++++++++++++++++++-------------
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index ae3e287604b7..f0569263622c 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -840,6 +840,23 @@ static void ploop_advance_discarded(struct ploop *ploop, struct md_page *md,
 	ploop_hole_set_bit(d_clu, ploop);
 }
 
+static void ploop_dispatch_md_waiters(struct ploop *ploop,
+				      struct llist_node *waiters)
+{
+	struct llist_node *pos, *t;
+	struct pio *pio;
+	LIST_HEAD(list);
+
+	llist_for_each_safe(pos, t, waiters) {
+		pio = list_entry((struct list_head *)pos, typeof(*pio), list);
+		INIT_LIST_HEAD(&pio->list);
+		list_add(&pio->list, &list);
+	}
+
+	if (!list_empty(&list))
+		ploop_dispatch_pios(ploop, NULL, &list);
+}
+
 /*
  * Apply to the local BAT copy the changes made by the pios attached
  * to @piwb, whatever type @piwb was prepared with: allocations and
@@ -856,11 +873,10 @@ static void ploop_advance_local_after_bat_wb(struct ploop *ploop,
 	struct md_page *md = piwb->md;
 	map_index_t *dst_clu;
 	unsigned long flags;
-	LIST_HEAD(list);
 	struct llist_node *wait_llist_pending;
 	struct ploop_cow *cow;
 	struct pio *pio;
-	struct llist_node *pos, *t;
+	struct llist_node *pos;
 	BUG_ON(!md);
 
 	spin_lock_irqsave(&ploop->bat_lock, flags);
@@ -893,17 +909,7 @@ static void ploop_advance_local_after_bat_wb(struct ploop *ploop,
 	spin_unlock_irqrestore(&ploop->bat_lock, flags);
 	kunmap_local(dst_clu);
 
-	if (wait_llist_pending) {
-		llist_for_each_safe(pos, t, wait_llist_pending) {
-			pio = list_entry((struct list_head *)pos, typeof(*pio), list);
-			INIT_LIST_HEAD(&pio->list);
-			list_add(&pio->list, &list);
-		}
-	}
-
-	if (!list_empty(&list))
-		ploop_dispatch_pios(ploop, NULL, &list);
-
+	ploop_dispatch_md_waiters(ploop, wait_llist_pending);
 }
 
 static void ploop_free_piwb(struct ploop_index_wb *piwb)
-- 
2.53.0



More information about the Devel mailing list