[Devel] [PATCH vz9 v1 29/63] dm-ploop: add interface to disable bat writeback delay
Alexander Atanasov
alexander.atanasov at virtuozzo.com
Fri Jan 24 18:36:03 MSK 2025
Add conditions that prevent writeback delay:
- if we have a pending pios
- if doing utility operations we do not want to delay writeout too
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 | 15 ++++++++++++++-
drivers/md/dm-ploop.h | 7 ++++++-
3 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c
index 26dc1ff04e8e..f98542e952e1 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 40c3cb00856d..cc75b99908a2 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -585,6 +585,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 = {
@@ -1842,7 +1853,9 @@ 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 || time_before(md->dirty_timeout, timeout)) {
+ if (!llist_empty(&md->wait_llist) || md->high_prio ||
+ time_before(md->dirty_timeout, timeout) ||
+ 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 fa2b02910296..b0cf01bb3003 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -181,6 +181,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;
@@ -608,6 +609,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