[Devel] [PATCH vz9 v1 57/63] dm-ploop: end fsync pios in parallel
Alexander Atanasov
alexander.atanasov at virtuozzo.com
Fri Jan 24 18:36:31 MSK 2025
Send all pios attached to sync operation to runners
to call endio.
https://virtuozzo.atlassian.net/browse/VSTOR-91821
Signed-off-by: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
---
drivers/md/dm-ploop-map.c | 18 ++++++++++++------
drivers/md/dm-ploop-target.c | 1 +
drivers/md/dm-ploop.h | 2 ++
3 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index f9904e708c35..cb25255e5bf4 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -2006,7 +2006,10 @@ static int process_ploop_fsync_work(struct ploop *ploop, struct llist_node *llfl
if (static_branch_unlikely(&ploop_standby_check))
ploop_check_standby_mode(ploop, ret);
}
- ploop_pio_endio(pio);
+ pio->queue_list_id = PLOOP_LIST_FLUSHPIO;
+ atomic_inc(&ploop->kt_worker->fsync_pios);
+ ploop_runners_add_work(ploop, pio);
+ npios++;
}
return npios;
}
@@ -2105,14 +2108,12 @@ void do_ploop_run_work(struct ploop *ploop)
/* Now process fsync pios after we have done all other */
npios = process_ploop_fsync_work(ploop, llflush_pios);
/* Since dispatcher is single thread no other work can be queued */
-#ifdef USE_RUNNERS__NOT_READY
if (npios) {
current->flags = old_flags;
wait_event_interruptible(ploop->dispatcher_wq_fsync,
- atomic_read(&wrkr->fsync_pios) != 0);
+ !atomic_read(&ploop->kt_worker->fsync_pios));
current->flags |= PF_IO_THREAD|PF_LOCAL_THROTTLE|PF_MEMALLOC_NOIO;
}
-#endif
}
current->flags = old_flags;
@@ -2134,6 +2135,7 @@ int ploop_pio_runner(void *data)
struct llist_node *pos, *t;
unsigned int old_flags = current->flags;
int did_process_pios = 0;
+ int did_process_fsync = 0;
for (;;) {
current->flags = old_flags;
@@ -2146,6 +2148,10 @@ int ploop_pio_runner(void *data)
did_process_pios = 0;
wake_up_interruptible(&ploop->dispatcher_wq_data);
}
+ if (did_process_fsync) {
+ did_process_fsync = 0;
+ wake_up_interruptible(&ploop->dispatcher_wq_fsync);
+ }
/* Only stop when there is no more pios */
if (kthread_should_stop()) {
__set_current_state(TASK_RUNNING);
@@ -2170,9 +2176,9 @@ int ploop_pio_runner(void *data)
WARN_ON_ONCE(1); /* We must not see prepares here */
break;
case PLOOP_LIST_FLUSHPIO:
- // fsync pios can come here for endio
- // XXX: make it a FSYNC list
+ did_process_fsync++;
ploop_pio_endio(pio);
+ atomic_dec(&ploop->kt_worker->fsync_pios);
break;
case PLOOP_LIST_DEFERRED:
ploop_process_one_deferred_bio(ploop, pio);
diff --git a/drivers/md/dm-ploop-target.c b/drivers/md/dm-ploop-target.c
index 8b0d2b7ae85b..61190f2f7eae 100644
--- a/drivers/md/dm-ploop-target.c
+++ b/drivers/md/dm-ploop-target.c
@@ -558,6 +558,7 @@ static int ploop_ctr(struct dm_target *ti, unsigned int argc, char **argv)
init_waitqueue_head(&ploop->dispatcher_wq_data);
+ init_waitqueue_head(&ploop->dispatcher_wq_fsync);
ploop->kt_worker = ploop_worker_create(ploop, ploop_worker, "d", 0);
if (!ploop->kt_worker)
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index 11e50ab1293b..7dbe8819acf7 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -153,11 +153,13 @@ struct ploop_worker {
struct llist_head work_llist;
unsigned int runner_id;
atomic_t inflight_pios;
+ atomic_t fsync_pios;
struct ploop_worker *next;
};
struct ploop {
struct wait_queue_head dispatcher_wq_data;
+ struct wait_queue_head dispatcher_wq_fsync;
struct dm_target *ti;
#define PLOOP_PRQ_POOL_SIZE 512 /* Twice nr_requests from blk_mq_init_sched() */
mempool_t *prq_pool;
--
2.43.0
More information about the Devel
mailing list