[Devel] [RFC PATCH vz9 v5 44/49] dm-ploop: make ploop_submit_metadata_writeback return number of requests sent
Alexander Atanasov
alexander.atanasov at virtuozzo.com
Mon Nov 18 09:25:11 MSK 2024
We need to wait for write back to complete to issue pending flushes.
To know if we have to wait return numer of pios submitted.
https://virtuozzo.atlassian.net/browse/VSTOR-91821
Signed-off-by: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
---
drivers/md/dm-ploop-map.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index acff0d7c5a20..c7c07234571b 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -1911,7 +1911,7 @@ static int inline ploop_runners_have_pending(struct ploop *ploop)
}
#endif
-static void ploop_submit_metadata_writeback(struct ploop *ploop, int force)
+static int ploop_submit_metadata_writeback(struct ploop *ploop, int force)
{
unsigned long flags;
LIST_HEAD(ll_skipped);
@@ -1919,19 +1919,26 @@ static void ploop_submit_metadata_writeback(struct ploop *ploop, int force)
struct llist_node *pos, *t;
struct llist_node *ll_wb_batch;
unsigned long timeout = jiffies;
+ int ret;
/* Lock here to protect against md_inflight counting */
spin_lock_irqsave(&ploop->bat_lock, flags);
ll_wb_batch = llist_del_all(&ploop->wb_batch_llist);
spin_unlock_irqrestore(&ploop->bat_lock, flags);
+ if (!ll_wb_batch) {
+ return 0;
+ }
+
+ ret = 0;
+
/*
* 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
*/
- llist_for_each_safe(pos, t, ll_wb_batch ) {
+ llist_for_each_safe(pos, t, ll_wb_batch) {
md = list_entry((struct list_head *)pos, typeof(*md), wb_link);
- if (test_bit(MD_HIGHPRIO, &md->status) || time_before(md->dirty_timeout, timeout)
- || ploop->force_md_writeback) {
+ if (!llist_empty(&md->wait_llist) || force || test_bit(MD_HIGHPRIO, &md->status) ||
+ time_before(md->dirty_timeout, timeout)) {
/* 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));
@@ -1939,11 +1946,14 @@ static void ploop_submit_metadata_writeback(struct ploop *ploop, int force)
clear_bit(MD_DIRTY, &md->status);
clear_bit(MD_HIGHPRIO, &md->status);
ploop_index_wb_submit(ploop, md->piwb);
+ ret++;
} else {
printk(KERN_ERR "abwbl\n");
+ INIT_LIST_HEAD(&md->wb_link);
llist_add((struct llist_node *)&md->wb_link, &ploop->wb_batch_llist);
}
}
+ return ret;
}
static void process_ploop_fsync_work(struct ploop *ploop, struct llist_node *llflush_pios)
--
2.43.0
More information about the Devel
mailing list