[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230817195925.10268-1-g.ottinger@gmx.at>
Date: Thu, 17 Aug 2023 21:59:25 +0200
From: Georg Ottinger <g.ottinger@....at>
To: jack@...e.com
Cc: linux-ext4@...r.kernel.org, linux-kernel@...r.kernel.org,
g.ottinger@....at
Subject: [PATCH v1] ext2: improve consistency of ext2_fsblk_t datatype usage
The ext2 block allocation/deallocation functions and their respective
calls use a mixture of unsigned long and ext2_fsblk_t datatypes to
index the desired ext2 block. This commit replaces occurrences of
unsigned long with ext2_fsblk_t, covering the functions
ext2_new_block(), ext2_new_blocks(), ext2_free_blocks(),
ext2_free_data() and ext2_free_branches(). This commit is rather
conservative, and only replaces unsigned long with ext2_fsblk_t if
the variable is used to index a specific ext2 block.
Signed-off-by: Georg Ottinger <g.ottinger@....at>
---
fs/ext2/balloc.c | 4 ++--
fs/ext2/ext2.h | 6 +++---
fs/ext2/inode.c | 6 +++---
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
index eca60b747..9db13852c 100644
--- a/fs/ext2/balloc.c
+++ b/fs/ext2/balloc.c
@@ -474,7 +474,7 @@ void ext2_discard_reservation(struct inode *inode)
* @block: start physical block to free
* @count: number of blocks to free
*/
-void ext2_free_blocks (struct inode * inode, unsigned long block,
+void ext2_free_blocks (struct inode * inode, ext2_fsblk_t block,
unsigned long count)
{
struct buffer_head *bitmap_bh = NULL;
@@ -1431,7 +1431,7 @@ ext2_fsblk_t ext2_new_blocks(struct inode *inode, ext2_fsblk_t goal,
return 0;
}
-ext2_fsblk_t ext2_new_block(struct inode *inode, unsigned long goal, int *errp)
+ext2_fsblk_t ext2_new_block(struct inode *inode, ext2_fsblk_t goal, int *errp)
{
unsigned long count = 1;
diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
index 35a041c47..83fd85bb1 100644
--- a/fs/ext2/ext2.h
+++ b/fs/ext2/ext2.h
@@ -695,12 +695,12 @@ static inline struct ext2_inode_info *EXT2_I(struct inode *inode)
/* balloc.c */
extern int ext2_bg_has_super(struct super_block *sb, int group);
extern unsigned long ext2_bg_num_gdb(struct super_block *sb, int group);
-extern ext2_fsblk_t ext2_new_block(struct inode *, unsigned long, int *);
-extern ext2_fsblk_t ext2_new_blocks(struct inode *, unsigned long,
+extern ext2_fsblk_t ext2_new_block(struct inode *, ext2_fsblk_t, int *);
+extern ext2_fsblk_t ext2_new_blocks(struct inode *, ext2_fsblk_t,
unsigned long *, int *);
extern int ext2_data_block_valid(struct ext2_sb_info *sbi, ext2_fsblk_t start_blk,
unsigned int count);
-extern void ext2_free_blocks (struct inode *, unsigned long,
+extern void ext2_free_blocks (struct inode *, ext2_fsblk_t,
unsigned long);
extern unsigned long ext2_count_free_blocks (struct super_block *);
extern unsigned long ext2_count_dirs (struct super_block *);
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index 75983215c..72916c929 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -1082,8 +1082,8 @@ static Indirect *ext2_find_shared(struct inode *inode,
*/
static inline void ext2_free_data(struct inode *inode, __le32 *p, __le32 *q)
{
- unsigned long block_to_free = 0, count = 0;
- unsigned long nr;
+ ext2_fsblk_t block_to_free = 0, count = 0;
+ ext2_fsblk_t nr;
for ( ; p < q ; p++) {
nr = le32_to_cpu(*p);
@@ -1123,7 +1123,7 @@ static inline void ext2_free_data(struct inode *inode, __le32 *p, __le32 *q)
static void ext2_free_branches(struct inode *inode, __le32 *p, __le32 *q, int depth)
{
struct buffer_head * bh;
- unsigned long nr;
+ ext2_fsblk_t nr;
if (depth--) {
int addr_per_block = EXT2_ADDR_PER_BLOCK(inode->i_sb);
--
2.17.1
Powered by blists - more mailing lists