[Devel] [PATCH RH8 08/18] ploop: Refactor submit_pio()

Kirill Tkhai ktkhai at virtuozzo.com
Wed Jun 16 18:46:57 MSK 2021


Make only "list_splice_tail" entry point for both workers.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 drivers/md/dm-ploop-map.c |   21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index ef37874e8991..73d44122361b 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -1632,11 +1632,16 @@ static noinline struct bio_vec *create_bvec_from_rq(struct request *rq)
 
 static noinline void submit_pio(struct ploop *ploop, struct pio *pio)
 {
+	struct list_head *queue_list;
+	struct work_struct *worker;
 	unsigned long flags;
 	LIST_HEAD(list);
 	int ret;
 
 	if (pio->bi_iter.bi_size) {
+		queue_list = &ploop->deferred_pios;
+		worker = &ploop->worker;
+
 		if (ploop_pio_valid(ploop, pio) < 0)
 			goto kill;
 
@@ -1645,20 +1650,20 @@ static noinline void submit_pio(struct ploop *ploop, struct pio *pio)
 			pio->bi_status = BLK_STS_RESOURCE;
 			goto endio;
 		}
-		list_add(&pio->list, &list);
+	} else {
+		queue_list = &ploop->flush_pios;
+		worker = &ploop->fsync_worker;
 
-		defer_pios(ploop, NULL, &list);
-		goto out;
+		if (WARN_ON_ONCE(pio->bi_op != REQ_OP_FLUSH))
+			goto kill;
 	}
 
-	if (WARN_ON_ONCE(pio->bi_op != REQ_OP_FLUSH))
-		goto kill;
+	list_add(&pio->list, &list);
 
 	spin_lock_irqsave(&ploop->deferred_lock, flags);
-	list_add_tail(&pio->list, &ploop->flush_pios);
+	list_splice_tail(&list, queue_list);
 	spin_unlock_irqrestore(&ploop->deferred_lock, flags);
-	queue_work(ploop->wq, &ploop->fsync_worker);
-out:
+	queue_work(ploop->wq, worker);
 	return;
 kill:
 	pio->bi_status = BLK_STS_IOERR;




More information about the Devel mailing list