[Devel] [PATCH RHEL8 COMMIT] ploop: Introduce separate lock for inflight pios

Konstantin Khorenko khorenko at virtuozzo.com
Thu Jun 17 19:01:00 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.44
------>
commit 0bac9a519f688d347151f1cc2f3252d7f50390b6
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Thu Jun 17 19:01:00 2021 +0300

    ploop: Introduce separate lock for inflight pios
    
    Just to not overload deferred_lock
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
    
    =====================
    Patchset description:
    
    ploop: Allow to resubmit partially completed request
    
    This allows to continue submitting partially completed requests.
    
    https://jira.sw.ru/browse/PSBM-127225
    
    Kirill Tkhai (18):
          ploop: Simplify ploop_write_cluster_sync()
          ploop: Rename hook->pio, h->pio, ploop_cow::hook->aux_pio
          ploop: Rename force_link_inflight_bios
          ploop: Introduce separate lock for inflight pios
          ploop: Use hlist instead of rbtree
          ploop: Always link submitted pios
          ploop: Unexport ploop_inflight_bios_ref_switch()
          ploop: Refactor submit_pio()
          ploop: Introduce ploop_suspend_submitting_pios
          ploop: Refactor ploop_ctr()
          ploop: Use ploop_call_rw_iter() in submit_delta_read()
          ploop: Generalize submit_rw_mapped()
          ploop: Kill submit_delta_read()
          ploop: Rename submit_rw_mapped()
          ploop: Extract submit_rw_mapped() to separate function
          ploop: Save level before submitting pio
          ploop: Make fsync work be able to run in parallel with main work
          ploop: Introduce resubmitting partially completed pios
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 drivers/md/dm-ploop-map.c    | 22 +++++++++++-----------
 drivers/md/dm-ploop-target.c |  1 +
 drivers/md/dm-ploop.h        |  1 +
 3 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index e064e66acef5..388973b56a85 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -354,7 +354,7 @@ struct pio *find_pio_range(struct ploop *ploop, struct rb_root *root,
 
 static struct pio *find_inflight_bio(struct ploop *ploop, unsigned int cluster)
 {
-	lockdep_assert_held(&ploop->deferred_lock);
+	lockdep_assert_held(&ploop->inflight_lock);
 	return find_pio(ploop, &ploop->inflight_pios_rbtree, cluster);
 }
 
@@ -481,29 +481,29 @@ static void maybe_link_submitting_pio(struct ploop *ploop, struct pio *pio,
 	if (!ploop->force_rbtree_for_inflight)
 		return;
 
-	spin_lock_irqsave(&ploop->deferred_lock, flags);
+	spin_lock_irqsave(&ploop->inflight_lock, flags);
 	link_pio(ploop, pio, &ploop->inflight_pios_rbtree, cluster, false);
-	spin_unlock_irqrestore(&ploop->deferred_lock, flags);
+	spin_unlock_irqrestore(&ploop->inflight_lock, flags);
 }
 static void maybe_unlink_completed_pio(struct ploop *ploop, struct pio *pio)
 {
 	LIST_HEAD(pio_list);
 	unsigned long flags;
-	bool queue = false;
 
 	if (likely(RB_EMPTY_NODE(&pio->node)))
 		return;
 
-	spin_lock_irqsave(&ploop->deferred_lock, flags);
+	spin_lock_irqsave(&ploop->inflight_lock, flags);
 	unlink_pio(ploop, &ploop->inflight_pios_rbtree, pio, &pio_list);
+	spin_unlock_irqrestore(&ploop->inflight_lock, flags);
+
 	if (!list_empty(&pio_list)) {
+		spin_lock_irqsave(&ploop->deferred_lock, flags);
 		list_splice_tail(&pio_list, &ploop->deferred_pios);
-		queue = true;
-	}
-	spin_unlock_irqrestore(&ploop->deferred_lock, flags);
+		spin_unlock_irqrestore(&ploop->deferred_lock, flags);
 
-	if (queue)
 		queue_work(ploop->wq, &ploop->worker);
+	}
 }
 
 static bool pio_endio_if_all_zeros(struct pio *pio)
@@ -584,11 +584,11 @@ static void handle_discard_pio(struct ploop *ploop, struct pio *pio,
 		}
 	}
 
-	spin_lock_irqsave(&ploop->deferred_lock, flags);
+	spin_lock_irqsave(&ploop->inflight_lock, flags);
 	inflight_h = find_inflight_bio(ploop, cluster);
 	if (inflight_h)
 		add_endio_pio(inflight_h, pio);
-	spin_unlock_irqrestore(&ploop->deferred_lock, flags);
+	spin_unlock_irqrestore(&ploop->inflight_lock, flags);
 
 	if (inflight_h) {
 		/* @pio will be requeued on inflight_h's pio end */
diff --git a/drivers/md/dm-ploop-target.c b/drivers/md/dm-ploop-target.c
index 608d9d6697d2..f346e6ca68c5 100644
--- a/drivers/md/dm-ploop-target.c
+++ b/drivers/md/dm-ploop-target.c
@@ -291,6 +291,7 @@ static int ploop_ctr(struct dm_target *ti, unsigned int argc, char **argv)
 
 	rwlock_init(&ploop->bat_rwlock);
 	init_rwsem(&ploop->ctl_rwsem);
+	spin_lock_init(&ploop->inflight_lock);
 	spin_lock_init(&ploop->deferred_lock);
 
 	INIT_LIST_HEAD(&ploop->deferred_pios);
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index 62b0d9847347..03410b5ac093 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -184,6 +184,7 @@ struct ploop {
 	bool inflight_ref_comp_pending;
 	unsigned int inflight_bios_ref_index:1;
 
+	spinlock_t inflight_lock;
 	spinlock_t deferred_lock;
 	struct list_head deferred_pios;
 	struct list_head flush_pios;


More information about the Devel mailing list