[Devel] [PATCH RHEL8 COMMIT] ploop: Move md is busy check to delay_if_md_busy()

Konstantin Khorenko khorenko at virtuozzo.com
Fri Jul 2 22:43:25 MSK 2021


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

    ploop: Move md is busy check to delay_if_md_busy()
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
    
    ==========================
    Parallel async BAT pages submission and improvements
    
    [1-15]:
    https://jira.sw.ru/browse/PSBM-124550
    
    [16-22]:
    following improvements
    
    Kirill Tkhai (22):
          ploop: Remove absolet comment
          ploop: Add md and piwb cross pointers
          ploop: Add @md argument to locate_new_cluster_and_attach_pio()
          ploop: Refactoring in process_one_discard_pio()
          ploop: Pass type argument to ploop_prepare_bat_update()
          ploop: Move md is busy check to delay_if_md_busy()
          ploop: Introduce batch list for md pages writeback
          ploop: Check for md dirty instead of md piwb
          ploop: Reread piwb after ploop_prepare_bat_update()
          ploop: Change argument in ploop_prepare_bat_update()
          ploop: Return md from ploop_prepare_reloc_index_wb()
          ploop: Change arguments and rename ploop_reset_bat_update()
          ploop: Allow parallel wb of md pages
          ploop: Async md writeback
          ploop: Rename ploop_submit_index_wb_sync()
          ploop: Resubmit pios from main kwork
          ploop: Rename process_delta_wb()
          ploop: Do fsync after bat page write
          ploop: Do not iterate excess clusters in notify_delta_merged()
          ploop: Use kvec in ploop_delta_check_header()
          ploop: Add argument to ploop_read_delta_metadata()
          ploop: Underline clu and page is u32
---
 drivers/md/dm-ploop-map.c | 58 +++++++++++++++++++++--------------------------
 1 file changed, 26 insertions(+), 32 deletions(-)

diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index ce65da6988bf..877e29226a45 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -255,16 +255,22 @@ void dispatch_pios(struct ploop *ploop, struct pio *pio, struct list_head *pio_l
 	queue_work(ploop->wq, &ploop->worker);
 }
 
-/* FIXME: check wb, make bool ... */
-static void delay_on_md_busy(struct ploop *ploop, struct md_page *md, struct pio *pio)
+static bool delay_if_md_busy(struct ploop *ploop, struct ploop_index_wb *piwb,
+		     struct md_page *md, enum piwb_type type, struct pio *pio)
 {
 	unsigned long flags;
+	bool busy = false;
 
 	WARN_ON_ONCE(!list_empty(&pio->list));
 
 	write_lock_irqsave(&ploop->bat_rwlock, flags);
-	list_add_tail(&pio->list, &md->wait_list);
+	if (piwb->md && (piwb->md != md || piwb->type != type)) {
+		list_add_tail(&pio->list, &piwb->md->wait_list);
+		busy = true;
+	}
 	write_unlock_irqrestore(&ploop->bat_rwlock, flags);
+
+	return busy;
 }
 
 void track_dst_cluster(struct ploop *ploop, u32 dst_clu)
@@ -1242,22 +1248,19 @@ static void submit_cow_index_wb(struct ploop_cow *cow,
 	struct md_page *md;
 	map_index_t *to;
 
+	WARN_ON_ONCE(cow->aux_pio->queue_list_id != PLOOP_LIST_COW);
 	page_id = bat_clu_to_page_nr(clu);
+	md = md_page_find(ploop, page_id);
+
+	if (delay_if_md_busy(ploop, piwb, md, PIWB_TYPE_ALLOC, cow->aux_pio))
+		goto out;
 
-	if (piwb->page_id == PAGE_NR_NONE) {
+	if (!md->piwb) {
 		/* No index wb in process. Prepare a new one */
 		if (ploop_prepare_bat_update(ploop, page_id, piwb, PIWB_TYPE_ALLOC) < 0)
 			goto err_resource;
 	}
 
-	if (piwb->page_id != page_id || piwb->type != PIWB_TYPE_ALLOC) {
-		/* Another BAT page wb is in process */
-		WARN_ON_ONCE(cow->aux_pio->queue_list_id != PLOOP_LIST_COW);
-		md = md_page_find(ploop, piwb->page_id);
-		delay_on_md_busy(ploop, md, cow->aux_pio);
-		goto out;
-	}
-
 	clu -= page_id * PAGE_SIZE / sizeof(map_index_t) - PLOOP_MAP_OFFSET;
 
 	to = kmap_atomic(piwb->bat_page);
@@ -1333,10 +1336,12 @@ static bool locate_new_cluster_and_attach_pio(struct ploop *ploop,
 	bool attached = false;
 	unsigned int page_id;
 
-	page_id = bat_clu_to_page_nr(clu);
+	WARN_ON_ONCE(pio->queue_list_id != PLOOP_LIST_DEFERRED);
+	if (delay_if_md_busy(ploop, piwb, md, PIWB_TYPE_ALLOC, pio))
+		goto out;
 
-	if (piwb->page_id == PAGE_NR_NONE) {
-		/* No index wb in process. Prepare a new one */
+	if (!md->piwb) {
+		page_id = bat_clu_to_page_nr(clu);
 		if (ploop_prepare_bat_update(ploop, page_id, piwb, PIWB_TYPE_ALLOC) < 0) {
 			pio->bi_status = BLK_STS_RESOURCE;
 			goto error;
@@ -1344,13 +1349,6 @@ static bool locate_new_cluster_and_attach_pio(struct ploop *ploop,
 		bat_update_prepared = true;
 	}
 
-	if (piwb->page_id != page_id || piwb->type != PIWB_TYPE_ALLOC) {
-		/* Another BAT page wb is in process */
-		WARN_ON_ONCE(pio->queue_list_id != PLOOP_LIST_DEFERRED);
-		delay_on_md_busy(ploop, piwb->md, pio);
-		goto out;
-	}
-
 	if (ploop_alloc_cluster(ploop, piwb, clu, dst_clu)) {
 		pio->bi_status = BLK_STS_IOERR;
 		goto error;
@@ -1471,12 +1469,15 @@ static void process_one_discard_pio(struct ploop *ploop, struct pio *pio,
 	struct md_page *md;
 	map_index_t *to;
 
-	WARN_ON(ploop->nr_deltas != 1);
+	WARN_ON(ploop->nr_deltas != 1 ||
+		pio->queue_list_id != PLOOP_LIST_DISCARD);
 
 	page_id = bat_clu_to_page_nr(clu);
+	md = md_page_find(ploop, page_id);
+	if (delay_if_md_busy(ploop, piwb, md, PIWB_TYPE_DISCARD, pio))
+		goto out;
 
-	if (piwb->page_id == PAGE_NR_NONE) {
-		/* No index wb in process. Prepare a new one */
+	if (!md->piwb) {
 		if (ploop_prepare_bat_update(ploop, page_id, piwb, PIWB_TYPE_DISCARD) < 0) {
 			pio->bi_status = BLK_STS_RESOURCE;
 			goto err;
@@ -1484,13 +1485,6 @@ static void process_one_discard_pio(struct ploop *ploop, struct pio *pio,
 		bat_update_prepared = true;
 	}
 
-	if (piwb->page_id != page_id || piwb->type != PIWB_TYPE_DISCARD) {
-		WARN_ON_ONCE(pio->queue_list_id != PLOOP_LIST_DISCARD);
-		md = md_page_find(ploop, piwb->page_id);
-		delay_on_md_busy(ploop, md, pio);
-		goto out;
-	}
-
 	/* Cluster index related to the page[page_id] start */
 	clu -= piwb->page_id * PAGE_SIZE / sizeof(map_index_t) - PLOOP_MAP_OFFSET;
 


More information about the Devel mailing list