[Devel] [PATCH RH8 22/22] ploop: Underline clu and page is u32

Kirill Tkhai ktkhai at virtuozzo.com
Wed Jun 30 13:34:47 MSK 2021


Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 drivers/md/dm-ploop-bat.c |   28 ++++++++----------
 drivers/md/dm-ploop-cmd.c |   37 +++++++++++------------
 drivers/md/dm-ploop-map.c |   65 ++++++++++++++++++-----------------------
 drivers/md/dm-ploop.h     |   72 +++++++++++++++++++++------------------------
 4 files changed, 92 insertions(+), 110 deletions(-)

diff --git a/drivers/md/dm-ploop-bat.c b/drivers/md/dm-ploop-bat.c
index 53a51871b0b2..1ae863043f50 100644
--- a/drivers/md/dm-ploop-bat.c
+++ b/drivers/md/dm-ploop-bat.c
@@ -11,7 +11,7 @@
 #include <linux/mm.h>
 #include "dm-ploop.h"
 
-struct md_page * md_page_find(struct ploop *ploop, unsigned int id)
+struct md_page * md_page_find(struct ploop *ploop, u32 id)
 {
 	struct rb_node *node;
 	struct md_page *md;
@@ -33,8 +33,8 @@ struct md_page * md_page_find(struct ploop *ploop, unsigned int id)
 
 static void __md_page_insert(struct rb_root *root, struct md_page *new_md)
 {
-	unsigned int new_id = new_md->id;
 	struct rb_node *parent, **node;
+	u32 new_id = new_md->id;
 	struct md_page *md;
 
 	node = &root->rb_node;
@@ -60,7 +60,7 @@ void md_page_insert(struct ploop *ploop, struct md_page *new_md)
 	__md_page_insert(&ploop->bat_entries, new_md);
 }
 
-static struct md_page * alloc_md_page(unsigned int id)
+static struct md_page * alloc_md_page(u32 id)
 {
 	struct md_page *md;
 	struct page *page;
@@ -101,10 +101,10 @@ void ploop_free_md_page(struct md_page *md)
 	kfree(md);
 }
 
-int prealloc_md_pages(struct rb_root *root, unsigned int nr_bat_entries,
-		      unsigned int new_nr_bat_entries)
+int prealloc_md_pages(struct rb_root *root, u32 nr_bat_entries,
+		      u32 new_nr_bat_entries)
 {
-	unsigned int i, nr_pages, new_nr_pages;
+	u32 i, nr_pages, new_nr_pages;
 	struct md_page *md;
 	void *addr;
 
@@ -127,10 +127,9 @@ int prealloc_md_pages(struct rb_root *root, unsigned int nr_bat_entries,
 	return 0;
 }
 
-bool try_update_bat_entry(struct ploop *ploop, unsigned int clu,
-			  u8 level, unsigned int dst_clu)
+bool try_update_bat_entry(struct ploop *ploop, u32 clu, u8 level, u32 dst_clu)
 {
-	unsigned int *bat_entries, id = bat_clu_to_page_nr(clu);
+	u32 *bat_entries, id = bat_clu_to_page_nr(clu);
 	struct md_page *md = md_page_find(ploop, id);
 
 	lockdep_assert_held(&ploop->bat_rwlock);
@@ -239,10 +238,9 @@ int ploop_read_bat(struct ploop *ploop, struct bio *bio, u8 nr_deltas)
 #endif
 
 /* Alloc holes_bitmap and set bits of free clusters */
-static int ploop_setup_holes_bitmap(struct ploop *ploop,
-				    unsigned int bat_clusters)
+static int ploop_setup_holes_bitmap(struct ploop *ploop, u32 bat_clusters)
 {
-	unsigned int i, size;
+	u32 i, size;
 
 	/*
 	 * + number of data clusters.
@@ -269,8 +267,8 @@ static int ploop_setup_holes_bitmap(struct ploop *ploop,
 
 int ploop_setup_metadata(struct ploop *ploop, struct page *page)
 {
-	unsigned int bat_clusters, offset_clusters;
 	struct ploop_pvd_header *m_hdr = NULL;
+	u32 bat_clusters, offset_clusters;
 	unsigned long size;
 	int ret;
 
@@ -318,7 +316,7 @@ static int ploop_delta_check_header(struct ploop *ploop,
 				    struct ploop_pvd_header *d_hdr,
 				    u32 *delta_nr_be_ret)
 {
-	unsigned int bytes, delta_nr_be, offset_clusters, bat_clusters;
+	u32 bytes, delta_nr_be, offset_clusters, bat_clusters;
 	int ret = -EPROTO;
 
 	if (memcmp(d_hdr->m_Sig, ploop->m_Sig, sizeof(d_hdr->m_Sig)) ||
@@ -420,7 +418,7 @@ static void apply_delta_mappings(struct ploop *ploop, struct ploop_delta *deltas
 {
 	map_index_t *bat_entries, *delta_bat_entries;
 	bool is_top_level, is_raw, stop = false;
-	unsigned int i, end, dst_clu, clu;
+	u32 i, end, dst_clu, clu;
 	struct rb_node *node;
 	struct md_page *md;
 
diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c
index d1ed50ed4772..5104bdff10f8 100644
--- a/drivers/md/dm-ploop-cmd.c
+++ b/drivers/md/dm-ploop-cmd.c
@@ -22,7 +22,7 @@
 static void ploop_advance_holes_bitmap(struct ploop *ploop,
 				       struct ploop_cmd *cmd)
 {
-	unsigned int i, end, size, dst_clu, *bat_entries;
+	u32 i, end, size, dst_clu, *bat_entries;
 	struct rb_node *node;
 	struct md_page *md;
 
@@ -143,11 +143,9 @@ static void ploop_resume_submitting_pios(struct ploop *ploop)
 }
 
 /* Find existing BAT clu pointing to dst_clu */
-static unsigned int ploop_find_bat_entry(struct ploop *ploop,
-					 unsigned int dst_clu,
-					 bool *is_locked)
+static u32 ploop_find_bat_entry(struct ploop *ploop, u32 dst_clu, bool *is_locked)
 {
-	unsigned int i, end, *bat_entries, clu = UINT_MAX;
+	u32 i, end, *bat_entries, clu = U32_MAX;
 	struct rb_node *node;
 	struct md_page *md;
 
@@ -179,8 +177,7 @@ static unsigned int ploop_find_bat_entry(struct ploop *ploop,
 	return clu;
 }
 
-void pio_prepare_offsets(struct ploop *ploop, struct pio *pio,
-			 unsigned int clu)
+void pio_prepare_offsets(struct ploop *ploop, struct pio *pio, u32 clu)
 {
 	int i, nr_pages = nr_pages_in_cluster(ploop);
 
@@ -204,7 +201,7 @@ static void wake_completion(struct pio *pio, void *data, blk_status_t status)
 }
 
 static int ploop_read_cluster_sync(struct ploop *ploop, struct pio *pio,
-				   unsigned int dst_clu)
+				   u32 dst_clu)
 {
 	DECLARE_COMPLETION(completion);
 
@@ -224,7 +221,7 @@ static int ploop_read_cluster_sync(struct ploop *ploop, struct pio *pio,
 }
 
 static int ploop_write_cluster_sync(struct ploop *ploop, struct pio *pio,
-				    unsigned int dst_clu)
+				    u32 dst_clu)
 {
 	struct file *file = top_delta(ploop)->file;
 	DECLARE_COMPLETION(completion);
@@ -251,8 +248,7 @@ static int ploop_write_cluster_sync(struct ploop *ploop, struct pio *pio,
 }
 
 static int ploop_write_zero_cluster_sync(struct ploop *ploop,
-					 struct pio *pio,
-					 unsigned int clu)
+					 struct pio *pio, u32 clu)
 {
 	void *data;
 	int i;
@@ -276,9 +272,9 @@ static void ploop_make_md_wb(struct ploop *ploop, struct md_page *md)
 static int ploop_grow_relocate_cluster(struct ploop *ploop,
 				       struct ploop_cmd *cmd)
 {
-	unsigned int new_dst, clu, dst_clu;
 	struct pio *pio = cmd->resize.pio;
 	struct ploop_index_wb *piwb;
+	u32 new_dst, clu, dst_clu;
 	struct completion comp;
 	struct md_page *md;
 	bool is_locked;
@@ -414,7 +410,7 @@ static void ploop_add_md_pages(struct ploop *ploop, struct rb_root *from)
  */
 static int process_resize_cmd(struct ploop *ploop, struct ploop_cmd *cmd)
 {
-	unsigned int dst_clu;
+	u32 dst_clu;
 	int ret = 0;
 
 	/* Update memory arrays and hb_nr, but do not update nr_bat_entries. */
@@ -502,8 +498,8 @@ void free_pio_with_pages(struct ploop *ploop, struct pio *pio)
 /* TODO: we may delegate this to userspace */
 static int ploop_resize(struct ploop *ploop, sector_t new_sectors)
 {
-	unsigned int nr_bat_entries, nr_old_bat_clusters, nr_bat_clusters;
 	struct ploop_cmd cmd = { .resize.md_pages_root = RB_ROOT };
+	u32 nr_bat_entries, nr_old_bat_clusters, nr_bat_clusters;
 	unsigned int hb_nr, size, old_size;
 	struct ploop_pvd_header *hdr;
 	sector_t old_sectors;
@@ -687,7 +683,7 @@ static int ploop_merge_latest_snapshot(struct ploop *ploop)
 static void notify_delta_merged(struct ploop *ploop, u8 level, void *hdr,
 				bool forward, u32 size_in_clus)
 {
-	unsigned int i, end, *bat_entries, *delta_bat_entries;
+	u32 i, end, *bat_entries, *delta_bat_entries;
 	struct rb_node *node;
 	struct md_page *md;
 	struct file *file;
@@ -748,7 +744,7 @@ static void notify_delta_merged(struct ploop *ploop, u8 level, void *hdr,
 static int process_update_delta_index(struct ploop *ploop, u8 level,
 				      const char *map)
 {
-	unsigned int clu, dst_clu, n;
+	u32 clu, dst_clu, n;
 	int ret;
 
 	write_lock_irq(&ploop->bat_rwlock);
@@ -890,11 +886,12 @@ static int ploop_update_delta_index(struct ploop *ploop, unsigned int level,
 
 static int process_flip_upper_deltas(struct ploop *ploop)
 {
-	unsigned int i, size, end, bat_clusters, hb_nr, *bat_entries;
+	u32 i, end, bat_clusters, hb_nr, *bat_entries;
 	void *holes_bitmap = ploop->holes_bitmap;
 	u8 level = top_level(ploop) - 1;
 	struct rb_node *node;
 	struct md_page *md;
+	u64 size;
 
 	size = (PLOOP_MAP_OFFSET + ploop->nr_bat_entries) * sizeof(map_index_t);
         bat_clusters = DIV_ROUND_UP(size, CLU_SIZE(ploop));
@@ -934,7 +931,7 @@ static int process_flip_upper_deltas(struct ploop *ploop)
 static int process_tracking_start(struct ploop *ploop, void *tracking_bitmap,
 				  u32 tb_nr)
 {
-	unsigned int i, nr_pages, end, *bat_entries, dst_clu, nr;
+	u32 i, nr_pages, end, *bat_entries, dst_clu, nr;
 	struct rb_node *node;
 	struct md_page *md;
 	int ret = 0;
@@ -1001,9 +998,9 @@ static int tracking_get_next(struct ploop *ploop, char *result,
 	return ret;
 }
 
-static unsigned int max_dst_clu_in_top_delta(struct ploop *ploop)
+static u32 max_dst_clu_in_top_delta(struct ploop *ploop)
 {
-	unsigned int i, nr_pages, nr = 0, end, *bat_entries, dst_clu = 0;
+	u32 i, nr_pages, nr = 0, end, *bat_entries, dst_clu = 0;
 	struct rb_node *node;
 	struct md_page *md;
 
diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index 6bd7bd087f4a..15427a5f4154 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -81,8 +81,8 @@ void init_pio(struct ploop *ploop, unsigned int bi_op, struct pio *pio)
 static int ploop_pio_valid(struct ploop *ploop, struct pio *pio)
 {
 	sector_t sector = pio->bi_iter.bi_sector;
-	unsigned int end_clu;
 	loff_t end_byte;
+	u32 end_clu;
 
 	end_byte = to_bytes(sector) + pio->bi_iter.bi_size - 1;
 	end_clu = POS_TO_CLU(ploop, end_byte);
@@ -298,7 +298,7 @@ void track_dst_cluster(struct ploop *ploop, u32 dst_clu)
  */
 void __track_pio(struct ploop *ploop, struct pio *pio)
 {
-	unsigned int dst_clu = SEC_TO_CLU(ploop, pio->bi_iter.bi_sector);
+	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;
@@ -347,13 +347,13 @@ struct pio *find_pio(struct hlist_head head[], u32 clu)
 	return NULL;
 }
 
-static struct pio *find_inflight_bio(struct ploop *ploop, unsigned int clu)
+static struct pio *find_inflight_bio(struct ploop *ploop, u32 clu)
 {
 	lockdep_assert_held(&ploop->inflight_lock);
 	return find_pio(ploop->inflight_pios, clu);
 }
 
-struct pio *find_lk_of_cluster(struct ploop *ploop, unsigned int clu)
+struct pio *find_lk_of_cluster(struct ploop *ploop, u32 clu)
 {
 	lockdep_assert_held(&ploop->deferred_lock);
 	return find_pio(ploop->exclusive_pios, clu);
@@ -440,8 +440,7 @@ static void del_cluster_lk(struct ploop *ploop, struct pio *pio)
 		dispatch_pios(ploop, NULL, &pio_list);
 }
 
-static void link_submitting_pio(struct ploop *ploop, struct pio *pio,
-				unsigned int clu)
+static void link_submitting_pio(struct ploop *ploop, struct pio *pio, u32 clu)
 {
 	unsigned long flags;
 
@@ -521,7 +520,7 @@ static int punch_hole(struct file *file, loff_t pos, loff_t len)
 }
 
 static void handle_discard_pio(struct ploop *ploop, struct pio *pio,
-		     unsigned int clu, unsigned int dst_clu)
+			       u32 clu, u32 dst_clu)
 {
 	struct pio *inflight_h;
 	unsigned long flags;
@@ -598,9 +597,9 @@ static void queue_or_fail(struct ploop *ploop, int err, void *data)
 
 static void complete_cow(struct ploop_cow *cow, blk_status_t bi_status)
 {
-	unsigned int dst_clu = cow->dst_clu;
 	struct pio *aux_pio = cow->aux_pio;
 	struct ploop *ploop = cow->ploop;
+	u32 dst_clu = cow->dst_clu;
 	unsigned long flags;
 	struct pio *cow_pio;
 
@@ -622,10 +621,9 @@ static void 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,
-				  unsigned int clu)
+static void ploop_release_cluster(struct ploop *ploop, u32 clu)
 {
-	unsigned int id, *bat_entries, dst_clu;
+	u32 id, *bat_entries, dst_clu;
 	struct md_page *md;
 
 	lockdep_assert_held(&ploop->bat_rwlock);
@@ -646,7 +644,7 @@ static void ploop_release_cluster(struct ploop *ploop,
 }
 
 static void piwb_discard_completed(struct ploop *ploop, bool success,
-		  unsigned int clu, unsigned int new_dst_clu)
+				   u32 clu, u32 new_dst_clu)
 {
 	if (new_dst_clu)
 		return;
@@ -668,8 +666,8 @@ static void ploop_advance_local_after_bat_wb(struct ploop *ploop,
 					     struct ploop_index_wb *piwb,
 					     bool success)
 {
-	unsigned int i, last, *bat_entries;
 	struct md_page *md = piwb->md;
+	u32 i, last, *bat_entries;
 	map_index_t *dst_clu, off;
 	unsigned long flags;
 	LIST_HEAD(list);
@@ -802,7 +800,7 @@ static void ploop_bat_write_complete(struct ploop_index_wb *piwb,
 static int ploop_prepare_bat_update(struct ploop *ploop, struct md_page *md,
 				    enum piwb_type type)
 {
-	unsigned int i, off, last, *bat_entries;
+	u32 i, off, last, *bat_entries;
 	struct ploop_index_wb *piwb;
 	bool is_last_page = true;
 	u32 page_id = md->id;
@@ -883,7 +881,7 @@ void ploop_break_bat_update(struct ploop *ploop, struct md_page *md)
 
 static void ploop_bat_page_zero_cluster(struct ploop *ploop,
 					struct ploop_index_wb *piwb,
-					unsigned int clu)
+					u32 clu)
 {
 	map_index_t *to;
 
@@ -896,9 +894,9 @@ static void ploop_bat_page_zero_cluster(struct ploop *ploop,
 }
 
 static int find_dst_clu_bit(struct ploop *ploop,
-		      unsigned int *ret_dst_clu)
+		      u32 *ret_dst_clu)
 {
-	unsigned int dst_clu;
+	u32 dst_clu;
 
 	/* Find empty clu */
 	dst_clu = find_first_bit(ploop->holes_bitmap, ploop->hb_nr);
@@ -935,7 +933,7 @@ static int truncate_prealloc_safe(struct ploop_delta *delta, loff_t len, const c
 	return 0;
 }
 
-static int allocate_cluster(struct ploop *ploop, unsigned int *dst_clu)
+static int allocate_cluster(struct ploop *ploop, u32 *dst_clu)
 {
 	struct ploop_delta *top = top_delta(ploop);
 	u32 clu_size = CLU_SIZE(ploop);
@@ -991,7 +989,7 @@ static int allocate_cluster(struct ploop *ploop, unsigned int *dst_clu)
  * in ploop->holes_bitmap and bat_page.
  */
 static int ploop_alloc_cluster(struct ploop *ploop, struct ploop_index_wb *piwb,
-			       unsigned int clu, unsigned int *dst_clu)
+			       u32 clu, u32 *dst_clu)
 {
 	struct page *page = piwb->bat_page;
 	bool already_alloced = false;
@@ -1176,7 +1174,7 @@ void map_and_submit_rw(struct ploop *ploop, u32 dst_clu, struct pio *pio, u8 lev
 }
 
 static void initiate_delta_read(struct ploop *ploop, unsigned int level,
-				unsigned int dst_clu, struct pio *pio)
+				u32 dst_clu, struct pio *pio)
 {
 	if (dst_clu == BAT_ENTRY_NONE) {
 		/* No one delta contains dst_clu. */
@@ -1197,8 +1195,7 @@ static void ploop_cow_endio(struct pio *aux_pio, void *data, blk_status_t bi_sta
 	dispatch_pios(ploop, aux_pio, NULL);
 }
 
-static bool postpone_if_cluster_locked(struct ploop *ploop, struct pio *pio,
-				       unsigned int clu)
+static bool postpone_if_cluster_locked(struct ploop *ploop, struct pio *pio, u32 clu)
 {
 	struct pio *e_h; /* Exclusively locked */
 
@@ -1212,8 +1209,7 @@ static bool postpone_if_cluster_locked(struct ploop *ploop, struct pio *pio,
 }
 
 static int submit_cluster_cow(struct ploop *ploop, unsigned int level,
-			      unsigned int clu, unsigned int dst_clu,
-			      struct pio *cow_pio)
+			      u32 clu, u32 dst_clu, struct pio *cow_pio)
 {
 	struct ploop_cow *cow = NULL;
 	struct pio *aux_pio = NULL;
@@ -1246,7 +1242,7 @@ static int submit_cluster_cow(struct ploop *ploop, unsigned int level,
 }
 
 static void initiate_cluster_cow(struct ploop *ploop, unsigned int level,
-		unsigned int clu, unsigned int dst_clu, struct pio *pio)
+				 u32 clu, u32 dst_clu, struct pio *pio)
 {
 	if (!submit_cluster_cow(ploop, level, clu, dst_clu, pio))
 		return;
@@ -1259,7 +1255,7 @@ static void submit_cluster_write(struct ploop_cow *cow)
 {
 	struct pio *aux_pio = cow->aux_pio;
 	struct ploop *ploop = cow->ploop;
-	unsigned int dst_clu;
+	u32 dst_clu;
 
 	if (allocate_cluster(ploop, &dst_clu) < 0)
 		goto error;
@@ -1281,10 +1277,9 @@ static void submit_cluster_write(struct ploop_cow *cow)
 static void submit_cow_index_wb(struct ploop_cow *cow)
 {
 	struct pio *cow_pio = cow->cow_pio;
-	unsigned int clu = cow_pio->clu;
 	struct ploop *ploop = cow->ploop;
+	u32 page_id, clu = cow_pio->clu;
 	struct ploop_index_wb *piwb;
-	unsigned int page_id;
 	struct md_page *md;
 	map_index_t *to;
 
@@ -1369,14 +1364,13 @@ static void process_delta_cow(struct ploop *ploop, struct list_head *cow_list)
  */
 static bool locate_new_cluster_and_attach_pio(struct ploop *ploop,
 					      struct md_page *md,
-					      unsigned int clu,
-					      unsigned int *dst_clu,
+					      u32 clu, u32 *dst_clu,
 					      struct pio *pio)
 {
 	bool bat_update_prepared = false;
 	struct ploop_index_wb *piwb;
 	bool attached = false;
-	unsigned int page_id;
+	u32 page_id;
 
 	WARN_ON_ONCE(pio->queue_list_id != PLOOP_LIST_DEFERRED);
 	if (delay_if_md_busy(ploop, md, PIWB_TYPE_ALLOC, pio))
@@ -1417,8 +1411,8 @@ static bool locate_new_cluster_and_attach_pio(struct ploop *ploop,
 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;
+	u32 clu, dst_clu;
 	u8 level;
 	bool ret;
 
@@ -1540,8 +1534,8 @@ static void process_deferred_pios(struct ploop *ploop, struct list_head *pios)
 
 static void process_one_discard_pio(struct ploop *ploop, struct pio *pio)
 {
-	unsigned int page_id, clu = pio->clu;
 	bool bat_update_prepared = false;
+	u32 page_id, clu = pio->clu;
 	struct ploop_index_wb *piwb;
 	struct md_page *md;
 	map_index_t *to;
@@ -1841,11 +1835,10 @@ static void handle_cleanup(struct ploop *ploop, struct pio *pio)
  */
 int ploop_prepare_reloc_index_wb(struct ploop *ploop,
 				 struct md_page **ret_md,
-				 unsigned int clu,
-				 unsigned int *dst_clu)
+				 u32 clu, u32 *dst_clu)
 {
-	unsigned int page_id = bat_clu_to_page_nr(clu);
 	enum piwb_type type = PIWB_TYPE_ALLOC;
+	u32 page_id = bat_clu_to_page_nr(clu);
 	struct md_page *md = md_page_find(ploop, page_id);
 	struct ploop_index_wb *piwb;
 
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index 8bb075b72e3f..50663d8aa219 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -69,9 +69,9 @@ struct ploop_cmd {
 	};
 };
 
-#define PAGE_NR_NONE		UINT_MAX
+#define PAGE_NR_NONE		U32_MAX
 /* We can't use 0 for unmapped clusters, since RAW image references 0 clu */
-#define BAT_ENTRY_NONE		UINT_MAX
+#define BAT_ENTRY_NONE		U32_MAX
 
 #define PLOOP_INFLIGHT_TIMEOUT	(60 * HZ)
 #define PLOOP_ENOSPC_TIMEOUT	(20 * HZ)
@@ -104,13 +104,13 @@ struct ploop_index_wb {
 	atomic_t count;
 	bool completed;
 	int bi_status;
-	unsigned int page_id;
+	u32 page_id;
 };
 
 /* Metadata page */
 struct md_page {
 	struct rb_node node;
-	unsigned int id; /* Number of this page starting from hdr */
+	u32 id; /* Number of this page starting from hdr */
 #define MD_DIRTY	(1U << 1) /* Page contains changes and wants writeback */
 #define MD_WRITEBACK	(1U << 2) /* Writeback was submitted */
 	unsigned int status;
@@ -137,7 +137,7 @@ struct ploop {
 	struct rb_root bat_entries;
 	struct ploop_delta *deltas;
 	u8 nr_deltas;
-	unsigned int nr_bat_entries;
+	u32 nr_bat_entries;
 	unsigned int cluster_log; /* In sectors */
 
 	u8 m_Sig[16]; /* Signature */
@@ -149,7 +149,7 @@ struct ploop {
 	 * are also included, and their bits must be zeroed.
 	 */
 	void *holes_bitmap; /* Clearing a bit occurs from kwork only */
-	unsigned int hb_nr; /* holes_bitmap size in bits */
+	u32 hb_nr; /* holes_bitmap size in bits */
 	rwlock_t bat_rwlock;
 
 	struct list_head wb_batch_list;
@@ -244,7 +244,7 @@ struct pio {
 	ploop_endio_t endio_cb;
 	void *endio_cb_data;
 
-	unsigned int clu;
+	u32 clu;
 	u8 level;
 
 	bool is_data_alloc:1;
@@ -273,7 +273,7 @@ struct pio {
 struct ploop_cow {
 	struct ploop *ploop;
 	struct pio *aux_pio;
-	unsigned int dst_clu;
+	u32 dst_clu;
 
 	struct pio *cow_pio;
 };
@@ -293,8 +293,7 @@ static inline bool ploop_is_ro(struct ploop *ploop)
 	return (dm_table_get_mode(ploop->ti->table) & FMODE_WRITE) == 0;
 }
 
-static inline void remap_to_cluster(struct ploop *ploop, struct pio *pio,
-				    unsigned int clu)
+static inline void remap_to_cluster(struct ploop *ploop, struct pio *pio, u32 clu)
 {
 	pio->bi_iter.bi_sector &= ((1 << ploop->cluster_log) - 1);
 	pio->bi_iter.bi_sector |= (clu << ploop->cluster_log);
@@ -344,7 +343,7 @@ static inline void ploop_hole_set_bit(unsigned long nr, struct ploop *ploop)
 		set_bit(nr, ploop->holes_bitmap);
 }
 
-static inline void ploop_hole_clear_bit(unsigned int nr, struct ploop *ploop)
+static inline void ploop_hole_clear_bit(u32 nr, struct ploop *ploop)
 {
 	if (!WARN_ON_ONCE(nr >= ploop->hb_nr))
 		clear_bit(nr, ploop->holes_bitmap);
@@ -357,7 +356,7 @@ static inline unsigned int nr_pages_in_cluster(struct ploop *ploop)
 
 /* Get number of clusters, occupied by hdr and BAT */
 static inline unsigned int ploop_nr_bat_clusters(struct ploop *ploop,
-						 unsigned int nr_bat_entries)
+						 u32 nr_bat_entries)
 {
 	unsigned long size, bat_clusters;
 
@@ -367,40 +366,37 @@ static inline unsigned int ploop_nr_bat_clusters(struct ploop *ploop,
 	return bat_clusters;
 }
 
-static inline unsigned int bat_clu_to_page_nr(unsigned int clu)
+static inline u32 bat_clu_to_page_nr(u32 clu)
 {
-	unsigned int byte;
+	u64 byte;
 
 	byte = (clu + PLOOP_MAP_OFFSET) * sizeof(map_index_t);
 	return byte >> PAGE_SHIFT;
 }
 
-static inline unsigned int bat_clu_idx_in_page(unsigned int clu)
+static inline u32 bat_clu_idx_in_page(u32 clu)
 {
 	return (clu + PLOOP_MAP_OFFSET) % (PAGE_SIZE / sizeof(map_index_t));
 }
 
-static inline unsigned int page_clu_idx_to_bat_clu(unsigned int page_id,
-						   unsigned int cluster_rel)
+static inline u32 page_clu_idx_to_bat_clu(u32 page_id, u32 cluster_rel)
 {
 	unsigned int off;
-	off = page_id * PAGE_SIZE / sizeof(map_index_t) - PLOOP_MAP_OFFSET;
+	off = (u64)page_id * PAGE_SIZE / sizeof(map_index_t) - PLOOP_MAP_OFFSET;
 	return off + cluster_rel;
 }
 
-extern struct md_page * md_page_find(struct ploop *ploop, unsigned int id);
+extern struct md_page * md_page_find(struct ploop *ploop, u32 id);
 
 /*
  * This should be called in very rare cases. Avoid this function
  * in cycles by clu, use ploop_for_each_md_page()-based
  * iterations instead.
  */
-static inline unsigned int ploop_bat_entries(struct ploop *ploop,
-					     unsigned int clu,
-					     u8 *bat_level,
-					     struct md_page **md_ret)
+static inline u32 ploop_bat_entries(struct ploop *ploop, u32 clu,
+			  u8 *bat_level, struct md_page **md_ret)
 {
-	unsigned int *bat_entries, dst_clu, id;
+	u32 *bat_entries, dst_clu, id;
 	struct md_page *md;
 
 	id = bat_clu_to_page_nr(clu);
@@ -421,10 +417,9 @@ static inline unsigned int ploop_bat_entries(struct ploop *ploop,
 	return dst_clu;
 }
 
-static inline bool cluster_is_in_top_delta(struct ploop *ploop,
-					   unsigned int clu)
+static inline bool cluster_is_in_top_delta(struct ploop *ploop, u32 clu)
 {
-	unsigned int dst_clu;
+	u32 dst_clu;
 	u8 level;
 
 	if (WARN_ON(clu >= ploop->nr_bat_entries))
@@ -437,9 +432,9 @@ static inline bool cluster_is_in_top_delta(struct ploop *ploop,
 }
 
 static inline bool md_page_cluster_is_in_top_delta(struct ploop *ploop,
-			      struct md_page *md, unsigned int clu)
+					   struct md_page *md, u32 clu)
 {
-	unsigned int count, *bat_entries;
+	u32 count, *bat_entries;
 	bool ret = true;
 
 	count = PAGE_SIZE / sizeof(map_index_t);
@@ -457,10 +452,10 @@ static inline bool md_page_cluster_is_in_top_delta(struct ploop *ploop,
 	return ret;
 }
 
-static inline void init_bat_entries_iter(struct ploop *ploop, unsigned int page_id,
-					 unsigned int *start, unsigned int *end)
+static inline void init_bat_entries_iter(struct ploop *ploop, u32 page_id,
+					 u32 *start, u32 *end)
 {
-	unsigned int last_page = bat_clu_to_page_nr(ploop->nr_bat_entries - 1);
+	u32 last_page = bat_clu_to_page_nr(ploop->nr_bat_entries - 1);
 	unsigned int count = PAGE_SIZE / sizeof(map_index_t);
 
 	*start = 0;
@@ -483,8 +478,8 @@ static inline void track_pio(struct ploop *ploop, struct pio *pio)
 
 extern struct pio *find_pio(struct hlist_head head[], u32 clu);
 
-extern int prealloc_md_pages(struct rb_root *root, unsigned int nr_bat_entries,
-			     unsigned int new_nr_bat_entries);
+extern int prealloc_md_pages(struct rb_root *root, u32 nr_bat_entries,
+			     u32 new_nr_bat_entries);
 
 static inline struct pio *bio_to_endio_hook(struct bio *bio)
 {
@@ -521,8 +516,8 @@ static inline bool fake_merge_pio(struct pio *pio)
 extern void md_page_insert(struct ploop *ploop, struct md_page *md);
 extern void ploop_free_md_page(struct md_page *md);
 extern void free_md_pages_tree(struct rb_root *root);
-extern bool try_update_bat_entry(struct ploop *ploop, unsigned int clu,
-				 u8 level, unsigned int dst_clu);
+extern bool try_update_bat_entry(struct ploop *ploop, u32 clu,
+				 u8 level, u32 dst_clu);
 extern int convert_bat_entries(u32 *bat_entries, u32 count);
 
 extern int ploop_add_delta(struct ploop *ploop, u32 level, struct file *file, bool is_raw);
@@ -539,8 +534,7 @@ extern int ploop_rw_page_sync(unsigned rw, struct file *file,
 			      u64 index, struct page *page);
 extern void map_and_submit_rw(struct ploop *ploop, u32 dst_clu, struct pio *pio, u8 level);
 
-extern int ploop_prepare_reloc_index_wb(struct ploop *, struct md_page **,
-					unsigned int, unsigned int *);
+extern int ploop_prepare_reloc_index_wb(struct ploop *, struct md_page **, u32, u32 *);
 extern void ploop_break_bat_update(struct ploop *ploop, struct md_page *);
 extern void ploop_index_wb_submit(struct ploop *, struct ploop_index_wb *);
 extern int ploop_message(struct dm_target *ti, unsigned int argc, char **argv,
@@ -548,7 +542,7 @@ extern int ploop_message(struct dm_target *ti, unsigned int argc, char **argv,
 
 extern struct pio * alloc_pio_with_pages(struct ploop *ploop);
 extern void free_pio_with_pages(struct ploop *ploop, struct pio *pio);
-extern void pio_prepare_offsets(struct ploop *, struct pio *, unsigned int);
+extern void pio_prepare_offsets(struct ploop *, struct pio *, u32);
 
 extern int ploop_setup_metadata(struct ploop *ploop, struct page *page);
 extern int ploop_read_delta_metadata(struct ploop *ploop, struct file *file,




More information about the Devel mailing list