[Devel] [PATCH RH8 04/18] ploop: Introduce separate lock for inflight pios
Kirill Tkhai
ktkhai at virtuozzo.com
Wed Jun 16 18:46:36 MSK 2021
Just to not overload deferred_lock
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