[Devel] [PATCH RHEL8 COMMIT] ploop: Teach dispatch_pios() work with flush pios

Konstantin Khorenko khorenko at virtuozzo.com
Fri Jul 2 22:47:58 MSK 2021


The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.vz8.5.51
------>
commit 7ba1b3c06e3b886ac87d9722656232492caed489
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Fri Jul 2 22:47:58 2021 +0300

    ploop: Teach dispatch_pios() work with flush pios
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
    
    ==========================
    ploop: Split pios in kwork
    
    https://jira.sw.ru/browse/PSBM-131208
    
    Kirill Tkhai (10):
          ploop: Remove debug noinline in create_bvec_from_rq()
          ploop: Manage flush pios in generic way
          ploop: Teach dispatch_pios() work with flush pios
          ploop: Make split_pios_to_list() to add initial pio to the list too
          ploop: Introduce embedded_pio_to_prq()
          ploop: Introduce ploop_prq_valid()
          ploop: Move create_bvec_from_rq() up
          ploop: Split pios from kwork context
          ploop: Add sanity check of passed BAT from disk
          ploop: Reread file size after index update
---
 drivers/md/dm-ploop-map.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index 5c8375636eac..a4cc8de169c4 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -229,30 +229,40 @@ static int split_pio_to_list(struct ploop *ploop, struct pio *pio,
 	return -ENOMEM;
 }
 
-static void dispatch_pio(struct ploop *ploop, struct pio *pio)
+static void dispatch_pio(struct ploop *ploop, struct pio *pio,
+			 bool *is_data, bool *is_flush)
 {
 	struct list_head *list = &ploop->pios[pio->queue_list_id];
 
 	lockdep_assert_held(&ploop->deferred_lock);
 	WARN_ON_ONCE(pio->queue_list_id >= PLOOP_LIST_COUNT);
 
+	if (pio->queue_list_id == PLOOP_LIST_FLUSH)
+		*is_flush = true;
+	else
+		*is_data = true;
+
 	list_add_tail(&pio->list, list);
 }
 
 void dispatch_pios(struct ploop *ploop, struct pio *pio, struct list_head *pio_list)
 {
+	bool is_data = false, is_flush = false;
 	unsigned long flags;
 
 	spin_lock_irqsave(&ploop->deferred_lock, flags);
 	if (pio)
-		dispatch_pio(ploop, pio);
+		dispatch_pio(ploop, pio, &is_data, &is_flush);
 	if (pio_list) {
 		while ((pio = pio_list_pop(pio_list)) != NULL)
-			dispatch_pio(ploop, pio);
+			dispatch_pio(ploop, pio, &is_data, &is_flush);
 	}
 	spin_unlock_irqrestore(&ploop->deferred_lock, flags);
 
-	queue_work(ploop->wq, &ploop->worker);
+	if (is_data)
+		queue_work(ploop->wq, &ploop->worker);
+	if (is_flush)
+		queue_work(ploop->wq, &ploop->fsync_worker);
 }
 
 static bool delay_if_md_busy(struct ploop *ploop, struct md_page *md,
@@ -1482,7 +1492,6 @@ static void md_write_endio(struct pio *pio, void *piwb_ptr, blk_status_t bi_stat
 {
 	struct ploop_index_wb *piwb = piwb_ptr;
 	struct ploop *ploop = piwb->ploop;
-	unsigned long flags;
 	u32 dst_clu;
 
 	dst_clu = POS_TO_CLU(ploop, (u64)piwb->page_id << PAGE_SHIFT);
@@ -1495,10 +1504,8 @@ static void md_write_endio(struct pio *pio, void *piwb_ptr, blk_status_t bi_stat
 		pio->endio_cb = md_fsync_endio;
 		pio->endio_cb_data = piwb;
 
-		spin_lock_irqsave(&ploop->deferred_lock, flags);
-		list_add_tail(&pio->list, &ploop->pios[PLOOP_LIST_FLUSH]);
-		spin_unlock_irqrestore(&ploop->deferred_lock, flags);
-		queue_work(ploop->wq, &ploop->fsync_worker);
+		pio->queue_list_id = PLOOP_LIST_FLUSH;
+		dispatch_pios(ploop, pio, NULL);
 	}
 }
 


More information about the Devel mailing list