[Devel] [PATCH RHEL8 COMMIT] ploop: Convert track_bio()

Konstantin Khorenko khorenko at virtuozzo.com
Mon May 17 19:04:53 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 9b09cf93d685633a3067d86fe01c0edcb25c5a45
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Mon May 17 19:04:53 2021 +0300

    ploop: Convert track_bio()
    
    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, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index 26480c713cd6..ef3e2a571de4 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -149,6 +149,9 @@ void track_dst_cluster(struct ploop *ploop, u32 dst_cluster)
 {
 	unsigned long flags;
 
+	if (!ploop->tracking_bitmap)
+		return;
+
 	read_lock_irqsave(&ploop->bat_rwlock, flags);
 	if (ploop->tracking_bitmap && !WARN_ON(dst_cluster >= ploop->tb_nr))
 		set_bit(dst_cluster, ploop->tracking_bitmap);
@@ -163,15 +166,13 @@ void track_dst_cluster(struct ploop *ploop, u32 dst_cluster)
  * Thus, userspace mustn't do maintaince operations in parallel
  * with tracking.
  */
-void __track_bio(struct ploop *ploop, struct bio *bio)
+void __track_pio(struct ploop *ploop, struct pio *pio)
 {
-	unsigned int dst_cluster = bio->bi_iter.bi_sector >> ploop->cluster_log;
+	unsigned int dst_cluster = pio->bi_iter.bi_sector >> ploop->cluster_log;
 
-	if (!op_is_write(bio->bi_opf) || !bio_sectors(bio))
+	if (!op_is_write(pio->bi_opf) || !bvec_iter_sectors((pio)->bi_iter))
 		return;
 
-	WARN_ON_ONCE(bio->bi_disk != ploop->origin_dev->bdev->bd_disk);
-
 	track_dst_cluster(ploop, dst_cluster);
 }
 
@@ -970,9 +971,10 @@ static void ploop_cow_endio(struct bio *cluster_bio)
 {
 	struct ploop_cow *cow = cluster_bio->bi_private;
 	struct ploop *ploop = cow->ploop;
+	unsigned int dst_cluster = cluster_bio->bi_iter.bi_sector >> ploop->cluster_log;
 	unsigned long flags;
 
-	track_bio(ploop, cluster_bio);
+	track_dst_cluster(ploop, dst_cluster);
 
 	spin_lock_irqsave(&ploop->deferred_lock, flags);
 	bio_list_add(&ploop->delta_cow_action_list, cluster_bio);
@@ -1667,7 +1669,7 @@ int ploop_endio(struct dm_target *ti, struct bio *bio, blk_status_t *err)
 		 * and for data bios. Check for ref_index to not
 		 * track @bio twice.
 		 */
-		track_bio(ploop, bio);
+		track_pio(ploop, pio);
 	}
 	/*
 	 * This function is called from the very beginning
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index 581ebc999c8b..a35770437dc6 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -477,13 +477,13 @@ static inline void init_bat_entries_iter(struct ploop *ploop, unsigned int page_
 		*end = ((ploop->nr_bat_entries + PLOOP_MAP_OFFSET) % count) - 1;
 }
 
-extern void __track_bio(struct ploop *ploop, struct bio *bio);
+extern void __track_pio(struct ploop *ploop, struct pio *pio);
 
-static inline void track_bio(struct ploop *ploop, struct bio *bio)
+static inline void track_pio(struct ploop *ploop, struct pio *pio)
 {
 	/* See comment in process_tracking_start() about visibility */
 	if (unlikely(ploop->tracking_bitmap))
-		__track_bio(ploop, bio);
+		__track_pio(ploop, pio);
 }
 
 extern struct pio *find_endio_hook_range(struct ploop *ploop, struct rb_root *root,


More information about the Devel mailing list