[Devel] [PATCH RHEL8 COMMIT] ploop: Add endio_cb

Konstantin Khorenko khorenko at virtuozzo.com
Mon May 17 19:04:54 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.30
------>
commit 8524fe259b8eead0b596e19640fbcc761611cda4
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Mon May 17 19:04:54 2021 +0300

    ploop: Add endio_cb
    
    Similar to bio->bi_end_io but for pio
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
    
    =====================
    Patchset description:
    
    dm-ploop: Kill loop
    
    Intermediate patches can't be base for bisect.
    
    In scope of https://jira.sw.ru/browse/PSBM-123654
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 drivers/md/dm-ploop-map.c | 16 +++++++++++++---
 drivers/md/dm-ploop.h     |  6 ++++++
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index aebee550f7a3..fec9d16d8c0d 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -123,14 +123,22 @@ static int ploop_pio_cluster(struct ploop *ploop, struct pio *pio,
 	return 0;
 }
 
-void pio_endio(struct pio *pio)
+static void call_bio_endio(struct pio *pio, void *data, blk_status_t bi_status)
 {
-	struct bio *bio = dm_bio_from_per_bio_data(pio, sizeof(*pio));
+	struct bio *bio = data;
 
-	bio->bi_status = pio->bi_status;
+	bio->bi_status = bi_status;
 	bio_endio(bio);
 }
 
+void pio_endio(struct pio *pio)
+{
+	ploop_endio_t endio_cb = pio->endio_cb;
+	void *endio_cb_data = pio->endio_cb_data;
+
+	endio_cb(pio, endio_cb_data, pio->bi_status);
+}
+
 void defer_pios(struct ploop *ploop, struct pio *pio, struct list_head *pio_list)
 {
 	unsigned long flags;
@@ -1632,6 +1640,8 @@ int ploop_map(struct dm_target *ti, struct bio *bio)
 	pio->bi_iter = bio->bi_iter;
 	pio->bi_io_vec = bio->bi_io_vec;
 	pio->bi_opf = bio->bi_opf;
+	pio->endio_cb = call_bio_endio;
+	pio->endio_cb_data = bio;
 
 	if (pio->bi_iter.bi_size) {
 		if (ploop_pio_cluster(ploop, pio, &cluster) < 0)
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index a35770437dc6..dad0e5857a50 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -229,6 +229,9 @@ struct ploop {
 	spinlock_t pb_lock;
 };
 
+struct pio;
+typedef void (*ploop_endio_t)(struct pio *, void *, blk_status_t);
+
 struct pio {
 	struct list_head list;
 
@@ -241,6 +244,9 @@ struct pio {
 	unsigned int		bi_opf;
 	blk_status_t bi_status;
 
+	ploop_endio_t endio_cb;
+	void *endio_cb_data;
+
 	unsigned int cluster;
 
 #define PLOOP_END_IO_NONE		0


More information about the Devel mailing list