Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 498e5f24 authored by Theodore Ts'o's avatar Theodore Ts'o
Browse files

ext4: Change unsigned long to unsigned int



Convert the unsigned longs that are most responsible for bloating the
stack usage on 64-bit systems.

Nearly all places in the ext3/4 code which uses "unsigned long" is
probably a bug, since on 32-bit systems a ulong a 32-bits, which means
we are wasting stack space on 64-bit systems.

Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
parent a9df9a49
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -205,8 +205,8 @@ struct ext4_group_desc * ext4_get_group_desc(struct super_block *sb,
					     ext4_group_t block_group,
					     struct buffer_head **bh)
{
	unsigned long group_desc;
	unsigned long offset;
	unsigned int group_desc;
	unsigned int offset;
	struct ext4_group_desc *desc;
	struct ext4_sb_info *sbi = EXT4_SB(sb);

@@ -225,7 +225,7 @@ struct ext4_group_desc * ext4_get_group_desc(struct super_block *sb,
	if (!sbi->s_group_desc[group_desc]) {
		ext4_error(sb, "ext4_get_group_desc",
			   "Group descriptor not loaded - "
			   "block_group = %u, group_desc = %lu, desc = %lu",
			   "block_group = %u, group_desc = %u, desc = %u",
			   block_group, group_desc, offset);
		return NULL;
	}
@@ -372,8 +372,8 @@ void ext4_free_blocks_sb(handle_t *handle, struct super_block *sb,
	struct buffer_head *gd_bh;
	ext4_group_t block_group;
	ext4_grpblk_t bit;
	unsigned long i;
	unsigned long overflow;
	unsigned int i;
	unsigned int overflow;
	struct ext4_group_desc *desc;
	struct ext4_super_block *es;
	struct ext4_sb_info *sbi;
@@ -720,7 +720,7 @@ ext4_fsblk_t ext4_count_free_blocks(struct super_block *sb)
#ifdef EXT4FS_DEBUG
	struct ext4_super_block *es;
	ext4_fsblk_t bitmap_count;
	unsigned long x;
	unsigned int x;
	struct buffer_head *bitmap_bh = NULL;

	es = EXT4_SB(sb)->s_es;
@@ -740,7 +740,7 @@ ext4_fsblk_t ext4_count_free_blocks(struct super_block *sb)
			continue;

		x = ext4_count_free(bitmap_bh, sb->s_blocksize);
		printk(KERN_DEBUG "group %lu: stored = %d, counted = %lu\n",
		printk(KERN_DEBUG "group %lu: stored = %d, counted = %u\n",
			i, le16_to_cpu(gdp->bg_free_blocks_count), x);
		bitmap_count += x;
	}
+2 −3
Original line number Diff line number Diff line
@@ -15,10 +15,9 @@

static const int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0};

unsigned long ext4_count_free(struct buffer_head *map, unsigned int numchars)
unsigned int ext4_count_free(struct buffer_head *map, unsigned int numchars)
{
	unsigned int i;
	unsigned long sum = 0;
	unsigned int i, sum = 0;

	if (!map)
		return 0;
+4 −4
Original line number Diff line number Diff line
@@ -64,7 +64,7 @@ static unsigned char get_dtype(struct super_block *sb, int filetype)
int ext4_check_dir_entry(const char *function, struct inode *dir,
			 struct ext4_dir_entry_2 *de,
			 struct buffer_head *bh,
			 unsigned long offset)
			 unsigned int offset)
{
	const char *error_msg = NULL;
	const int rlen = ext4_rec_len_from_disk(de->rec_len);
@@ -84,9 +84,9 @@ int ext4_check_dir_entry(const char *function, struct inode *dir,
	if (error_msg != NULL)
		ext4_error(dir->i_sb, function,
			"bad entry in directory #%lu: %s - "
			"offset=%lu, inode=%lu, rec_len=%d, name_len=%d",
			"offset=%u, inode=%u, rec_len=%d, name_len=%d",
			dir->i_ino, error_msg, offset,
			(unsigned long) le32_to_cpu(de->inode),
			le32_to_cpu(de->inode),
			rlen, de->name_len);
	return error_msg == NULL ? 1 : 0;
}
@@ -95,7 +95,7 @@ static int ext4_readdir(struct file *filp,
			 void *dirent, filldir_t filldir)
{
	int error = 0;
	unsigned long offset;
	unsigned int offset;
	int i, stored;
	struct ext4_dir_entry_2 *de;
	struct super_block *sb;
+10 −12
Original line number Diff line number Diff line
@@ -94,9 +94,9 @@ struct ext4_allocation_request {
	/* phys. block for ^^^ */
	ext4_fsblk_t pright;
	/* how many blocks we want to allocate */
	unsigned long len;
	unsigned int len;
	/* flags. see above EXT4_MB_HINT_* */
	unsigned long flags;
	unsigned int flags;
};

/*
@@ -997,6 +997,9 @@ do { \
# define ATTRIB_NORET	__attribute__((noreturn))
# define NORET_AND	noreturn,

/* bitmap.c */
extern unsigned int ext4_count_free(struct buffer_head *, unsigned);

/* balloc.c */
extern unsigned int ext4_block_group(struct super_block *sb,
			ext4_fsblk_t blocknr);
@@ -1024,7 +1027,7 @@ extern int ext4_should_retry_alloc(struct super_block *sb, int *retries);
/* dir.c */
extern int ext4_check_dir_entry(const char *, struct inode *,
				struct ext4_dir_entry_2 *,
				struct buffer_head *, unsigned long);
				struct buffer_head *, unsigned int);
extern int ext4_htree_store_dirent(struct file *dir_file, __u32 hash,
				    __u32 minor_hash,
				    struct ext4_dir_entry_2 *dirent);
@@ -1044,7 +1047,6 @@ extern struct inode * ext4_orphan_get(struct super_block *, unsigned long);
extern unsigned long ext4_count_free_inodes(struct super_block *);
extern unsigned long ext4_count_dirs(struct super_block *);
extern void ext4_check_inodes_bitmap(struct super_block *);
extern unsigned long ext4_count_free(struct buffer_head *, unsigned);

/* mballoc.c */
extern long ext4_mb_stats;
@@ -1074,10 +1076,6 @@ struct buffer_head *ext4_bread(handle_t *, struct inode *,
						ext4_lblk_t, int, int *);
int ext4_get_block(struct inode *inode, sector_t iblock,
				struct buffer_head *bh_result, int create);
int ext4_get_blocks_handle(handle_t *handle, struct inode *inode,
				ext4_lblk_t iblock, unsigned long maxblocks,
				struct buffer_head *bh_result,
				int create, int extend_disksize);

extern struct inode *ext4_iget(struct super_block *, unsigned long);
extern int  ext4_write_inode(struct inode *, int);
@@ -1276,8 +1274,8 @@ extern int ext4_ext_writepage_trans_blocks(struct inode *, int);
extern int ext4_ext_index_trans_blocks(struct inode *inode, int nrblocks,
				       int chunk);
extern int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
			ext4_lblk_t iblock,
			unsigned long max_blocks, struct buffer_head *bh_result,
			       ext4_lblk_t iblock, unsigned int max_blocks,
			       struct buffer_head *bh_result,
			       int create, int extend_disksize);
extern void ext4_ext_truncate(struct inode *);
extern void ext4_ext_init(struct super_block *);
@@ -1285,7 +1283,7 @@ extern void ext4_ext_release(struct super_block *);
extern long ext4_fallocate(struct inode *inode, int mode, loff_t offset,
			  loff_t len);
extern int ext4_get_blocks_wrap(handle_t *handle, struct inode *inode,
			sector_t block, unsigned long max_blocks,
			sector_t block, unsigned int max_blocks,
			struct buffer_head *bh, int create,
			int extend_disksize, int flag);
#endif	/* __KERNEL__ */
+7 −6
Original line number Diff line number Diff line
@@ -100,9 +100,6 @@ struct ext4_inode_info {
	 */
	loff_t	i_disksize;

	/* on-disk additional length */
	__u16 i_extra_isize;

	/*
	 * i_data_sem is for serialising ext4_truncate() against
	 * ext4_getblock().  In the 2.4 ext2 design, great chunks of inode's
@@ -129,10 +126,14 @@ struct ext4_inode_info {
	spinlock_t i_prealloc_lock;

	/* allocation reservation info for delalloc */
	unsigned long i_reserved_data_blocks;
	unsigned long i_reserved_meta_blocks;
	unsigned long i_allocated_meta_blocks;
	unsigned int i_reserved_data_blocks;
	unsigned int i_reserved_meta_blocks;
	unsigned int i_allocated_meta_blocks;
	unsigned short i_delalloc_reserved_flag;

	/* on-disk additional length */
	__u16 i_extra_isize;

	spinlock_t i_block_reservation_lock;
};

Loading