[Devel] [PATCH RH8] ploop: Don't forget about nr_inflight after stop

Kirill Tkhai ktkhai at virtuozzo.com
Wed Jul 7 14:03:10 MSK 2021


We need to call inc_nr_inflight() for pios, which
are resubmitted after submission was stopped.
Refactor code to allow both the places to use
the same function.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 drivers/md/dm-ploop-cmd.c |    2 +-
 drivers/md/dm-ploop-map.c |   55 +++++++++++++++++++++++++++------------------
 drivers/md/dm-ploop.h     |    1 +
 3 files changed, 35 insertions(+), 23 deletions(-)

diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c
index f989d2ab008b..137067cccd47 100644
--- a/drivers/md/dm-ploop-cmd.c
+++ b/drivers/md/dm-ploop-cmd.c
@@ -140,7 +140,7 @@ static void ploop_resume_submitting_pios(struct ploop *ploop)
 	list_splice_tail_init(&ploop->suspended_pios, &list);
 	spin_unlock_irq(&ploop->deferred_lock);
 
-	dispatch_pios(ploop, NULL, &list);
+	submit_embedded_pios(ploop, &list);
 }
 
 /* Find existing BAT clu pointing to dst_clu */
diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index ca7f841cb8b8..00e4a6ad1d92 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -78,10 +78,8 @@ void init_pio(struct ploop *ploop, unsigned int bi_op, struct pio *pio)
 }
 
 /* Get clu related to pio sectors */
-static int ploop_prq_valid(struct ploop *ploop, struct ploop_rq *prq)
+static int ploop_rq_valid(struct ploop *ploop, struct request *rq)
 {
-	struct request *rq = prq->rq;
-
 	sector_t sector = blk_rq_pos(rq);
 	loff_t end_byte;
 	u32 end_clu;
@@ -1772,36 +1770,21 @@ static void init_prq(struct ploop_rq *prq, struct request *rq)
 	prq->bvec = NULL;
 }
 
-int ploop_clone_and_map(struct dm_target *ti, struct request *rq,
-		    union map_info *info, struct request **clone)
+static void submit_embedded_pio(struct ploop *ploop, struct pio *pio)
 {
-	struct ploop *ploop = ti->private;
+	struct ploop_rq *prq = embedded_pio_to_prq(pio);
+	struct request *rq = prq->rq;
 	struct work_struct *worker;
-	struct ploop_rq *prq;
 	unsigned long flags;
 	bool queue = true;
-	struct pio *pio;
-
-	prq = map_info_to_embedded_prq(info);
-	init_prq(prq, rq);
-
-	pio = map_info_to_embedded_pio(info);
-	init_pio(ploop, req_op(rq), pio);
-	pio->endio_cb = prq_endio;
-	pio->endio_cb_data = prq;
 
 	if (blk_rq_bytes(rq)) {
-		if (ploop_prq_valid(ploop, prq) < 0)
-			return DM_MAPIO_KILL;
-
 		pio->queue_list_id = PLOOP_LIST_PREPARE;
 		worker = &ploop->worker;
 	} else {
+		WARN_ON_ONCE(pio->bi_op != REQ_OP_FLUSH);
 		pio->queue_list_id = PLOOP_LIST_FLUSH;
 		worker = &ploop->fsync_worker;
-
-		if (WARN_ON_ONCE(pio->bi_op != REQ_OP_FLUSH))
-			return DM_MAPIO_KILL;
 	}
 
 	spin_lock_irqsave(&ploop->deferred_lock, flags);
@@ -1818,7 +1801,35 @@ int ploop_clone_and_map(struct dm_target *ti, struct request *rq,
 
 	if (queue)
 		queue_work(ploop->wq, worker);
+}
+
+void submit_embedded_pios(struct ploop *ploop, struct list_head *list)
+{
+	struct pio *pio;
+
+	while ((pio = pio_list_pop(list)) != NULL)
+		submit_embedded_pio(ploop, pio);
+}
+
+int ploop_clone_and_map(struct dm_target *ti, struct request *rq,
+		    union map_info *info, struct request **clone)
+{
+	struct ploop *ploop = ti->private;
+	struct ploop_rq *prq;
+	struct pio *pio;
+
+	if (blk_rq_bytes(rq) && ploop_rq_valid(ploop, rq) < 0)
+		return DM_MAPIO_KILL;
+
+	prq = map_info_to_embedded_prq(info);
+	init_prq(prq, rq);
+
+	pio = map_info_to_embedded_pio(info);
+	init_pio(ploop, req_op(rq), pio);
+	pio->endio_cb = prq_endio;
+	pio->endio_cb_data = prq;
 
+	submit_embedded_pio(ploop, pio);
 	return DM_MAPIO_SUBMITTED;
 }
 
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index 9c4b77852c18..d766a3381205 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -552,6 +552,7 @@ extern bool try_update_bat_entry(struct ploop *ploop, u32 clu,
 
 extern int ploop_add_delta(struct ploop *ploop, u32 level, struct file *file, bool is_raw);
 extern int ploop_check_delta_length(struct ploop *ploop, struct file *file, loff_t *file_size);
+extern void submit_embedded_pios(struct ploop *ploop, struct list_head *list);
 extern void dispatch_pios(struct ploop *ploop, struct pio *pio, struct list_head *pio_list);
 extern void do_ploop_work(struct work_struct *ws);
 extern void do_ploop_fsync_work(struct work_struct *ws);




More information about the Devel mailing list