--- linux-2.6.16-ming/fs/ext3/balloc.c | 17 +++++------------ linux-2.6.16-ming/fs/ext3/inode.c | 4 +--- linux-2.6.16-ming/fs/ext3/resize.c | 4 +--- linux-2.6.16-ming/fs/ext3/super.c | 4 +--- linux-2.6.16-ming/include/linux/ext3_fs.h | 8 ++++++++ 5 files changed, 16 insertions(+), 21 deletions(-) diff -puN include/linux/ext3_fs.h~ext3_group_first_block_no include/linux/ext3_fs.h --- linux-2.6.16/include/linux/ext3_fs.h~ext3_group_first_block_no 2006-05-22 14:39:34.000000000 -0700 +++ linux-2.6.16-ming/include/linux/ext3_fs.h 2006-05-22 14:57:12.000000000 -0700 @@ -712,6 +712,14 @@ struct dir_private_info { __u32 next_hash; }; +/* calculate the first block number of the group */ +static inline ext3_fsblk_t +ext3_group_first_block_no(struct super_block *sb, unsigned long group_no) +{ + return group_no * (ext3_fsblk_t)EXT3_BLOCKS_PER_GROUP(sb) + + le32_to_cpu(EXT3_SB(sb)->s_es->s_first_data_block); +} + /* * Special error return code only used by dx_probe() and its callers. */ diff -puN fs/ext3/balloc.c~ext3_group_first_block_no fs/ext3/balloc.c --- linux-2.6.16/fs/ext3/balloc.c~ext3_group_first_block_no 2006-05-22 14:57:27.000000000 -0700 +++ linux-2.6.16-ming/fs/ext3/balloc.c 2006-05-22 15:05:13.000000000 -0700 @@ -168,8 +168,7 @@ goal_in_my_reservation(struct ext3_reser { ext3_fsblk_t group_first_block, group_last_block; - group_first_block = le32_to_cpu(EXT3_SB(sb)->s_es->s_first_data_block) + - group * (ext3_fsblk_t)EXT3_BLOCKS_PER_GROUP(sb); + group_first_block = ext3_group_first_block_no(sb, group); group_last_block = group_first_block + EXT3_BLOCKS_PER_GROUP(sb) - 1; if ((rsv->_rsv_start > group_last_block) || @@ -664,9 +663,7 @@ ext3_try_to_allocate(struct super_block /* we do allocation within the reservation window if we have a window */ if (my_rsv) { - group_first_block = - le32_to_cpu(EXT3_SB(sb)->s_es->s_first_data_block) + - group * (ext3_fsblk_t)EXT3_BLOCKS_PER_GROUP(sb); + group_first_block = ext3_group_first_block_no(sb, group); if (my_rsv->_rsv_start >= group_first_block) start = my_rsv->_rsv_start - group_first_block; else @@ -900,8 +897,7 @@ static int alloc_new_reservation(struct int ret; spinlock_t *rsv_lock = &EXT3_SB(sb)->s_rsv_window_lock; - group_first_block = le32_to_cpu(EXT3_SB(sb)->s_es->s_first_data_block) + - group * (ext3_fsblk_t) EXT3_BLOCKS_PER_GROUP(sb); + group_first_block = ext3_group_first_block_no(sb, group); group_end_block = group_first_block + EXT3_BLOCKS_PER_GROUP(sb) - 1; if (grp_goal < 0) @@ -1104,8 +1100,7 @@ ext3_try_to_allocate_with_rsv(struct sup * first block is a filesystem wide block number * first block is the block number of the first block in this group */ - group_first_block = le32_to_cpu(EXT3_SB(sb)->s_es->s_first_data_block) + - group * (ext3_fsblk_t)EXT3_BLOCKS_PER_GROUP(sb); + group_first_block = ext3_group_first_block_no(sb, group); /* * Basically we will allocate a new block from inode's reservation @@ -1371,9 +1366,7 @@ allocated: if (fatal) goto out; - ret_block = grp_alloc_blk + - group_no * (ext3_fsblk_t)EXT3_BLOCKS_PER_GROUP(sb) + - le32_to_cpu(es->s_first_data_block); + ret_block = grp_alloc_blk + ext3_group_first_block_no(sb, group_no); if (in_range(le32_to_cpu(gdp->bg_block_bitmap), ret_block, num) || in_range(le32_to_cpu(gdp->bg_inode_bitmap), ret_block, num) || diff -puN fs/ext3/inode.c~ext3_group_first_block_no fs/ext3/inode.c --- linux-2.6.16/fs/ext3/inode.c~ext3_group_first_block_no 2006-05-22 15:05:28.000000000 -0700 +++ linux-2.6.16-ming/fs/ext3/inode.c 2006-05-22 15:11:49.000000000 -0700 @@ -429,9 +429,7 @@ static ext3_fsblk_t ext3_find_near(struc * It is going to be referred to from the inode itself? OK, just put it * into the same cylinder group then. */ - bg_start = ei->i_block_group * - (ext3_fsblk_t)EXT3_BLOCKS_PER_GROUP(inode->i_sb) + - le32_to_cpu(EXT3_SB(inode->i_sb)->s_es->s_first_data_block); + bg_start = ext3_group_first_block_no(inode->i_sb, ei->i_block_group); colour = (current->pid % 16) * (EXT3_BLOCKS_PER_GROUP(inode->i_sb) / 16); return bg_start + colour; diff -puN fs/ext3/resize.c~ext3_group_first_block_no fs/ext3/resize.c --- linux-2.6.16/fs/ext3/resize.c~ext3_group_first_block_no 2006-05-22 15:06:47.000000000 -0700 +++ linux-2.6.16-ming/fs/ext3/resize.c 2006-05-22 15:08:00.000000000 -0700 @@ -167,9 +167,7 @@ static int setup_new_group_blocks(struct struct ext3_new_group_data *input) { struct ext3_sb_info *sbi = EXT3_SB(sb); - ext3_fsblk_t start = input->group * - (ext3_fsblk_t) sbi->s_blocks_per_group + - le32_to_cpu(sbi->s_es->s_first_data_block); + ext3_fsblk_t start = ext3_group_first_block_no(sb, input->group); int reserved_gdb = ext3_bg_has_super(sb, input->group) ? le16_to_cpu(sbi->s_es->s_reserved_gdt_blocks) : 0; unsigned long gdblocks = ext3_bg_num_gdb(sb, input->group); diff -puN fs/ext3/super.c~ext3_group_first_block_no fs/ext3/super.c --- linux-2.6.16/fs/ext3/super.c~ext3_group_first_block_no 2006-05-22 15:08:12.000000000 -0700 +++ linux-2.6.16-ming/fs/ext3/super.c 2006-05-22 15:09:30.000000000 -0700 @@ -1321,10 +1321,8 @@ static ext3_fsblk_t descriptor_loc(struc { struct ext3_sb_info *sbi = EXT3_SB(sb); unsigned long bg, first_meta_bg; - ext3_fsblk_t first_data_block; int has_super = 0; - first_data_block = le32_to_cpu(sbi->s_es->s_first_data_block); first_meta_bg = le32_to_cpu(sbi->s_es->s_first_meta_bg); if (!EXT3_HAS_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_META_BG) || @@ -1333,7 +1331,7 @@ static ext3_fsblk_t descriptor_loc(struc bg = sbi->s_desc_per_block * nr; if (ext3_bg_has_super(sb, bg)) has_super = 1; - return (first_data_block + has_super + (bg * (ext3_fsblk_t)sbi->s_blocks_per_group)); + return (has_super + ext3_group_first_block_no(sb, bg)); } _