[Devel] [PATCH RHEL9 COMMIT] dm-ploop: Remove tracking code

Konstantin Khorenko khorenko at virtuozzo.com
Fri Nov 12 19:12:56 MSK 2021


The commit is pushed to "branch-rh9-5.14.vz9.1.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh9-5.14.0-4.vz9.10.26
------>
commit 4e7275c2ed27a5f8a9ba0aafd3611abd6c5a7d32
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Thu Oct 28 15:35:36 2021 +0000

    dm-ploop: Remove tracking code
    
    We use generic driver instead.
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 drivers/md/dm-ploop-cmd.c    | 165 -------------------------------------------
 drivers/md/dm-ploop-map.c    |  38 ----------
 drivers/md/dm-ploop-target.c |   3 -
 drivers/md/dm-ploop.h        |  13 ----
 4 files changed, 219 deletions(-)

diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c
index 3ba866cb0ec0..ed46da98b8d7 100644
--- a/drivers/md/dm-ploop-cmd.c
+++ b/drivers/md/dm-ploop-cmd.c
@@ -249,7 +249,6 @@ static int ploop_write_cluster_sync(struct ploop *ploop, struct pio *pio,
 	if (pio->bi_status)
 		return blk_status_to_errno(pio->bi_status);
 
-	/* track_bio(ploop, bio); */
 	return vfs_fsync(file, 0);
 }
 
@@ -982,166 +981,6 @@ static int ploop_set_falloc_new_clu(struct ploop *ploop, u64 val)
 	return 0;
 }
 
-static int process_tracking_start(struct ploop *ploop, void *tracking_bitmap,
-				  u32 tb_nr)
-{
-	u32 i, nr_pages, end, *bat_entries, dst_clu, nr;
-	struct rb_node *node;
-	struct md_page *md;
-	int ret = 0;
-
-	write_lock_irq(&ploop->bat_rwlock);
-	ploop->tracking_bitmap = tracking_bitmap;
-	ploop->tb_nr = tb_nr;
-
-	for_each_clear_bit(i, ploop->holes_bitmap, ploop->hb_nr)
-		set_bit(i, tracking_bitmap);
-	nr_pages = bat_clu_to_page_nr(ploop->nr_bat_entries - 1) + 1;
-	nr = 0;
-
-	ploop_for_each_md_page(ploop, md, node) {
-		ploop_init_be_iter(ploop, md->id, &i, &end);
-		bat_entries = kmap_atomic(md->page);
-		for (; i <= end; i++) {
-			dst_clu = bat_entries[i];
-			if (dst_clu == BAT_ENTRY_NONE ||
-			    md->bat_levels[i] != top_level(ploop))
-				continue;
-			if (WARN_ON(dst_clu >= tb_nr)) {
-				ret = -EIO;
-				break;
-			}
-			set_bit(dst_clu, tracking_bitmap);
-		}
-		kunmap_atomic(bat_entries);
-		if (ret)
-			break;
-		nr++;
-	}
-	write_unlock_irq(&ploop->bat_rwlock);
-
-	BUG_ON(ret == 0 && nr != nr_pages);
-	return ret;
-}
-
-static int tracking_get_next(struct ploop *ploop, char *result,
-			     unsigned int maxlen)
-{
-	unsigned int i, sz = 0, tb_nr = ploop->tb_nr, prev = ploop->tb_cursor;
-	void *tracking_bitmap = ploop->tracking_bitmap;
-	int ret = -EAGAIN;
-
-	if (WARN_ON_ONCE(prev > tb_nr - 1))
-		prev = 0;
-
-	write_lock_irq(&ploop->bat_rwlock);
-	i = find_next_bit(tracking_bitmap, tb_nr, prev + 1);
-	if (i < tb_nr)
-		goto found;
-	i = find_first_bit(tracking_bitmap, prev + 1);
-	if (i >= prev + 1)
-		goto unlock;
-found:
-	ret = (DMEMIT("%u\n", i)) ? 1 : 0;
-	if (ret)
-		clear_bit(i, tracking_bitmap);
-unlock:
-	write_unlock_irq(&ploop->bat_rwlock);
-	if (ret > 0)
-		ploop->tb_cursor = i;
-	return ret;
-}
-
-static u32 max_dst_clu_in_top_delta(struct ploop *ploop)
-{
-	u32 i, nr_pages, nr = 0, end, *bat_entries, dst_clu = 0;
-	struct rb_node *node;
-	struct md_page *md;
-
-	nr_pages = bat_clu_to_page_nr(ploop->nr_bat_entries - 1) + 1;
-
-	read_lock_irq(&ploop->bat_rwlock);
-	ploop_for_each_md_page(ploop, md, node) {
-		ploop_init_be_iter(ploop, md->id, &i, &end);
-		bat_entries = kmap_atomic(md->page);
-		for (; i <= end; i++) {
-			if (dst_clu < bat_entries[i] &&
-			    md->bat_levels[i] == top_level(ploop))
-				dst_clu = bat_entries[i];
-		}
-		kunmap_atomic(bat_entries);
-		nr++;
-	}
-	read_unlock_irq(&ploop->bat_rwlock);
-
-	BUG_ON(nr != nr_pages);
-	return dst_clu;
-}
-
-static int ploop_tracking_cmd(struct ploop *ploop, const char *suffix,
-			      char *result, unsigned int maxlen)
-{
-	void *tracking_bitmap = NULL;
-	unsigned int tb_nr, size;
-	int ret = 0;
-
-	if (ploop_is_ro(ploop))
-		return -EROFS;
-
-	if (!strcmp(suffix, "get_next")) {
-		if (!ploop->tracking_bitmap)
-			return -ENOENT;
-		return tracking_get_next(ploop, result, maxlen);
-	}
-
-	if (!strcmp(suffix, "start")) {
-		if (ploop->tracking_bitmap)
-			return -EEXIST;
-		if (ploop->maintaince)
-			return -EBUSY;
-		/* max_dst_clu_in_top_delta() may be above hb_nr */
-		tb_nr = max_dst_clu_in_top_delta(ploop) + 1;
-		if (tb_nr < ploop->hb_nr)
-			tb_nr = ploop->hb_nr;
-		/*
-		 * After max_dst_clu_in_top_delta() unlocks the lock,
-		 * new entries above tb_nr can't occur, since we always
-		 * alloc clusters from holes_bitmap (and they nr < hb_nr).
-		 */
-		size = DIV_ROUND_UP(tb_nr, 8 * sizeof(unsigned long));
-		size *= sizeof(unsigned long);
-		tracking_bitmap = kvzalloc(size, GFP_KERNEL);
-		if (!tracking_bitmap)
-			return -ENOMEM;
-		ploop->tb_cursor = tb_nr - 1;
-
-		ret = ploop_suspend_submitting_pios(ploop);
-		if (ret)
-			return ret;
-
-		ploop->maintaince = true;
-		ret = process_tracking_start(ploop, tracking_bitmap, tb_nr);
-
-		ploop_resume_submitting_pios(ploop);
-
-		if (ret)
-			goto stop;
-	} else if (!strcmp(suffix, "stop")) {
-		if (!ploop->tracking_bitmap)
-			return -ENOENT;
-stop:
-		write_lock_irq(&ploop->bat_rwlock);
-		kvfree(ploop->tracking_bitmap);
-		ploop->tracking_bitmap = NULL;
-		write_unlock_irq(&ploop->bat_rwlock);
-		ploop->maintaince = false;
-	} else {
-		return -EINVAL;
-	}
-
-	return ret;
-}
-
 static int ploop_set_noresume(struct ploop *ploop, char *mode)
 {
 	bool noresume;
@@ -1315,10 +1154,6 @@ int ploop_message(struct dm_target *ti, unsigned int argc, char **argv,
 		if (argc != 2 || kstrtou64(argv[1], 10, &val) < 0)
 			goto unlock;
 		ret = ploop_set_falloc_new_clu(ploop, val);
-	} else if (!strncmp(argv[0], "tracking_", 9)) {
-		if (argc != 1)
-			goto unlock;
-		ret = ploop_tracking_cmd(ploop, argv[0] + 9, result, maxlen);
 	} else if (!strcmp(argv[0], "set_noresume")) {
 		if (argc != 2)
 			goto unlock;
diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index a558445a1bec..8c356de05469 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -227,9 +227,6 @@ void pio_endio(struct pio *pio)
 {
 	struct ploop *ploop = pio->ploop;
 
-	if (pio->ref_index != PLOOP_REF_INDEX_INVALID)
-		track_pio(ploop, pio);
-
 	handle_cleanup(ploop, pio);
 
 	do_pio_endio(pio);
@@ -385,37 +382,6 @@ static bool delay_if_md_busy(struct ploop *ploop, struct md_page *md,
 	return busy;
 }
 
-void track_dst_cluster(struct ploop *ploop, u32 dst_clu)
-{
-	unsigned long flags;
-
-	if (!ploop->tracking_bitmap)
-		return;
-
-	read_lock_irqsave(&ploop->bat_rwlock, flags);
-	if (ploop->tracking_bitmap && !WARN_ON(dst_clu >= ploop->tb_nr))
-		set_bit(dst_clu, ploop->tracking_bitmap);
-	read_unlock_irqrestore(&ploop->bat_rwlock, flags);
-}
-
-/*
- * Userspace calls dm_suspend() to get changed blocks finally.
- * dm_suspend() waits for dm's inflight bios, so this function
- * must be called after @bio is written and before @bio is ended.
- * The only possible exception is writes driven by "message" ioctl.
- * Thus, userspace mustn't do maintaince operations in parallel
- * with tracking.
- */
-void __track_pio(struct ploop *ploop, struct pio *pio)
-{
-	u32 dst_clu = SEC_TO_CLU(ploop, pio->bi_iter.bi_sector);
-
-	if (!op_is_write(pio->bi_op) || !bvec_iter_sectors((pio)->bi_iter))
-		return;
-
-	track_dst_cluster(ploop, dst_clu);
-}
-
 static void queue_discard_index_wb(struct ploop *ploop, struct pio *pio)
 {
 	pio->queue_list_id = PLOOP_LIST_DISCARD;
@@ -1574,10 +1540,6 @@ static void md_write_endio(struct pio *pio, void *piwb_ptr, blk_status_t bi_stat
 {
 	struct ploop_index_wb *piwb = piwb_ptr;
 	struct ploop *ploop = piwb->ploop;
-	u32 dst_clu;
-
-	dst_clu = POS_TO_CLU(ploop, (u64)piwb->page_id << PAGE_SHIFT);
-	track_dst_cluster(ploop, dst_clu);
 
 	if (bi_status) {
 		md_fsync_endio(pio, piwb, bi_status);
diff --git a/drivers/md/dm-ploop-target.c b/drivers/md/dm-ploop-target.c
index 0d693ccd387d..ad4207156e20 100644
--- a/drivers/md/dm-ploop-target.c
+++ b/drivers/md/dm-ploop-target.c
@@ -179,7 +179,6 @@ static void ploop_destroy(struct ploop *ploop)
 	mempool_destroy(ploop->prq_pool);
 	kfree(ploop->deltas);
 	kvfree(ploop->holes_bitmap);
-	kvfree(ploop->tracking_bitmap);
 	free_md_pages_tree(&ploop->bat_entries);
 	kfree(ploop);
 }
@@ -451,8 +450,6 @@ static void ploop_status(struct dm_target *ti, status_type_t type,
 	down_read(&ploop->ctl_rwsem);
 	if (ploop->falloc_new_clu)
 		*p++ = 'f';
-	if (ploop->tracking_bitmap)
-		*p++ = 't';
 	if (READ_ONCE(ploop->noresume))
 		*p++ = 'n';
 	if (READ_ONCE(ploop->event_enospc))
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index 0a4c6b78e20e..05824851ba92 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -165,10 +165,6 @@ struct ploop {
 
 	struct list_head wb_batch_list;
 
-	void *tracking_bitmap;
-	unsigned int tb_nr; /* tracking_bitmap size in bits */
-	unsigned int tb_cursor;
-
 	/*
 	 * Hash table to link non-exclusive submitted bios.
 	 * This is needed for discard to check, nobody uses
@@ -486,15 +482,6 @@ static inline void ploop_init_be_iter(struct ploop *ploop, u32 page_id,
 	init_be_iter(ploop->nr_bat_entries, page_id, start, end);
 }
 
-extern void __track_pio(struct ploop *ploop, struct pio *pio);
-
-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_pio(ploop, pio);
-}
-
 extern struct pio *find_pio(struct hlist_head head[], u32 clu);
 
 extern int prealloc_md_pages(struct rb_root *root, u32 nr_bat_entries,


More information about the Devel mailing list