[Devel] [PATCH RHEL9 COMMIT] dm-ploop: resubmit enospc pios from dispatcher thread

Konstantin Khorenko khorenko at virtuozzo.com
Mon Jan 27 16:12:55 MSK 2025


The commit is pushed to "branch-rh9-5.14.0-427.44.1.vz9.80.x-ovz" and will appear at git at bitbucket.org:openvz/vzkernel.git
after rh9-5.14.0-427.44.1.vz9.80.6
------>
commit 71831d9c59b6d7622dec38dc7219564baeb480cc
Author: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
Date:   Fri Jan 24 17:36:33 2025 +0200

    dm-ploop: resubmit enospc pios from dispatcher thread
    
    When running out of space pios are delayed and retried
    from a timer. This timer is the only thing that runs in
    interrupt context and brings requirement to use _irqsave
    variants, since a complete request processing can be started
    from the timer. To avoid this set a flag from the timer
    and process delayed pios from the dispatcher thread.
    Follow up patches will cleanup flags saving.
    
    https://virtuozzo.atlassian.net/browse/VSTOR-98016
    Signed-off-by: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
    
    ======
    Patchset description:
    ploop: optimistations and scalling
    
    Ploop processes requsts in a different threads in parallel
    where possible which results in significant improvement in
    performance and makes further optimistations possible.
    
    Known bugs:
      - delayed metadata writeback is not working and is missing error handling
         - patch to disable it until fixed
      - fast path is not working - causes rcu lockups - patch to disable it
    
    Further improvements:
      - optimize md pages lookups
    
    Alexander Atanasov (50):
      dm-ploop: md_pages map all pages at creation time
      dm-ploop: Use READ_ONCE/WRITE_ONCE to access md page data
      dm-ploop: fsync after all pios are sent
      dm-ploop: move md status to use proper bitops
      dm-ploop: convert wait_list and wb_batch_llist to use lockless lists
      dm-ploop: convert enospc handling to use lockless lists
      dm-ploop: convert suspended_pios list to use lockless list
      dm-ploop: convert the rest of the lists to use llist variant
      dm-ploop: combine processing of pios thru prepare list and remove
        fsync worker
      dm-ploop: move from wq to kthread
      dm-ploop: move preparations of pios into the caller from worker
      dm-ploop: fast path execution for reads
      dm-ploop: do not use a wrapper for set_bit to make a page writeback
      dm-ploop: BAT use only one list for writeback
      dm-ploop: make md writeback timeout to be per page
      dm-ploop: add interface to disable bat writeback delay
      dm-ploop: convert wb_batch_list to lockless variant
      dm-ploop: convert high_prio to status
      dm-ploop: split cow processing into two functions
      dm-ploop: convert md page rw lock to spin lock
      dm-ploop: convert bat_rwlock to bat_lock spinlock
      dm-ploop: prepare bat updates under bat_lock
      dm-ploop: make ploop_bat_write_complete ready for parallel pio
        completion
      dm-ploop: make ploop_submit_metadata_writeback return number of
        requests sent
      dm-ploop: introduce pio runner threads
      dm-ploop: add pio list ids to be used when passing pios to runners
      dm-ploop: process pios via runners
      dm-ploop: disable metadata writeback delay
      dm-ploop: disable fast path
      dm-ploop: use lockless lists for chained cow updates list
      dm-ploop: use lockless lists for data ready pios
      dm-ploop: give runner threads better name
      dm-ploop: resize operation - add holes bitmap locking
      dm-ploop: remove unnecessary operations
      dm-ploop: use filp per thread
      dm-ploop: catch if we try to advance pio past bio end
      dm-ploop: support REQ_FUA for data pios
      dm-ploop: proplerly access nr_bat_entries
      dm-ploop: fix locking and improve error handling when submitting pios
      dm-ploop: fix how ENOTBLK is handled
      dm-ploop: sync when suspended or stopping
      dm-ploop: rework bat completion logic
      dm-ploop: rework logic in pio processing
      dm-ploop: end fsync pios in parallel
      dm-ploop: make filespace preallocations async
      dm-ploop: resubmit enospc pios from dispatcher thread
      dm-ploop: dm-ploop: simplify discard completion
      dm-ploop: use GFP_ATOMIC instead of GFP_NOIO
      dm-ploop: fix locks used in mixed context
      dm-ploop: fix how current flags are managed inside threads
    
    Andrey Zhadchenko (13):
      dm-ploop: do not flush after metadata writes
      dm-ploop: set IOCB_DSYNC on all FUA requests
      dm-ploop: remove extra ploop_cluster_is_in_top_delta()
      dm-ploop: introduce per-md page locking
      dm-ploop: reduce BAT accesses on discard completion
      dm-ploop: simplify llseek
      dm-ploop: speed up ploop_prepare_bat_update()
      dm-ploop: make new allocations immediately visible in BAT
      dm-ploop: drop ploop_cluster_is_in_top_delta()
      dm-ploop: do not wait for BAT update for non-FUA requests
      dm-ploop: add delay for metadata writeback
      dm-ploop: submit all postponed metadata on REQ_OP_FLUSH
      dm-ploop: handle REQ_PREFLUSH
    
    Feature: dm-ploop: ploop target driver
---
 drivers/md/dm-ploop-map.c    | 31 ++++++++++++++++++-------------
 drivers/md/dm-ploop-target.c |  2 +-
 drivers/md/dm-ploop.h        |  2 ++
 3 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index 00929455fcf5..98297fb46bb6 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -151,12 +151,7 @@ static void ploop_init_prq_and_embedded_pio(struct ploop *ploop,
 void ploop_enospc_timer(struct timer_list *timer)
 {
 	struct ploop *ploop = from_timer(ploop, timer, enospc_timer);
-	struct llist_node *enospc_pending = llist_del_all(&ploop->enospc_pios);
-
-	if (enospc_pending) {
-		enospc_pending = llist_reverse_order(enospc_pending);
-		ploop_submit_embedded_pios(ploop, enospc_pending);
-	}
+	ploop->submit_enospc = true;
 }
 
 void do_ploop_event_work(struct work_struct *ws)
@@ -169,12 +164,11 @@ void do_ploop_event_work(struct work_struct *ws)
 static bool ploop_try_delay_enospc(struct ploop_rq *prq, struct pio *pio)
 {
 	struct ploop *ploop = pio->ploop;
-	bool delayed = true;
 	unsigned long flags;
 
 	if (unlikely(ploop->wants_suspend)) {
-		delayed = false;
-		goto unlock;
+		PL_WARN("dropping pio enospc\n");
+		return false;
 	}
 
 	ploop_init_prq_and_embedded_pio(ploop, prq->rq, prq, pio);
@@ -185,13 +179,11 @@ static bool ploop_try_delay_enospc(struct ploop_rq *prq, struct pio *pio)
 	ploop->event_enospc = true;
 	spin_unlock_irqrestore(&ploop->deferred_lock, flags);
 	llist_add((struct llist_node *)(&pio->list), &ploop->enospc_pios);
-unlock:
 
-	if (delayed)
-		mod_timer(&ploop->enospc_timer, jiffies + PLOOP_ENOSPC_TIMEOUT);
+	mod_timer(&ploop->enospc_timer, jiffies + PLOOP_ENOSPC_TIMEOUT);
 	schedule_work(&ploop->event_work);
 
-	return delayed;
+	return true;
 }
 
 static void ploop_prq_endio(struct pio *pio, void *prq_ptr,
@@ -2165,6 +2157,14 @@ static inline int ploop_runners_add_work_list(struct ploop *ploop, struct llist_
 	return 0;
 }
 
+void ploop_resubmit_enospc_pios(struct ploop *ploop)
+{
+	struct llist_node *enospc_pending = llist_del_all(&ploop->enospc_pios);
+
+	if (enospc_pending)
+		ploop_submit_embedded_pios(ploop, llist_reverse_order(enospc_pending));
+}
+
 void do_ploop_run_work(struct ploop *ploop)
 {
 	LLIST_HEAD(deferred_pios);
@@ -2180,6 +2180,11 @@ void do_ploop_run_work(struct ploop *ploop)
 
 	current->flags |= PF_IO_THREAD|PF_LOCAL_THROTTLE|PF_MEMALLOC_NOIO;
 
+	if (ploop->submit_enospc) {
+		ploop->submit_enospc = false;
+		ploop_resubmit_enospc_pios(ploop);
+	}
+
 	llembedded_pios = llist_del_all(&ploop->pios[PLOOP_LIST_PREPARE]);
 
 	lldeferred_pios = llist_del_all(&ploop->pios[PLOOP_LIST_DEFERRED]);
diff --git a/drivers/md/dm-ploop-target.c b/drivers/md/dm-ploop-target.c
index 641950031fe3..f306f0c85ee5 100644
--- a/drivers/md/dm-ploop-target.c
+++ b/drivers/md/dm-ploop-target.c
@@ -695,7 +695,7 @@ static void ploop_presuspend(struct dm_target *ti)
 	wait_event_interruptible(ploop->dispatcher_wq_data,
 			(!atomic_read(&ploop->kt_worker->inflight_pios)));
 	vfs_fsync(ploop_top_delta(ploop)->file, 0);
-	ploop_enospc_timer(&ploop->enospc_timer);
+	ploop_resubmit_enospc_pios(ploop);
 }
 
 static void ploop_presuspend_undo(struct dm_target *ti)
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index edf9b1448887..43e65e841e4a 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -259,6 +259,7 @@ struct ploop {
 	bool nokblkcg;
 
 	struct timer_list enospc_timer;
+	bool submit_enospc; /* timer expired run pios from dispatcher */
 	bool event_enospc;
 
 	loff_t prealloc_size;
@@ -637,5 +638,6 @@ extern void ploop_disable_writeback_delay(struct ploop *ploop);
 extern void ploop_enable_writeback_delay(struct ploop *ploop);
 
 extern void ploop_should_prealloc(struct ploop *ploop, struct file *file);
+extern void ploop_resubmit_enospc_pios(struct ploop *ploop);
 
 #endif /* __DM_PLOOP_H */


More information about the Devel mailing list