[Devel] [RFC PATCH vz9 v5 32/49] dm-ploop: add interface to disable bat writeback delay

Alexander Atanasov alexander.atanasov at virtuozzo.com
Mon Nov 18 09:24:59 MSK 2024


When doing utility operations we do not want to delay writeout
of dirty pages. Add interface to disable delay.
Hook it into suspend/resuming of sending pios. Which is done before
ops that require it.

https://virtuozzo.atlassian.net/browse/VSTOR-91817
Signed-off-by: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
---
 drivers/md/dm-ploop-cmd.c |  2 ++
 drivers/md/dm-ploop-map.c | 14 +++++++++++++-
 drivers/md/dm-ploop.h     |  7 ++++++-
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c
index b1ab296d91f8..d4408cba5f0d 100644
--- a/drivers/md/dm-ploop-cmd.c
+++ b/drivers/md/dm-ploop-cmd.c
@@ -129,6 +129,7 @@ static void ploop_resume_submitting_pios(struct ploop *ploop)
 {
 	struct llist_node *suspended_pending;
 
+	ploop_enable_writeback_delay(ploop);
 	spin_lock_irq(&ploop->deferred_lock);
 	WARN_ON_ONCE(!ploop->stop_submitting_pios);
 	ploop->stop_submitting_pios = false;
@@ -143,6 +144,7 @@ static int ploop_suspend_submitting_pios(struct ploop *ploop)
 {
 	int ret;
 
+	ploop_disable_writeback_delay(ploop);
 	spin_lock_irq(&ploop->deferred_lock);
 	WARN_ON_ONCE(ploop->stop_submitting_pios);
 	ploop->stop_submitting_pios = true;
diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index 4eb1d9b6c6cd..5567c9acda58 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -582,6 +582,17 @@ static void ploop_md_up_prio(struct ploop *ploop, struct md_page *md)
        write_unlock_irqrestore(&ploop->bat_rwlock, flags);
 }
 
+void ploop_disable_writeback_delay(struct ploop *ploop)
+{
+	ploop->force_md_writeback = true;
+	ploop_schedule_work(ploop);
+}
+
+void ploop_enable_writeback_delay(struct ploop *ploop)
+{
+	ploop->force_md_writeback = false;
+}
+
 static bool ploop_pio_endio_if_all_zeros(struct pio *pio)
 {
 	struct bvec_iter bi = {
@@ -1828,7 +1839,8 @@ static void ploop_submit_metadata_writeback(struct ploop *ploop)
 	list_for_each_entry_safe(md, mtmp, &ploop->wb_batch_list, wb_link) {
 		write_lock_irq(&ploop->bat_rwlock);
 		list_del_init(&md->wb_link);
-		if (md->high_prio || ktime_after(md->dirty_time, ktimeout)) {
+		if (md->high_prio || ktime_after(md->dirty_time, ktimeout)
+		    || ploop->force_md_writeback) {
 			/* 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));
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index 1651293e2fd8..4b1164b26cb2 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -182,6 +182,7 @@ struct ploop {
 	struct list_head wb_batch_list;
 
 	ktime_t last_md_submit;
+	bool	force_md_writeback;
 #define PLOOP_DEFAULT_METADATA_SUBMIT_DELAY 10000
 	uint64_t md_submit_delay_ms;
 
@@ -610,6 +611,10 @@ extern void ploop_call_rw_iter(struct file *file, loff_t pos, unsigned rw,
 extern void ploop_enospc_timer(struct timer_list *timer);
 extern loff_t ploop_llseek_hole(struct dm_target *ti, loff_t offset, int whence);
 
-int ploop_worker(void *data);
+extern int ploop_worker(void *data);
+
+extern void ploop_disable_writeback_delay(struct ploop *ploop);
+extern void ploop_enable_writeback_delay(struct ploop *ploop);
+
 
 #endif /* __DM_PLOOP_H */
-- 
2.43.0



More information about the Devel mailing list