[Devel] [PATCH RH8 12/14] ploop: Return md page from ploop_bat_entries()

Kirill Tkhai ktkhai at virtuozzo.com
Fri Jun 25 18:10:11 MSK 2021


Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 drivers/md/dm-ploop-cmd.c |    2 +-
 drivers/md/dm-ploop-map.c |    3 ++-
 drivers/md/dm-ploop.h     |    7 +++++--
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c
index 363bf18371d6..bf9e2c04138a 100644
--- a/drivers/md/dm-ploop-cmd.c
+++ b/drivers/md/dm-ploop-cmd.c
@@ -728,7 +728,7 @@ static int process_update_delta_index(struct ploop *ploop, u8 level,
 	while (sscanf(map, "%u:%u;%n", &clu, &dst_clu, &n) == 2) {
 		if (clu >= ploop->nr_bat_entries)
 			break;
-		if (ploop_bat_entries(ploop, clu, NULL) == BAT_ENTRY_NONE)
+		if (ploop_bat_entries(ploop, clu, NULL, NULL) == BAT_ENTRY_NONE)
 			break;
 		map += n;
 	}
diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index 0469147586d3..72aec0573ca3 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -1371,6 +1371,7 @@ static int process_one_deferred_bio(struct ploop *ploop, struct pio *pio,
 {
 	sector_t sector = pio->bi_iter.bi_sector;
 	unsigned int clu, dst_clu;
+	struct md_page *md;
 	u8 level;
 	bool ret;
 
@@ -1381,7 +1382,7 @@ static int process_one_deferred_bio(struct ploop *ploop, struct pio *pio,
 	 * and wait synchronously from *this* kwork.
 	 */
 	clu = SEC_TO_CLU(ploop, sector);
-	dst_clu = ploop_bat_entries(ploop, clu, &level);
+	dst_clu = ploop_bat_entries(ploop, clu, &level, &md);
 
 	if (postpone_if_cluster_locked(ploop, pio, clu))
 		goto out;
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index 30bff7fd582e..ebe0c134c148 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -386,7 +386,8 @@ extern struct md_page * md_page_find(struct ploop *ploop, unsigned int id);
  */
 static inline unsigned int ploop_bat_entries(struct ploop *ploop,
 					     unsigned int clu,
-					     u8 *bat_level)
+					     u8 *bat_level,
+					     struct md_page **md_ret)
 {
 	unsigned int *bat_entries, dst_clu, id;
 	struct md_page *md;
@@ -400,6 +401,8 @@ static inline unsigned int ploop_bat_entries(struct ploop *ploop,
 
 	if (bat_level)
 		*bat_level = md->bat_levels[clu];
+	if (md_ret)
+		*md_ret = md;
 
 	bat_entries = kmap_atomic(md->page);
 	dst_clu = bat_entries[clu];
@@ -415,7 +418,7 @@ static inline bool cluster_is_in_top_delta(struct ploop *ploop,
 
 	if (WARN_ON(clu >= ploop->nr_bat_entries))
 		return false;
-	dst_clu = ploop_bat_entries(ploop, clu, &level);
+	dst_clu = ploop_bat_entries(ploop, clu, &level, NULL);
 
 	if (dst_clu == BAT_ENTRY_NONE || level < top_level(ploop))
 		return false;




More information about the Devel mailing list