[Devel] [PATCH RHEL8 COMMIT] ploop: Introduce find_endio_hook_range()

Konstantin Khorenko khorenko at virtuozzo.com
Fri Oct 18 14:36:58 MSK 2019


The commit is pushed to "branch-rh8-4.18.0-80.1.2.vz8.2.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-80.1.2.vz8.2.2
------>
commit 15be4a79c618f075689c4621f275c77f3076925e
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Fri Oct 18 14:36:57 2019 +0300

    ploop: Introduce find_endio_hook_range()
    
    Introduce this function to more effective search
    of range of hooks.
    
    Fixes: 398e0c85e871 ("dm: Interpreter of ploop1 format (ploop driver)")
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 drivers/md/dm-ploop-cmd.c | 12 +++++++-----
 drivers/md/dm-ploop-map.c | 11 ++++++-----
 drivers/md/dm-ploop.h     | 12 +++++++++---
 3 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c
index bde9ae11a625..0ad873a15411 100644
--- a/drivers/md/dm-ploop-cmd.c
+++ b/drivers/md/dm-ploop-cmd.c
@@ -1483,12 +1483,14 @@ static int ploop_push_backup_write(struct ploop *ploop, char *uuid,
 		return -ESTALE;
 
 	spin_lock_irq(&ploop->pb_lock);
-	for (i = cluster; i < cluster + nr; i++) {
+	for (i = cluster; i < cluster + nr; i++)
 		clear_bit(i, pb->ppb_map);
-		/* TODO: optimize by introduction find_endio_hook_after() */
-		h = find_endio_hook(ploop, &pb->rb_root, i);
-		if (h)
-			unlink_postponed_backup_endio(ploop, &bio_list, h);
+	for (i = 0; i < nr; i++) {
+		h = find_endio_hook_range(ploop, &pb->rb_root, cluster,
+					  cluster + nr - 1);
+		if (!h)
+			break;
+		unlink_postponed_backup_endio(ploop, &bio_list, h);
 	}
 
 	has_more = !RB_EMPTY_ROOT(&pb->rb_root);
diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index faa334e4d8a1..0fad19c69fa8 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -222,18 +222,19 @@ static int ploop_map_discard(struct ploop *ploop, struct bio *bio)
 	return DM_MAPIO_SUBMITTED;
 }
 
-struct dm_ploop_endio_hook *find_endio_hook(struct ploop *ploop,
-					    struct rb_root *root,
-					    unsigned int cluster)
+struct dm_ploop_endio_hook *find_endio_hook_range(struct ploop *ploop,
+						  struct rb_root *root,
+						  unsigned int left,
+						  unsigned int right)
 {
 	struct rb_node *node = root->rb_node;
 	struct dm_ploop_endio_hook *h;
 
 	while (node) {
 		h = rb_entry(node, struct dm_ploop_endio_hook, node);
-		if (cluster < h->cluster)
+		if (right < h->cluster)
 			node = node->rb_left;
-		else if (cluster > h->cluster)
+		else if (left > h->cluster)
 			node = node->rb_right;
 		else
 			return h;
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index ea6917d13835..02b496d7b7c3 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -343,6 +343,15 @@ static inline void track_bio(struct ploop *ploop, struct bio *bio)
 		__track_bio(ploop, bio);
 }
 
+extern struct dm_ploop_endio_hook *find_endio_hook_range(struct ploop *ploop,
+			struct rb_root *root, unsigned int l, unsigned int r);
+
+static inline struct dm_ploop_endio_hook *find_endio_hook(struct ploop *ploop,
+				   struct rb_root *root, unsigned int cluster)
+{
+	return find_endio_hook_range(ploop, root, cluster, cluster);
+}
+
 extern int ploop_add_delta(struct ploop *ploop, const char *arg);
 extern void defer_bio(struct ploop *ploop, struct bio *bio);
 extern void defer_bio_list(struct ploop *ploop, struct bio_list *bio_list);
@@ -354,9 +363,6 @@ extern int ploop_endio(struct dm_target *ti, struct bio *bio, blk_status_t *err)
 extern void ploop_inflight_bios_ref_switch(struct ploop *ploop);
 extern struct dm_ploop_endio_hook *find_lk_of_cluster(struct ploop *ploop,
 						      unsigned int cluster);
-extern struct dm_ploop_endio_hook *find_endio_hook(struct ploop *ploop,
-						   struct rb_root *root,
-						   unsigned int cluster);
 extern void unlink_postponed_backup_endio(struct ploop *ploop,
 					  struct bio_list *bio_list,
 					  struct dm_ploop_endio_hook *h);



More information about the Devel mailing list