[Devel] [PATCH VZ9 v3 05/13] dm-ploop: reduce BAT accesses on discard completion

Andrey Zhadchenko andrey.zhadchenko at virtuozzo.com
Thu Oct 24 20:23:33 MSK 2024


Drop extra ploop_cluster_is_in_top_delta() as we are planning to
access BAT anyway

https://virtuozzo.atlassian.net/browse/VSTOR-91817
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
---
 drivers/md/dm-ploop-map.c | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index 45278f32ec1a..3e774bdafb4a 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -697,12 +697,15 @@ static void ploop_complete_cow(struct ploop_cow *cow, blk_status_t bi_status)
 	kmem_cache_free(cow_cache, cow);
 }
 
-static void ploop_release_cluster(struct ploop *ploop, u32 clu)
+static void ploop_piwb_discard_completed(struct ploop *ploop,
+					 bool success, u32 clu, u32 new_dst_clu)
 {
 	u32 id, *bat_entries, dst_clu;
 	struct md_page *md;
+	u8 level;
 
-	lockdep_assert_held(&ploop->bat_rwlock);
+	if (new_dst_clu)
+		return;
 
 	id = ploop_bat_clu_to_page_nr(clu);
 	md = ploop_md_page_find(ploop, id);
@@ -712,22 +715,15 @@ static void ploop_release_cluster(struct ploop *ploop, u32 clu)
 
 	bat_entries = md->kmpage;
 	dst_clu = READ_ONCE(bat_entries[clu]);
-	WRITE_ONCE(bat_entries[clu], BAT_ENTRY_NONE);
-	WRITE_ONCE(md->bat_levels[clu], 0);
+	level = md->bat_levels[clu];
 
-	ploop_hole_set_bit(dst_clu, ploop);
-}
-
-static void ploop_piwb_discard_completed(struct ploop *ploop,
-					 bool success, u32 clu, u32 new_dst_clu)
-{
-	if (new_dst_clu)
-		return;
-
-	if (ploop_cluster_is_in_top_delta(ploop, clu)) {
+	if (!(dst_clu == BAT_ENTRY_NONE || level < ploop_top_level(ploop))) {
 		WARN_ON_ONCE(ploop->nr_deltas != 1);
-		if (success)
-			ploop_release_cluster(ploop, clu);
+		if (success) {
+			WRITE_ONCE(bat_entries[clu], BAT_ENTRY_NONE);
+			WRITE_ONCE(md->bat_levels[clu], 0);
+			ploop_hole_set_bit(dst_clu, ploop);
+		}
 	}
 }
 
-- 
2.39.3



More information about the Devel mailing list