Some updates from review comments from patch 1-4. --- fs/ext3/inode.c | 0 linux-2.6.17-rc4-ming/fs/ext3/resize.c | 2 linux-2.6.17-rc4-ming/fs/ext3/xattr.c | 2 --- linux-2.6.17-rc4-new-ming/fs/ext3/super.c | 2 linux-2.6.17-rc4-new-ming/fs/ext3/xattr.c | 2 linux-2.6.17-rc4-new-ming/include/linux/ext3_fs_i.h | 1 --- linux-2.6.16-ming/fs/ext3/balloc.c | 104 ++++++++++++++-------------- linux-2.6.16-ming/fs/ext3/ialloc.c | 7 + linux-2.6.16-ming/fs/ext3/resize.c | 21 +++-- linux-2.6.16-ming/fs/ext3/super.c | 2 linux-2.6.16-ming/fs/ext3/xattr.c | 2 linux-2.6.16-ming/include/linux/ext3_fs.h | 20 ++--- linux-2.6.16-ming/include/linux/ext3_fs_i.h | 1 7 files changed, 83 insertions(+), 74 deletions(-) diff -puN fs/ext3/balloc.c~ext3_blks_fixes_from_comments-1-4 fs/ext3/balloc.c --- linux-2.6.16/fs/ext3/balloc.c~ext3_blks_fixes_from_comments-1-4 2006-05-19 17:12:58.511677445 -0700 +++ linux-2.6.16-ming/fs/ext3/balloc.c 2006-05-19 17:12:58.538674301 -0700 @@ -163,7 +163,7 @@ restart: #endif static int -goal_in_my_reservation(struct ext3_reserve_window *rsv, ext3_grpblk_t goal, +goal_in_my_reservation(struct ext3_reserve_window *rsv, ext3_grpblk_t grp_goal, unsigned int group, struct super_block * sb) { ext3_fsblk_t group_first_block, group_last_block; @@ -175,8 +175,8 @@ goal_in_my_reservation(struct ext3_reser if ((rsv->_rsv_start > group_last_block) || (rsv->_rsv_end < group_first_block)) return 0; - if ((goal >= 0) && ((goal + group_first_block < rsv->_rsv_start) - || (goal + group_first_block > rsv->_rsv_end))) + if ((grp_goal >= 0) && ((grp_goal + group_first_block < rsv->_rsv_start) + || (grp_goal + group_first_block > rsv->_rsv_end))) return 0; return 1; } @@ -311,14 +311,14 @@ void ext3_discard_reservation(struct ino /* Free given blocks, update quota and i_blocks field */ void ext3_free_blocks_sb(handle_t *handle, struct super_block *sb, ext3_fsblk_t block, unsigned long count, - ext3_fsblk_t *pdquot_freed_blocks) + unsigned long *pdquot_freed_blocks) { struct buffer_head *bitmap_bh = NULL; struct buffer_head *gd_bh; unsigned long block_group; ext3_grpblk_t bit; unsigned long i; - ext3_fsblk_t overflow; + unsigned long overflow; struct ext3_group_desc * desc; struct ext3_super_block * es; struct ext3_sb_info *sbi; @@ -333,7 +333,7 @@ void ext3_free_blocks_sb(handle_t *handl block + count > le32_to_cpu(es->s_blocks_count)) { ext3_error (sb, "ext3_free_blocks", "Freeing blocks not in datazone - " - "block = %lu, count = %lu", block, count); + "block = "E3FSBLK", count = %lu", block, count); goto error_return; } @@ -369,7 +369,7 @@ do_more: sbi->s_itb_per_group)) ext3_error (sb, "ext3_free_blocks", "Freeing blocks in system zones - " - "Block = %lu, count = %lu", + "Block = "E3FSBLK", count = %lu", block, count); /* @@ -453,7 +453,8 @@ do_more: bit + i, bitmap_bh->b_data)) { jbd_unlock_bh_state(bitmap_bh); ext3_error(sb, __FUNCTION__, - "bit already cleared for block %lu", block + i); + "bit already cleared for block "E3FSBLK, + block + i); jbd_lock_bh_state(bitmap_bh); BUFFER_TRACE(bitmap_bh, "bit already cleared"); } else { @@ -496,7 +497,7 @@ void ext3_free_blocks(handle_t *handle, ext3_fsblk_t block, unsigned long count) { struct super_block * sb; - ext3_fsblk_t dquot_freed_blocks; + unsigned long dquot_freed_blocks; sb = inode->i_sb; if (!sb) { @@ -592,7 +593,7 @@ find_next_usable_block(ext3_grpblk_t sta * less than EXT3_BLOCKS_PER_GROUP. Aligning up to the * next 64-bit boundary is simple.. */ - int end_goal = (start + 63) & ~63; + ext3_grpblk_t end_goal = (start + 63) & ~63; if (end_goal > maxblocks) end_goal = maxblocks; here = ext3_find_next_zero_bit(bh->b_data, end_goal, start); @@ -654,7 +655,7 @@ claim_block(spinlock_t *lock, ext3_grpbl */ static ext3_grpblk_t ext3_try_to_allocate(struct super_block *sb, handle_t *handle, int group, - struct buffer_head *bitmap_bh, ext3_grpblk_t goal, + struct buffer_head *bitmap_bh, ext3_grpblk_t grp_goal, unsigned long *count, struct ext3_reserve_window *my_rsv) { ext3_fsblk_t group_first_block; @@ -675,13 +676,13 @@ ext3_try_to_allocate(struct super_block if (end > EXT3_BLOCKS_PER_GROUP(sb)) /* reservation window crosses group boundary */ end = EXT3_BLOCKS_PER_GROUP(sb); - if ((start <= goal) && (goal < end)) - start = goal; + if ((start <= grp_goal) && (grp_goal < end)) + start = grp_goal; else - goal = -1; + grp_goal = -1; } else { - if (goal > 0) - start = goal; + if (grp_goal > 0) + start = grp_goal; else start = 0; end = EXT3_BLOCKS_PER_GROUP(sb); @@ -690,43 +691,43 @@ ext3_try_to_allocate(struct super_block BUG_ON(start > EXT3_BLOCKS_PER_GROUP(sb)); repeat: - if (goal < 0 || !ext3_test_allocatable(goal, bitmap_bh)) { - goal = find_next_usable_block(start, bitmap_bh, end); - if (goal < 0) + if (grp_goal < 0 || !ext3_test_allocatable(grp_goal, bitmap_bh)) { + grp_goal = find_next_usable_block(start, bitmap_bh, end); + if (grp_goal < 0) goto fail_access; if (!my_rsv) { int i; - for (i = 0; i < 7 && goal > start && - ext3_test_allocatable(goal - 1, + for (i = 0; i < 7 && grp_goal > start && + ext3_test_allocatable(grp_goal - 1, bitmap_bh); - i++, goal--) + i++, grp_goal--) ; } } - start = goal; + start = grp_goal; - if (!claim_block(sb_bgl_lock(EXT3_SB(sb), group), goal, bitmap_bh)) { + if (!claim_block(sb_bgl_lock(EXT3_SB(sb), group), grp_goal, bitmap_bh)) { /* * The block was allocated by another thread, or it was * allocated and then freed by another thread */ start++; - goal++; + grp_goal++; if (start >= end) goto fail_access; goto repeat; } num++; - goal++; - while (num < *count && goal < end - && ext3_test_allocatable(goal, bitmap_bh) - && claim_block(sb_bgl_lock(EXT3_SB(sb), group), goal, bitmap_bh)) { + grp_goal++; + while (num < *count && grp_goal < end + && ext3_test_allocatable(grp_goal, bitmap_bh) + && claim_block(sb_bgl_lock(EXT3_SB(sb), group), grp_goal, bitmap_bh)) { num++; - goal++; + grp_goal++; } *count = num; - return goal - num; + return grp_goal - num; fail_access: *count = num; return -1; @@ -876,10 +877,10 @@ static int find_next_reservable_window( * * @rsv: the reservation * - * @goal: The goal (group-relative). It is where the search for a + * @grp_goal: The goal (group-relative). It is where the search for a * free reservable space should start from. - * if we have a goal(goal >0 ), then start from there, - * no goal(goal = -1), we start from the first block + * if we have a grp_goal(grp_goal >0 ), then start from there, + * no grp_goal(grp_goal = -1), we start from the first block * of the group. * * @sb: the super block @@ -888,7 +889,7 @@ static int find_next_reservable_window( * */ static int alloc_new_reservation(struct ext3_reserve_window_node *my_rsv, - ext3_grpblk_t goal, struct super_block *sb, + ext3_grpblk_t grp_goal, struct super_block *sb, unsigned int group, struct buffer_head *bitmap_bh) { struct ext3_reserve_window_node *search_head; @@ -903,10 +904,10 @@ static int alloc_new_reservation(struct group * EXT3_BLOCKS_PER_GROUP(sb); group_end_block = group_first_block + EXT3_BLOCKS_PER_GROUP(sb) - 1; - if (goal < 0) + if (grp_goal < 0) start_block = group_first_block; else - start_block = goal + group_first_block; + start_block = grp_goal + group_first_block; size = my_rsv->rsv_goal_size; @@ -1063,7 +1064,7 @@ static void try_to_extend_reservation(st static ext3_grpblk_t ext3_try_to_allocate_with_rsv(struct super_block *sb, handle_t *handle, unsigned int group, struct buffer_head *bitmap_bh, - ext3_grpblk_t goal, + ext3_grpblk_t grp_goal, struct ext3_reserve_window_node * my_rsv, unsigned long *count, int *errp) { @@ -1094,12 +1095,12 @@ ext3_try_to_allocate_with_rsv(struct sup */ if (my_rsv == NULL ) { ret = ext3_try_to_allocate(sb, handle, group, bitmap_bh, - goal, count, NULL); + grp_goal, count, NULL); goto out; } /* - * goal is a group relative block number (if there is a goal) - * 0 < goal < EXT3_BLOCKS_PER_GROUP(sb) + * grp_goal is a group relative block number (if there is a goal) + * 0 < grp_goal < EXT3_BLOCKS_PER_GROUP(sb) * first block is a filesystem wide block number * first block is the block number of the first block in this group */ @@ -1123,24 +1124,24 @@ ext3_try_to_allocate_with_rsv(struct sup */ while (1) { if (rsv_is_empty(&my_rsv->rsv_window) || (ret < 0) || - !goal_in_my_reservation(&my_rsv->rsv_window, goal, group, sb)) { + !goal_in_my_reservation(&my_rsv->rsv_window, grp_goal, group, sb)) { if (my_rsv->rsv_goal_size < *count) my_rsv->rsv_goal_size = *count; - ret = alloc_new_reservation(my_rsv, goal, sb, + ret = alloc_new_reservation(my_rsv, grp_goal, sb, group, bitmap_bh); if (ret < 0) break; /* failed */ - if (!goal_in_my_reservation(&my_rsv->rsv_window, goal, group, sb)) - goal = -1; - } else if (goal > 0 && (my_rsv->rsv_end-goal+1) < *count) + if (!goal_in_my_reservation(&my_rsv->rsv_window, grp_goal, group, sb)) + grp_goal = -1; + } else if (grp_goal > 0 && (my_rsv->rsv_end-grp_goal+1) < *count) try_to_extend_reservation(my_rsv, sb, - *count-my_rsv->rsv_end + goal - 1); + *count-my_rsv->rsv_end + grp_goal - 1); if ((my_rsv->rsv_start >= group_first_block + EXT3_BLOCKS_PER_GROUP(sb)) || (my_rsv->rsv_end < group_first_block)) BUG(); - ret = ext3_try_to_allocate(sb, handle, group, bitmap_bh, goal, + ret = ext3_try_to_allocate(sb, handle, group, bitmap_bh, grp_goal, &num, &my_rsv->rsv_window); if (ret >= 0) { my_rsv->rsv_alloc_hit += num; @@ -1381,7 +1382,8 @@ allocated: EXT3_SB(sb)->s_itb_per_group)) ext3_error(sb, "ext3_new_block", "Allocating block in system zone - " - "blocks from %lu, length %lu", ret_block, num); + "blocks from "E3FSBLK", length %lu", + ret_block, num); performed_allocation = 1; @@ -1410,14 +1412,14 @@ allocated: } } } - ext3_debug("found bit %d\n", grp_alloc_blk+i); + ext3_debug("found bit %d\n", grp_alloc_blk); spin_unlock(sb_bgl_lock(sbi, group_no)); jbd_unlock_bh_state(bitmap_bh); #endif if (ret_block + num - 1 >= le32_to_cpu(es->s_blocks_count)) { ext3_error(sb, "ext3_new_block", - "block(%lu) >= blocks count(%d) - " + "block("E3FSBLK") >= blocks count(%d) - " "block_group = %d, es == %p ", ret_block, le32_to_cpu(es->s_blocks_count), group_no, es); goto out; diff -puN fs/ext3/ialloc.c~ext3_blks_fixes_from_comments-1-4 fs/ext3/ialloc.c --- linux-2.6.16/fs/ext3/ialloc.c~ext3_blks_fixes_from_comments-1-4 2006-05-19 17:12:58.515676979 -0700 +++ linux-2.6.16-ming/fs/ext3/ialloc.c 2006-05-19 17:12:58.547673253 -0700 @@ -263,9 +263,10 @@ static int find_group_orlov(struct super int inodes_per_group = EXT3_INODES_PER_GROUP(sb); int freei, avefreei; ext3_fsblk_t freeb, avefreeb; - int blocks_per_dir, ndirs; + ext3_fsblk_t blocks_per_dir; + int ndirs; int max_debt, max_dirs, min_inodes; - ext3_fsblk_t min_blocks; + ext3_grpblk_t min_blocks; int group = -1, i; struct ext3_group_desc *desc; struct buffer_head *bh; @@ -308,7 +309,7 @@ static int find_group_orlov(struct super min_inodes = avefreei - inodes_per_group / 4; min_blocks = avefreeb - EXT3_BLOCKS_PER_GROUP(sb) / 4; - max_debt = EXT3_BLOCKS_PER_GROUP(sb) / max(blocks_per_dir, BLOCK_COST); + max_debt = EXT3_BLOCKS_PER_GROUP(sb) / max(blocks_per_dir, (ext3_fsblk_t)BLOCK_COST); if (max_debt * INODE_COST > inodes_per_group) max_debt = inodes_per_group / INODE_COST; if (max_debt > 255) diff -puN fs/ext3/resize.c~ext3_blks_fixes_from_comments-1-4 fs/ext3/resize.c --- linux-2.6.16/fs/ext3/resize.c~ext3_blks_fixes_from_comments-1-4 2006-05-19 17:12:58.518676630 -0700 +++ linux-2.6.16-ming/fs/ext3/resize.c 2006-05-19 17:12:58.541673951 -0700 @@ -64,7 +64,8 @@ static int verify_group_input(struct sup ext3_warning(sb, __FUNCTION__, "Bad blocks count %u", input->blocks_count); else if (!(bh = sb_bread(sb, end - 1))) - ext3_warning(sb, __FUNCTION__, "Cannot read last block (%lu)", + ext3_warning(sb, __FUNCTION__, + "Cannot read last block ("E3FSBLK")", end - 1); else if (outside(input->block_bitmap, start, end)) ext3_warning(sb, __FUNCTION__, @@ -77,7 +78,7 @@ static int verify_group_input(struct sup else if (outside(input->inode_table, start, end) || outside(itend - 1, start, end)) ext3_warning(sb, __FUNCTION__, - "Inode table not in group (blocks %u-%lu)", + "Inode table not in group (blocks %u-"E3FSBLK")", input->inode_table, itend - 1); else if (input->inode_bitmap == input->block_bitmap) ext3_warning(sb, __FUNCTION__, @@ -85,25 +86,27 @@ static int verify_group_input(struct sup input->block_bitmap); else if (inside(input->block_bitmap, input->inode_table, itend)) ext3_warning(sb, __FUNCTION__, - "Block bitmap (%u) in inode table (%u-%lu)", + "Block bitmap (%u) in inode table (%u-"E3FSBLK")", input->block_bitmap, input->inode_table, itend-1); else if (inside(input->inode_bitmap, input->inode_table, itend)) ext3_warning(sb, __FUNCTION__, - "Inode bitmap (%u) in inode table (%u-%lu)", + "Inode bitmap (%u) in inode table (%u-"E3FSBLK")", input->inode_bitmap, input->inode_table, itend-1); else if (inside(input->block_bitmap, start, metaend)) ext3_warning(sb, __FUNCTION__, - "Block bitmap (%u) in GDT table (%lu-%lu)", + "Block bitmap (%u) in GDT table" + " ("E3FSBLK"-"E3FSBLK")", input->block_bitmap, start, metaend - 1); else if (inside(input->inode_bitmap, start, metaend)) ext3_warning(sb, __FUNCTION__, - "Inode bitmap (%u) in GDT table (%lu-%lu)", + "Inode bitmap (%u) in GDT table" + " ("E3FSBLK"-"E3FSBLK")", input->inode_bitmap, start, metaend - 1); else if (inside(input->inode_table, start, metaend) || inside(itend - 1, start, metaend)) ext3_warning(sb, __FUNCTION__, - "Inode table (%u-%lu) overlaps" - "GDT table (%lu-%lu)", + "Inode table (%u-"E3FSBLK") overlaps" + "GDT table ("E3FSBLK"-"E3FSBLK")", input->inode_table, itend - 1, start, metaend - 1); else err = 0; @@ -913,7 +916,7 @@ int ext3_group_extend(struct super_block struct buffer_head * bh; handle_t *handle; int err; - ext3_fsblk_t freed_blocks; + unsigned long freed_blocks; /* We don't need to worry about locking wrt other resizers just * yet: we're going to revalidate es->s_blocks_count after diff -puN fs/ext3/super.c~ext3_blks_fixes_from_comments-1-4 fs/ext3/super.c --- linux-2.6.16/fs/ext3/super.c~ext3_blks_fixes_from_comments-1-4 2006-05-19 17:12:58.522676164 -0700 +++ linux-2.6.16-ming/fs/ext3/super.c 2006-05-19 17:12:58.545673485 -0700 @@ -1838,7 +1838,7 @@ static journal_t *ext3_get_dev_journal(s struct buffer_head * bh; journal_t *journal; int start; - int len; + ext3_fsblk_t len; int hblock, blocksize; unsigned long sb_block; unsigned long offset; diff -puN fs/ext3/xattr.c~ext3_blks_fixes_from_comments-1-4 fs/ext3/xattr.c --- linux-2.6.16/fs/ext3/xattr.c~ext3_blks_fixes_from_comments-1-4 2006-05-19 17:12:58.525675815 -0700 +++ linux-2.6.16-ming/fs/ext3/xattr.c 2006-05-19 17:12:58.549673020 -0700 @@ -794,7 +794,7 @@ inserted: /* We need to allocate a new block */ ext3_fsblk_t goal = le32_to_cpu( EXT3_SB(sb)->s_es->s_first_data_block) + - EXT3_I(inode)->i_block_group * + (ext3_fsblk_t)EXT3_I(inode)->i_block_group * EXT3_BLOCKS_PER_GROUP(sb); ext3_fsblk_t block = ext3_new_block(handle, inode, goal, &error); diff -puN include/linux/ext3_fs.h~ext3_blks_fixes_from_comments-1-4 include/linux/ext3_fs.h --- linux-2.6.16/include/linux/ext3_fs.h~ext3_blks_fixes_from_comments-1-4 2006-05-19 17:12:58.529675349 -0700 +++ linux-2.6.16-ming/include/linux/ext3_fs.h 2006-05-19 17:12:58.551672787 -0700 @@ -732,14 +732,15 @@ struct dir_private_info { /* balloc.c */ extern int ext3_bg_has_super(struct super_block *sb, int group); extern unsigned long ext3_bg_num_gdb(struct super_block *sb, int group); -extern ext3_fsblk_t ext3_new_block (handle_t *, struct inode *, ext3_fsblk_t, - int *); -extern ext3_fsblk_t ext3_new_blocks (handle_t *, struct inode *, ext3_fsblk_t, - unsigned long *, int *); -extern void ext3_free_blocks (handle_t *, struct inode *, ext3_fsblk_t, - unsigned long); -extern void ext3_free_blocks_sb (handle_t *, struct super_block *, - ext3_fsblk_t, unsigned long, ext3_fsblk_t *); +extern ext3_fsblk_t ext3_new_block (handle_t *handle, struct inode *inode, + ext3_fsblk_t goal, int *errp); +extern ext3_fsblk_t ext3_new_blocks (handle_t *handle, struct inode *inode, + ext3_fsblk_t goal, unsigned long *count, int *errp); +extern void ext3_free_blocks (handle_t *handle, struct inode *inode, + ext3_fsblk_t block, unsigned long count); +extern void ext3_free_blocks_sb (handle_t *handle, struct super_block *sb, + ext3_fsblk_t block, unsigned long count, + unsigned long *pdquot_freed_blocks); extern unsigned long ext3_count_free_blocks (struct super_block *); extern void ext3_check_blocks_bitmap (struct super_block *); extern struct ext3_group_desc * ext3_get_group_desc(struct super_block * sb, @@ -776,7 +777,8 @@ extern unsigned long ext3_count_free (st /* inode.c */ -int ext3_forget(handle_t *, int, struct inode *, struct buffer_head *, ext3_fsblk_t); +int ext3_forget(handle_t *handle, int is_metadata, struct inode *inode, + struct buffer_head *bh, ext3_fsblk_t blocknr); struct buffer_head * ext3_getblk (handle_t *, struct inode *, long, int, int *); struct buffer_head * ext3_bread (handle_t *, struct inode *, int, int, int *); int ext3_get_blocks_handle(handle_t *handle, struct inode *inode, diff -puN include/linux/ext3_fs_i.h~ext3_blks_fixes_from_comments-1-4 include/linux/ext3_fs_i.h --- linux-2.6.16/include/linux/ext3_fs_i.h~ext3_blks_fixes_from_comments-1-4 2006-05-19 17:12:58.532675000 -0700 +++ linux-2.6.16-ming/include/linux/ext3_fs_i.h 2006-05-19 17:12:58.546673369 -0700 @@ -27,6 +27,7 @@ typedef int ext3_grpblk_t; /* data type for filesystem-wide blocks number */ typedef unsigned long ext3_fsblk_t; +#define E3FSBLK "%lu" struct ext3_reserve_window { __u32 _rsv_start; /* First byte reserved */ _