[Devel] [PATCH RHEL8 COMMIT] ploop: Use array of pios instead of separate lists
Konstantin Khorenko
khorenko at virtuozzo.com
Tue Jun 29 16:08:15 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.50
------>
commit eebc646378a6163adaf4650dc4a98ae71ff60a77
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date: Tue Jun 29 16:08:15 2021 +0300
ploop: Use array of pios instead of separate lists
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
==========================
Preparation for #PSBM-124550 (part 2)
Kirill Tkhai (14):
ploop: Kill "get_delta_name" alias
ploop: Use initial pio for COW
ploop: Rename cluster_pio into aux_pio
ploop: Shorten variable names
ploop: Rename in submit_cluster_write()
ploop: Use defer_pios() instead of manual code
ploop: Use array of pios instead of separate lists
ploop: Generalize dispatch_pios usage
ploop: Unify process_delta_wb()
ploop: Remove unused struct member
ploop: Rename page_nr
ploop: Return md page from ploop_bat_entries()
ploop: Kill dead check in ploop_attach_end_action()
ploop: Delay bio if md page is BUSY
---
drivers/md/dm-ploop-map.c | 25 ++++++++++++++-----------
drivers/md/dm-ploop-target.c | 13 +++++++------
drivers/md/dm-ploop.h | 17 ++++++++++++-----
3 files changed, 33 insertions(+), 22 deletions(-)
diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index 1f34ebcc0b6a..9f85ca7754b7 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -244,15 +244,16 @@ static int split_pio_to_list(struct ploop *ploop, struct pio *pio,
void defer_pios(struct ploop *ploop, struct pio *pio, struct list_head *pio_list)
{
+ struct list_head *list = &ploop->pios[PLOOP_LIST_DEFERRED];
unsigned long flags;
spin_lock_irqsave(&ploop->deferred_lock, flags);
if (pio)
- list_add_tail(&pio->list, &ploop->deferred_pios);
+ list_add_tail(&pio->list, list);
if (pio_list)
- list_splice_tail_init(pio_list, &ploop->deferred_pios);
-
+ list_splice_tail_init(pio_list, list);
spin_unlock_irqrestore(&ploop->deferred_lock, flags);
+
queue_work(ploop->wq, &ploop->worker);
}
@@ -289,10 +290,11 @@ void __track_pio(struct ploop *ploop, struct pio *pio)
static void queue_discard_index_wb(struct ploop *ploop, struct pio *pio)
{
+ struct list_head *list = &ploop->pios[PLOOP_LIST_DISCARD];
unsigned long flags;
spin_lock_irqsave(&ploop->deferred_lock, flags);
- list_add_tail(&pio->list, &ploop->discard_pios);
+ list_add_tail(&pio->list, list);
spin_unlock_irqrestore(&ploop->deferred_lock, flags);
queue_work(ploop->wq, &ploop->worker);
@@ -1133,7 +1135,7 @@ static void ploop_cow_endio(struct pio *aux_pio, void *data, blk_status_t bi_sta
unsigned long flags;
spin_lock_irqsave(&ploop->deferred_lock, flags);
- list_add_tail(&aux_pio->list, &ploop->delta_cow_action_list);
+ list_add_tail(&aux_pio->list, &ploop->pios[PLOOP_LIST_COW]);
spin_unlock_irqrestore(&ploop->deferred_lock, flags);
queue_work(ploop->wq, &ploop->worker);
@@ -1241,7 +1243,7 @@ static void submit_cow_index_wb(struct ploop_cow *cow,
/* Another BAT page wb is in process */
spin_lock_irq(&ploop->deferred_lock);
list_add_tail(&cow->aux_pio->list,
- &ploop->delta_cow_action_list);
+ &ploop->pios[PLOOP_LIST_COW]);
spin_unlock_irq(&ploop->deferred_lock);
queue_work(ploop->wq, &ploop->worker);
goto out;
@@ -1267,13 +1269,14 @@ static void submit_cow_index_wb(struct ploop_cow *cow,
static void process_delta_wb(struct ploop *ploop, struct ploop_index_wb *piwb)
{
+ struct list_head *list = &ploop->pios[PLOOP_LIST_COW];
struct pio *aux_pio;
struct ploop_cow *cow;
LIST_HEAD(cow_list);
- if (list_empty(&ploop->delta_cow_action_list))
+ if (list_empty(list))
return;
- list_splice_tail_init(&ploop->delta_cow_action_list, &cow_list);
+ list_splice_tail_init(list, &cow_list);
spin_unlock_irq(&ploop->deferred_lock);
while ((aux_pio = pio_list_pop(&cow_list)) != NULL) {
@@ -1547,8 +1550,8 @@ void do_ploop_work(struct work_struct *ws)
spin_lock_irq(&ploop->deferred_lock);
process_delta_wb(ploop, &piwb);
- list_splice_init(&ploop->deferred_pios, &deferred_pios);
- list_splice_init(&ploop->discard_pios, &discard_pios);
+ list_splice_init(&ploop->pios[PLOOP_LIST_DEFERRED], &deferred_pios);
+ list_splice_init(&ploop->pios[PLOOP_LIST_DISCARD], &discard_pios);
spin_unlock_irq(&ploop->deferred_lock);
process_deferred_pios(ploop, &deferred_pios, &piwb);
@@ -1632,7 +1635,7 @@ static void submit_pio(struct ploop *ploop, struct pio *pio)
int ret;
if (pio->bi_iter.bi_size) {
- queue_list = &ploop->deferred_pios;
+ queue_list = &ploop->pios[PLOOP_LIST_DEFERRED];
worker = &ploop->worker;
if (ploop_pio_valid(ploop, pio) < 0)
diff --git a/drivers/md/dm-ploop-target.c b/drivers/md/dm-ploop-target.c
index afdf23325d3b..d4413ff259a5 100644
--- a/drivers/md/dm-ploop-target.c
+++ b/drivers/md/dm-ploop-target.c
@@ -132,11 +132,11 @@ void free_md_pages_tree(struct rb_root *root)
static bool ploop_has_pending_activity(struct ploop *ploop)
{
bool has = false;
+ int i;
spin_lock_irq(&ploop->deferred_lock);
- has |= !list_empty(&ploop->deferred_pios);
- has |= !list_empty(&ploop->discard_pios);
- has |= !list_empty(&ploop->delta_cow_action_list);
+ for (i = 0; i < PLOOP_LIST_COUNT; i++)
+ has |= !list_empty(&ploop->pios[i]);
spin_unlock_irq(&ploop->deferred_lock);
return has;
@@ -326,13 +326,14 @@ static int ploop_ctr(struct dm_target *ti, unsigned int argc, char **argv)
spin_lock_init(&ploop->deferred_lock);
INIT_LIST_HEAD(&ploop->suspended_pios);
- INIT_LIST_HEAD(&ploop->deferred_pios);
+
+ for (i = 0; i < PLOOP_LIST_COUNT; i++)
+ INIT_LIST_HEAD(&ploop->pios[i]);
+
INIT_LIST_HEAD(&ploop->flush_pios);
- INIT_LIST_HEAD(&ploop->discard_pios);
INIT_LIST_HEAD(&ploop->resubmit_pios);
INIT_LIST_HEAD(&ploop->enospc_pios);
INIT_LIST_HEAD(&ploop->cluster_lk_list);
- INIT_LIST_HEAD(&ploop->delta_cow_action_list);
ploop->bat_entries = RB_ROOT;
timer_setup(&ploop->enospc_timer, ploop_enospc_timer, 0);
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index 9192d96ce64d..9b69a7eed71d 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -114,6 +114,15 @@ struct md_page {
u8 *bat_levels;
};
+enum {
+ PLOOP_LIST_DEFERRED = 0,
+ PLOOP_LIST_DISCARD,
+ PLOOP_LIST_COW,
+
+ PLOOP_LIST_COUNT,
+ PLOOP_LIST_INVALID = PLOOP_LIST_COUNT,
+};
+
struct ploop {
struct dm_target *ti;
@@ -166,9 +175,10 @@ struct ploop {
spinlock_t inflight_lock;
spinlock_t deferred_lock;
- struct list_head deferred_pios;
+
+ struct list_head pios[PLOOP_LIST_COUNT];
+
struct list_head flush_pios;
- struct list_head discard_pios;
struct list_head resubmit_pios; /* After partial IO */
struct list_head enospc_pios; /* Delayed after ENOSPC */
@@ -184,9 +194,6 @@ struct ploop {
*/
struct list_head cluster_lk_list;
- /* List of COW requests requiring action. */
- struct list_head delta_cow_action_list;
-
/* Resume is prohibited */
bool noresume;
/* Device is suspended */
More information about the Devel
mailing list