In-kernel block varibles fixes to support >32 bit block block. Changes include: - convert some int type kernel block varibles to sector_t (bug fixes) - convert the rest of unsigned long type kernel block varibles to sector_t type. --- linux-2.6.16-ming/fs/ext3/balloc.c | 146 ++++++++++++++-------------- linux-2.6.16-ming/fs/ext3/bitmap.c | 4 linux-2.6.16-ming/fs/ext3/inode.c | 62 ++++++----- linux-2.6.16-ming/fs/ext3/namei.c | 18 +-- linux-2.6.16-ming/fs/ext3/resize.c | 44 ++++---- linux-2.6.16-ming/fs/ext3/super.c | 48 ++++----- linux-2.6.16-ming/fs/ext3/xattr.c | 10 - linux-2.6.16-ming/include/linux/ext3_fs.h | 29 +++-- linux-2.6.16-ming/include/linux/ext3_fs_i.h | 10 - 9 files changed, 195 insertions(+), 176 deletions(-) diff -puN fs/ext3/balloc.c~kernel_varibles_sector_t fs/ext3/balloc.c --- linux-2.6.16/fs/ext3/balloc.c~kernel_varibles_sector_t 2006-05-08 11:04:03.218190139 -0700 +++ linux-2.6.16-ming/fs/ext3/balloc.c 2006-05-08 11:22:35.368288412 -0700 @@ -20,11 +20,14 @@ #include #include #include +#include /* * balloc.c contains the blocks allocation and deallocation routines */ +#define EXT3_UNSPECIFIED_GOAL ((sector_t)-1) + /* * The free blocks are managed by bitmaps. A file system contains several * blocks groups. Each group contains 1 bitmap block for blocks, 1 bitmap @@ -163,10 +166,10 @@ restart: #endif static int -goal_in_my_reservation(struct ext3_reserve_window *rsv, int goal, +goal_in_my_reservation(struct ext3_reserve_window *rsv, sector_t goal, unsigned int group, struct super_block * sb) { - unsigned long group_first_block, group_last_block; + sector_t group_first_block, group_last_block; group_first_block = le32_to_cpu(EXT3_SB(sb)->s_es->s_first_data_block) + group * EXT3_BLOCKS_PER_GROUP(sb); @@ -175,7 +178,7 @@ 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) + if ((goal != EXT3_UNSPECIFIED_GOAL) && ((goal + group_first_block < rsv->_rsv_start) || (goal + group_first_block > rsv->_rsv_end))) return 0; return 1; @@ -187,7 +190,7 @@ goal_in_my_reservation(struct ext3_reser * Returns NULL if there are no windows or if all windows start after the goal. */ static struct ext3_reserve_window_node * -search_reserve_window(struct rb_root *root, unsigned long goal) +search_reserve_window(struct rb_root *root, sector_t goal) { struct rb_node *n = root->rb_node; struct ext3_reserve_window_node *rsv; @@ -223,7 +226,7 @@ void ext3_rsv_window_add(struct super_bl { struct rb_root *root = &EXT3_SB(sb)->s_rsv_window_root; struct rb_node *node = &rsv->rsv_node; - unsigned int start = rsv->rsv_start; + sector_t start = rsv->rsv_start; struct rb_node ** p = &root->rb_node; struct rb_node * parent = NULL; @@ -310,15 +313,15 @@ 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, - unsigned long block, unsigned long count, - int *pdquot_freed_blocks) + sector_t block, sector_t count, + sector_t *pdquot_freed_blocks) { struct buffer_head *bitmap_bh = NULL; struct buffer_head *gd_bh; - unsigned long block_group; - unsigned long bit; - unsigned long i; - unsigned long overflow; + sector_t block_group; + sector_t bit; + sector_t i; + sector_t overflow; struct ext3_group_desc * desc; struct ext3_super_block * es; struct ext3_sb_info *sbi; @@ -333,18 +336,17 @@ 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 = %llu, count = %llu", + (unsigned long long)block, (unsigned long long)count); goto error_return; } - ext3_debug ("freeing block(s) %lu-%lu\n", block, block + count - 1); + ext3_debug ("freeing block(s) %llu-%llu\n", (unsigned long long)block, + (unsigned long long)(block + count - 1)); do_more: overflow = 0; - block_group = (block - le32_to_cpu(es->s_first_data_block)) / - EXT3_BLOCKS_PER_GROUP(sb); - bit = (block - le32_to_cpu(es->s_first_data_block)) % - EXT3_BLOCKS_PER_GROUP(sb); + EXT3_BLOCK_GROUP(sb, block_group, bit, block - le32_to_cpu(es->s_first_data_block)); /* * Check to see if we are freeing blocks across a group * boundary. @@ -369,8 +371,9 @@ do_more: sbi->s_itb_per_group)) ext3_error (sb, "ext3_free_blocks", "Freeing blocks in system zones - " - "Block = %lu, count = %lu", - block, count); + "Block = %llu, count = %llu", + (unsigned long long)block, + (unsigned long long)count); /* * We are about to start releasing blocks in the bitmap, @@ -453,7 +456,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 %llu", + (unsigned long long)block + i); jbd_lock_bh_state(bitmap_bh); BUFFER_TRACE(bitmap_bh, "bit already cleared"); } else { @@ -493,10 +497,10 @@ error_return: /* Free given blocks, update quota and i_blocks field */ void ext3_free_blocks(handle_t *handle, struct inode *inode, - unsigned long block, unsigned long count) + sector_t block, sector_t count) { struct super_block * sb; - int dquot_freed_blocks; + sector_t dquot_freed_blocks; sb = inode->i_sb; if (!sb) { @@ -651,11 +655,16 @@ claim_block(spinlock_t *lock, int block, * new bitmap. In that case we must release write access to the old one via * ext3_journal_release_buffer(), else we'll run out of credits. */ -static int +static sector_t ext3_try_to_allocate(struct super_block *sb, handle_t *handle, int group, - struct buffer_head *bitmap_bh, int goal, struct ext3_reserve_window *my_rsv) + struct buffer_head *bitmap_bh, sector_t goal, struct ext3_reserve_window *my_rsv) { - int group_first_block, start, end; + sector_t group_first_block; + int start, end; + int bit = 0; + + if (goal != EXT3_UNSPECIFIED_GOAL) + bit = goal; /* we do allocation within the reservation window if we have a window */ if (my_rsv) { @@ -671,13 +680,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 ( (goal != EXT3_UNSPECIFIED_GOAL) || ((start <= bit) && (bit < end)) ) + start = bit; else - goal = -1; + goal = EXT3_UNSPECIFIED_GOAL; } else { - if (goal > 0) - start = goal; + if (goal != EXT3_UNSPECIFIED_GOAL) + start = bit; else start = 0; end = EXT3_BLOCKS_PER_GROUP(sb); @@ -686,34 +695,34 @@ 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 (goal == EXT3_UNSPECIFIED_GOAL || !ext3_test_allocatable(bit, bitmap_bh)) { + bit = find_next_usable_block(start, bitmap_bh, end); + if (bit < 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 && bit > start && + ext3_test_allocatable(bit - 1, bitmap_bh); - i++, goal--) + i++, bit--) ; } } - start = goal; + start = bit; - if (!claim_block(sb_bgl_lock(EXT3_SB(sb), group), goal, bitmap_bh)) { + if (!claim_block(sb_bgl_lock(EXT3_SB(sb), group), bit, bitmap_bh)) { /* * The block was allocated by another thread, or it was * allocated and then freed by another thread */ start++; - goal++; + bit++; if (start >= end) goto fail_access; goto repeat; } - return goal; + return bit; fail_access: return -1; } @@ -754,12 +763,12 @@ fail_access: static int find_next_reservable_window( struct ext3_reserve_window_node *search_head, struct ext3_reserve_window_node *my_rsv, - struct super_block * sb, int start_block, - int last_block) + struct super_block * sb, sector_t start_block, + sector_t last_block) { struct rb_node *next; struct ext3_reserve_window_node *rsv, *prev; - int cur; + sector_t cur; int size = my_rsv->rsv_goal_size; /* TODO: make the start of the reservation window byte-aligned */ @@ -873,11 +882,11 @@ static int find_next_reservable_window( * */ static int alloc_new_reservation(struct ext3_reserve_window_node *my_rsv, - int goal, struct super_block *sb, + sector_t goal, struct super_block *sb, unsigned int group, struct buffer_head *bitmap_bh) { struct ext3_reserve_window_node *search_head; - int group_first_block, group_end_block, start_block; + sector_t group_first_block, group_end_block, start_block; int first_free_block; struct rb_root *fs_rsv_root = &EXT3_SB(sb)->s_rsv_window_root; unsigned long size; @@ -888,7 +897,7 @@ 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 (goal == EXT3_UNSPECIFIED_GOAL) start_block = group_first_block; else start_block = goal + group_first_block; @@ -1023,10 +1032,10 @@ retry: static int ext3_try_to_allocate_with_rsv(struct super_block *sb, handle_t *handle, unsigned int group, struct buffer_head *bitmap_bh, - int goal, struct ext3_reserve_window_node * my_rsv, + sector_t goal, struct ext3_reserve_window_node * my_rsv, int *errp) { - unsigned long group_first_block; + sector_t group_first_block; int ret = 0; int fatal; @@ -1087,7 +1096,7 @@ ext3_try_to_allocate_with_rsv(struct sup break; /* failed */ if (!goal_in_my_reservation(&my_rsv->rsv_window, goal, group, sb)) - goal = -1; + goal = EXT3_UNSPECIFIED_GOAL; } if ((my_rsv->rsv_start >= group_first_block + EXT3_BLOCKS_PER_GROUP(sb)) || (my_rsv->rsv_end < group_first_block)) @@ -1118,7 +1127,7 @@ out: static int ext3_has_free_blocks(struct ext3_sb_info *sbi) { - int free_blocks, root_blocks; + sector_t free_blocks, root_blocks; free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter); root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count); @@ -1154,16 +1163,16 @@ int ext3_should_retry_alloc(struct super * bitmap, and then for any free bit if that fails. * This function also updates quota and i_blocks field. */ -int ext3_new_block(handle_t *handle, struct inode *inode, - unsigned long goal, int *errp) +sector_t ext3_new_block(handle_t *handle, struct inode *inode, + sector_t goal, int *errp) { struct buffer_head *bitmap_bh = NULL; struct buffer_head *gdp_bh; - int group_no; + sector_t group_no; int goal_group; int ret_block; int bgi; /* blockgroup iteration index */ - int target_block; + sector_t target_block; int fatal = 0, err; int performed_allocation = 0; int free_blocks; @@ -1220,8 +1229,7 @@ int ext3_new_block(handle_t *handle, str if (goal < le32_to_cpu(es->s_first_data_block) || goal >= le32_to_cpu(es->s_blocks_count)) goal = le32_to_cpu(es->s_first_data_block); - group_no = (goal - le32_to_cpu(es->s_first_data_block)) / - EXT3_BLOCKS_PER_GROUP(sb); + EXT3_BLOCK_GROUP(sb, group_no, ret_block, goal - le32_to_cpu(es->s_first_data_block)); gdp = ext3_get_group_desc(sb, group_no, &gdp_bh); if (!gdp) goto io_error; @@ -1238,8 +1246,7 @@ retry: my_rsv = NULL; if (free_blocks > 0) { - ret_block = ((goal - le32_to_cpu(es->s_first_data_block)) % - EXT3_BLOCKS_PER_GROUP(sb)); + EXT3_BLOCK_GROUP(sb, group_no, ret_block, goal - le32_to_cpu(es->s_first_data_block)); bitmap_bh = read_block_bitmap(sb, group_no); if (!bitmap_bh) goto io_error; @@ -1322,7 +1329,7 @@ allocated: EXT3_SB(sb)->s_itb_per_group)) ext3_error(sb, "ext3_new_block", "Allocating block in system zone - " - "block = %u", target_block); + "block = %llu", (unsigned long long)target_block); performed_allocation = 1; @@ -1352,14 +1359,13 @@ allocated: jbd_unlock_bh_state(bitmap_bh); #endif - /* ret_block was blockgroup-relative. Now it becomes fs-relative */ - ret_block = target_block; - - if (ret_block >= le32_to_cpu(es->s_blocks_count)) { + if (target_block >= le32_to_cpu(es->s_blocks_count)) { ext3_error(sb, "ext3_new_block", - "block(%d) >= blocks count(%d) - " - "block_group = %d, es == %p ", ret_block, - le32_to_cpu(es->s_blocks_count), group_no, es); + "block(%llu) >= blocks count(%d) - " + "block_group = %llu, es == %p ", + (unsigned long long)target_block, + le32_to_cpu(es->s_blocks_count), + (unsigned long long)group_no, es); goto out; } @@ -1369,7 +1375,7 @@ allocated: * the caller wants to use it as metadata or data. */ ext3_debug("allocating block %d. Goal hits %d of %d.\n", - ret_block, goal_hits, goal_attempts); + target_block, goal_hits, goal_attempts); spin_lock(sb_bgl_lock(sbi, group_no)); gdp->bg_free_blocks_count = @@ -1388,7 +1394,7 @@ allocated: *errp = 0; brelse(bitmap_bh); - return ret_block; + return target_block; io_error: *errp = -EIO; @@ -1406,7 +1412,7 @@ out: return 0; } -unsigned long ext3_count_free_blocks(struct super_block *sb) +sector_t ext3_count_free_blocks(struct super_block *sb) { unsigned long desc_count; struct ext3_group_desc *gdp; @@ -1508,7 +1514,7 @@ int ext3_bg_has_super(struct super_block * (primary or backup) in this group. In the future there may be a * different number of descriptor blocks in each group. */ -unsigned long ext3_bg_num_gdb(struct super_block *sb, int group) +sector_t ext3_bg_num_gdb(struct super_block *sb, int group) { if (EXT3_HAS_RO_COMPAT_FEATURE(sb,EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER)&& !ext3_group_sparse(group)) diff -puN include/linux/ext3_fs.h~kernel_varibles_sector_t include/linux/ext3_fs.h --- linux-2.6.16/include/linux/ext3_fs.h~kernel_varibles_sector_t 2006-05-08 11:04:03.221189792 -0700 +++ linux-2.6.16-ming/include/linux/ext3_fs.h 2006-05-08 11:25:31.344978478 -0700 @@ -147,6 +147,11 @@ struct ext3_group_desc # define EXT3_DESC_PER_BLOCK(s) (EXT3_SB(s)->s_desc_per_block) # define EXT3_INODES_PER_GROUP(s) (EXT3_SB(s)->s_inodes_per_group) # define EXT3_DESC_PER_BLOCK_BITS(s) (EXT3_SB(s)->s_desc_per_block_bits) +# define EXT3_BLOCK_GROUP(sb, block_group, offset, blocknr) \ +do { \ + block_group = (blocknr); \ + offset = sector_div(block_group, EXT3_BLOCKS_PER_GROUP(sb)); \ +} while (0) #else # define EXT3_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group) # define EXT3_DESC_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (struct ext3_group_desc)) @@ -477,7 +482,7 @@ struct ext3_super_block { __le32 s_journal_dev; /* device number of journal file */ __le32 s_last_orphan; /* start of list of inodes to delete */ __le32 s_hash_seed[4]; /* HTREE hash seed */ - __u8 s_def_hash_version; /* Default hash version to use */ +/*F0*/ __u8 s_def_hash_version; /* Default hash version to use */ __u8 s_reserved_char_pad; __u16 s_reserved_word_pad; __le32 s_default_mount_opts; @@ -730,13 +735,13 @@ 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 int ext3_new_block (handle_t *, struct inode *, unsigned long, int *); -extern void ext3_free_blocks (handle_t *, struct inode *, unsigned long, - unsigned long); +extern sector_t ext3_bg_num_gdb(struct super_block *sb, int group); +extern sector_t ext3_new_block (handle_t *, struct inode *, sector_t, int *); +extern void ext3_free_blocks (handle_t *, struct inode *, sector_t, + sector_t); extern void ext3_free_blocks_sb (handle_t *, struct super_block *, - unsigned long, unsigned long, int *); -extern unsigned long ext3_count_free_blocks (struct super_block *); + sector_t, sector_t, sector_t *); +extern sector_t 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, unsigned int block_group, @@ -768,13 +773,13 @@ extern struct inode * ext3_orphan_get (s extern unsigned long ext3_count_free_inodes (struct super_block *); extern unsigned long ext3_count_dirs (struct super_block *); extern void ext3_check_inodes_bitmap (struct super_block *); -extern unsigned long ext3_count_free (struct buffer_head *, unsigned); +extern sector_t ext3_count_free (struct buffer_head *, unsigned); /* inode.c */ -extern int ext3_forget(handle_t *, int, struct inode *, struct buffer_head *, int); -extern struct buffer_head * ext3_getblk (handle_t *, struct inode *, long, int, int *); -extern struct buffer_head * ext3_bread (handle_t *, struct inode *, int, int, int *); +extern int ext3_forget(handle_t *, int, struct inode *, struct buffer_head *, sector_t); +extern struct buffer_head * ext3_getblk (handle_t *, struct inode *, sector_t, int, int *); +extern struct buffer_head * ext3_bread (handle_t *, struct inode *, sector_t, int, int *); extern void ext3_read_inode (struct inode *); extern int ext3_write_inode (struct inode *, int); @@ -804,7 +809,7 @@ extern int ext3_group_add(struct super_b struct ext3_new_group_data *input); extern int ext3_group_extend(struct super_block *sb, struct ext3_super_block *es, - unsigned long n_blocks_count); + sector_t n_blocks_count); /* super.c */ extern void ext3_error (struct super_block *, const char *, const char *, ...) diff -puN fs/ext3/bitmap.c~kernel_varibles_sector_t fs/ext3/bitmap.c --- linux-2.6.16/fs/ext3/bitmap.c~kernel_varibles_sector_t 2006-05-08 11:04:03.224189444 -0700 +++ linux-2.6.16-ming/fs/ext3/bitmap.c 2006-05-08 11:04:03.256185739 -0700 @@ -15,10 +15,10 @@ static int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0}; -unsigned long ext3_count_free (struct buffer_head * map, unsigned int numchars) +sector_t ext3_count_free (struct buffer_head * map, unsigned int numchars) { unsigned int i; - unsigned long sum = 0; + sector_t sum = 0; if (!map) return (0); diff -puN fs/ext3/inode.c~kernel_varibles_sector_t fs/ext3/inode.c --- linux-2.6.16/fs/ext3/inode.c~kernel_varibles_sector_t 2006-05-08 11:04:03.228188981 -0700 +++ linux-2.6.16-ming/fs/ext3/inode.c 2006-05-08 11:25:31.362976400 -0700 @@ -64,7 +64,7 @@ static inline int ext3_inode_is_fast_sym int ext3_forget(handle_t *handle, int is_metadata, struct inode *inode, struct buffer_head *bh, - int blocknr) + sector_t blocknr) { int err; @@ -108,9 +108,9 @@ int ext3_forget(handle_t *handle, int is * truncate transaction. */ -static unsigned long blocks_for_truncate(struct inode *inode) +static sector_t blocks_for_truncate(struct inode *inode) { - unsigned long needed; + sector_t needed; needed = inode->i_blocks >> (inode->i_sb->s_blocksize_bits - 9); @@ -235,10 +235,10 @@ no_delete: clear_inode(inode); /* We must guarantee clearing of inode... */ } -static int ext3_alloc_block (handle_t *handle, - struct inode * inode, unsigned long goal, int *err) +static sector_t ext3_alloc_block (handle_t *handle, + struct inode * inode, sector_t goal, int *err) { - unsigned long result; + sector_t result; result = ext3_new_block(handle, inode, goal, err); return result; @@ -420,13 +420,13 @@ no_block: * Caller must make sure that @ind is valid and will stay that way. */ -static unsigned long ext3_find_near(struct inode *inode, Indirect *ind) +static sector_t ext3_find_near(struct inode *inode, Indirect *ind) { struct ext3_inode_info *ei = EXT3_I(inode); __le32 *start = ind->bh ? (__le32*) ind->bh->b_data : ei->i_data; __le32 *p; - unsigned long bg_start; - unsigned long colour; + sector_t bg_start; + sector_t colour; /* Try to find previous block */ for (p = ind->p - 1; p >= start; p--) @@ -460,7 +460,7 @@ static unsigned long ext3_find_near(stru * stores it in *@goal and returns zero. */ -static unsigned long ext3_find_goal(struct inode *inode, long block, +static sector_t ext3_find_goal(struct inode *inode, long block, Indirect chain[4], Indirect *partial) { struct ext3_block_alloc_info *block_i = EXT3_I(inode)->i_block_alloc_info; @@ -504,7 +504,7 @@ static unsigned long ext3_find_goal(stru static int ext3_alloc_branch(handle_t *handle, struct inode *inode, int num, - unsigned long goal, + sector_t goal, int *offsets, Indirect *branch) { @@ -512,14 +512,14 @@ static int ext3_alloc_branch(handle_t *h int n = 0, keys = 0; int err = 0; int i; - int parent = ext3_alloc_block(handle, inode, goal, &err); + sector_t parent = ext3_alloc_block(handle, inode, goal, &err); branch[0].key = cpu_to_le32(parent); if (parent) { for (n = 1; n < num; n++) { struct buffer_head *bh; /* Allocate the next block */ - int nr = ext3_alloc_block(handle, inode, parent, &err); + sector_t nr = ext3_alloc_block(handle, inode, parent, &err); if (!nr) break; branch[n].key = cpu_to_le32(nr); @@ -679,7 +679,7 @@ ext3_get_block_handle(handle_t *handle, int offsets[4]; Indirect chain[4]; Indirect *partial; - unsigned long goal; + sector_t goal; int left; int boundary = 0; const int depth = ext3_block_to_path(inode, iblock, offsets, &boundary); @@ -852,7 +852,7 @@ get_block: * `handle' can be NULL if create is zero */ struct buffer_head *ext3_getblk(handle_t *handle, struct inode * inode, - long block, int create, int * errp) + sector_t block, int create, int * errp) { struct buffer_head dummy; int fatal = 0, err; @@ -907,7 +907,7 @@ err: } struct buffer_head *ext3_bread(handle_t *handle, struct inode * inode, - int block, int create, int *err) + sector_t block, int create, int *err) { struct buffer_head * bh; @@ -1608,7 +1608,7 @@ void ext3_set_aops(struct inode *inode) static int ext3_block_truncate_page(handle_t *handle, struct page *page, struct address_space *mapping, loff_t from) { - unsigned long index = from >> PAGE_CACHE_SHIFT; + sector_t index = from >> PAGE_CACHE_SHIFT; unsigned offset = from & (PAGE_CACHE_SIZE-1); unsigned blocksize, iblock, length, pos; struct inode *inode = mapping->host; @@ -1814,7 +1814,7 @@ no_top: */ static void ext3_clear_blocks(handle_t *handle, struct inode *inode, struct buffer_head *bh, - unsigned long block_to_free, unsigned long count, + sector_t block_to_free, sector_t count, __le32 *first, __le32 *last) { __le32 *p; @@ -1876,12 +1876,12 @@ static void ext3_free_data(handle_t *han struct buffer_head *this_bh, __le32 *first, __le32 *last) { - unsigned long block_to_free = 0; /* Starting block # of a run */ - unsigned long count = 0; /* Number of blocks in the run */ + sector_t block_to_free = 0; /* Starting block # of a run */ + sector_t count = 0; /* Number of blocks in the run */ __le32 *block_to_free_p = NULL; /* Pointer into inode/ind corresponding to block_to_free */ - unsigned long nr; /* Current block # */ + sector_t nr; /* Current block # */ __le32 *p; /* Pointer into inode/ind for current block */ int err; @@ -1943,7 +1943,7 @@ static void ext3_free_branches(handle_t struct buffer_head *parent_bh, __le32 *first, __le32 *last, int depth) { - unsigned long nr; + sector_t nr; __le32 *p; if (is_handle_aborted(handle)) @@ -1967,8 +1967,8 @@ static void ext3_free_branches(handle_t */ if (!bh) { ext3_error(inode->i_sb, "ext3_free_branches", - "Read failure, inode=%ld, block=%ld", - inode->i_ino, nr); + "Read failure, inode=%ld, block=%llu", + inode->i_ino, (unsigned long long)nr); continue; } @@ -2250,11 +2250,12 @@ out_stop: ext3_journal_stop(handle); } -static unsigned long ext3_get_inode_block(struct super_block *sb, +static sector_t ext3_get_inode_block(struct super_block *sb, unsigned long ino, struct ext3_iloc *iloc) { unsigned long desc, group_desc, block_group; - unsigned long offset, block; + unsigned long offset; + sector_t block; struct buffer_head *bh; struct ext3_group_desc * gdp; @@ -2308,7 +2309,7 @@ static unsigned long ext3_get_inode_bloc static int __ext3_get_inode_loc(struct inode *inode, struct ext3_iloc *iloc, int in_mem) { - unsigned long block; + sector_t block; struct buffer_head *bh; block = ext3_get_inode_block(inode->i_sb, inode->i_ino, iloc); @@ -2319,7 +2320,8 @@ static int __ext3_get_inode_loc(struct i if (!bh) { ext3_error (inode->i_sb, "ext3_get_inode_loc", "unable to read inode block - " - "inode=%lu, block=%lu", inode->i_ino, block); + "inode=%lu, block=%llu", inode->i_ino, + (unsigned long long)block); return -EIO; } if (!buffer_uptodate(bh)) { @@ -2400,8 +2402,8 @@ make_io: if (!buffer_uptodate(bh)) { ext3_error(inode->i_sb, "ext3_get_inode_loc", "unable to read inode block - " - "inode=%lu, block=%lu", - inode->i_ino, block); + "inode=%lu, block=%llu", + inode->i_ino, (unsigned long long)block); brelse(bh); return -EIO; } diff -puN fs/ext3/namei.c~kernel_varibles_sector_t fs/ext3/namei.c --- linux-2.6.16/fs/ext3/namei.c~kernel_varibles_sector_t 2006-05-08 11:04:03.232188518 -0700 +++ linux-2.6.16-ming/fs/ext3/namei.c 2006-05-08 11:04:03.267184465 -0700 @@ -51,7 +51,7 @@ static struct buffer_head *ext3_append(handle_t *handle, struct inode *inode, - u32 *block, int *err) + sector_t *block, int *err) { struct buffer_head *bh; @@ -297,7 +297,7 @@ struct stats dx_show_entries(struct dx_h printk("%i indexed blocks...\n", count); for (i = 0; i < count; i++, entries++) { - u32 block = dx_get_block(entries), hash = i? dx_get_hash(entries): 0; + sector_t block = dx_get_block(entries), hash = i? dx_get_hash(entries): 0; u32 range = i < count - 1? (dx_get_hash(entries + 1) - hash): ~hash; struct stats stats; printk("%s%3u:%03u hash %8x/%8x ",levels?"":" ", i, block, hash, range); @@ -810,7 +810,7 @@ static struct buffer_head * ext3_find_en struct super_block * sb; struct buffer_head * bh_use[NAMEI_RA_SIZE]; struct buffer_head * bh, *ret = NULL; - unsigned long start, block, b; + sector_t start, block, b; int ra_max = 0; /* Number of bh's in the readahead buffer, bh_use[] */ int ra_ptr = 0; /* Current index into readahead @@ -879,7 +879,7 @@ restart: if (!buffer_uptodate(bh)) { /* read error, skip block & hope for the best */ ext3_error(sb, __FUNCTION__, "reading directory #%lu " - "offset %lu", dir->i_ino, block); + "offset %llu", dir->i_ino, (unsigned long long)block); brelse(bh); goto next; } @@ -927,7 +927,7 @@ static struct buffer_head * ext3_dx_find struct dx_frame frames[2], *frame; struct ext3_dir_entry_2 *de, *top; struct buffer_head *bh; - unsigned long block; + sector_t block; int retval; int namelen = dentry->d_name.len; const u8 *name = dentry->d_name.name; @@ -1107,7 +1107,7 @@ static struct ext3_dir_entry_2 *do_split unsigned blocksize = dir->i_sb->s_blocksize; unsigned count, continued; struct buffer_head *bh2; - u32 newblock; + sector_t newblock; u32 hash2; struct dx_map_entry *map; char *data1 = (*bh)->b_data, *data2; @@ -1296,7 +1296,7 @@ static int make_indexed_dir(handle_t *ha int retval; unsigned blocksize; struct dx_hash_info hinfo; - u32 block; + sector_t block; struct fake_dirent *fde; blocksize = dir->i_sb->s_blocksize; @@ -1380,7 +1380,7 @@ static int ext3_add_entry (handle_t *han #endif unsigned blocksize; unsigned nlen, rlen; - u32 block, blocks; + sector_t block, blocks; sb = dir->i_sb; blocksize = sb->s_blocksize; @@ -1463,7 +1463,7 @@ static int ext3_dx_add_entry(handle_t *h dx_get_count(entries), dx_get_limit(entries))); /* Need to split index? */ if (dx_get_count(entries) == dx_get_limit(entries)) { - u32 newblock; + sector_t newblock; unsigned icount = dx_get_count(entries); int levels = frame - frames; struct dx_entry *entries2; diff -puN fs/ext3/resize.c~kernel_varibles_sector_t fs/ext3/resize.c --- linux-2.6.16/fs/ext3/resize.c~kernel_varibles_sector_t 2006-05-08 11:04:03.235188170 -0700 +++ linux-2.6.16-ming/fs/ext3/resize.c 2006-05-08 11:22:35.377287374 -0700 @@ -18,6 +18,7 @@ #include #include +#include #define outside(b, first, last) ((b) < (first) || (b) >= (last)) @@ -112,7 +113,7 @@ static int verify_group_input(struct sup } static struct buffer_head *bclean(handle_t *handle, struct super_block *sb, - unsigned long blk) + sector_t blk) { struct buffer_head *bh; int err; @@ -163,14 +164,14 @@ static int setup_new_group_blocks(struct struct ext3_new_group_data *input) { struct ext3_sb_info *sbi = EXT3_SB(sb); - unsigned long start = input->group * sbi->s_blocks_per_group + + sector_t start = input->group * sbi->s_blocks_per_group + le32_to_cpu(sbi->s_es->s_first_data_block); 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); + sector_t gdblocks = ext3_bg_num_gdb(sb, input->group); struct buffer_head *bh; handle_t *handle; - unsigned long block; + sector_t block; int bit; int i; int err = 0, err2; @@ -328,7 +329,7 @@ static unsigned ext3_list_backups(struct static int verify_reserved_gdb(struct super_block *sb, struct buffer_head *primary) { - const unsigned long blk = primary->b_blocknr; + const sector_t blk = primary->b_blocknr; const unsigned long end = EXT3_SB(sb)->s_groups_count; unsigned three = 1; unsigned five = 5; @@ -340,9 +341,9 @@ static int verify_reserved_gdb(struct su while ((grp = ext3_list_backups(sb, &three, &five, &seven)) < end) { if (le32_to_cpu(*p++) != grp * EXT3_BLOCKS_PER_GROUP(sb) + blk){ ext3_warning(sb, __FUNCTION__, - "reserved GDT %ld missing grp %d (%ld)", - blk, grp, - grp * EXT3_BLOCKS_PER_GROUP(sb) + blk); + "reserved GDT %llu missing grp %d (%llu)", + (unsigned long long)blk, grp, + (unsigned long long)(grp * EXT3_BLOCKS_PER_GROUP(sb) + blk)); return -EINVAL; } if (++gdbackups > EXT3_ADDR_PER_BLOCK(sb)) @@ -515,7 +516,7 @@ static int reserve_backup_gdb(handle_t * struct buffer_head **primary; struct buffer_head *dind; struct ext3_iloc iloc; - unsigned long blk; + sector_t blk; __u32 *data, *end; int gdbackups = 0; int res, i; @@ -540,8 +541,9 @@ static int reserve_backup_gdb(handle_t * for (res = 0; res < reserved_gdb; res++, blk++) { if (le32_to_cpu(*data) != blk) { ext3_warning(sb, __FUNCTION__, - "reserved block %lu not at offset %ld", - blk, (long)(data - (__u32 *)dind->b_data)); + "reserved block %llu not at offset %ld", + (unsigned long long)blk, + (long)(data - (__u32 *)dind->b_data)); err = -EINVAL; goto exit_bh; } @@ -902,15 +904,16 @@ exit_put: * GDT blocks are reserved to grow to the desired size. */ int ext3_group_extend(struct super_block *sb, struct ext3_super_block *es, - unsigned long n_blocks_count) + sector_t n_blocks_count) { - unsigned long o_blocks_count; + sector_t o_blocks_count; unsigned long o_groups_count; unsigned long last; int add; struct buffer_head * bh; handle_t *handle; - int err, freed_blocks; + int err; + sector_t 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 @@ -919,8 +922,9 @@ int ext3_group_extend(struct super_block o_groups_count = EXT3_SB(sb)->s_groups_count; if (test_opt(sb, DEBUG)) - printk(KERN_DEBUG "EXT3-fs: extending last group from %lu to %lu blocks\n", - o_blocks_count, n_blocks_count); + printk(KERN_DEBUG "EXT3-fs: extending last group from %llu to %llu blocks\n", + (unsigned long long)o_blocks_count, + (unsigned long long)n_blocks_count); if (n_blocks_count == 0 || n_blocks_count == o_blocks_count) return 0; @@ -932,8 +936,8 @@ int ext3_group_extend(struct super_block } /* Handle the remaining blocks in the last group only. */ - last = (o_blocks_count - le32_to_cpu(es->s_first_data_block)) % - EXT3_BLOCKS_PER_GROUP(sb); + last = o_blocks_count - le32_to_cpu(es->s_first_data_block); + last = sector_div(last, EXT3_BLOCKS_PER_GROUP(sb)); if (last == 0) { ext3_warning(sb, __FUNCTION__, @@ -948,8 +952,8 @@ int ext3_group_extend(struct super_block if (o_blocks_count + add < n_blocks_count) ext3_warning(sb, __FUNCTION__, - "will only finish group (%lu blocks, %u new)", - o_blocks_count + add, add); + "will only finish group (%llu blocks, %u new)", + (unsigned long long)(o_blocks_count + add), add); /* See if the device is actually as big as what was requested */ bh = sb_bread(sb, o_blocks_count + add -1); diff -puN fs/ext3/super.c~kernel_varibles_sector_t fs/ext3/super.c --- linux-2.6.16/fs/ext3/super.c~kernel_varibles_sector_t 2006-05-08 11:04:03.239187707 -0700 +++ linux-2.6.16-ming/fs/ext3/super.c 2006-05-08 11:25:31.367975822 -0700 @@ -36,6 +36,7 @@ #include #include #include +#include #include @@ -687,9 +688,9 @@ static match_table_t tokens = { {Opt_resize, "resize"}, }; -static unsigned long get_sb_block(void **data) +static sector_t get_sb_block(void **data) { - unsigned long sb_block; + sector_t sb_block; char *options = (char *) *data; if (!options || strncmp(options, "sb=", 3) != 0) @@ -709,7 +710,7 @@ static unsigned long get_sb_block(void * static int parse_options (char *options, struct super_block *sb, unsigned long *inum, unsigned long *journal_devnum, - unsigned long *n_blocks_count, int is_remount) + sector_t *n_blocks_count, int is_remount) { struct ext3_sb_info *sbi = EXT3_SB(sb); char * p; @@ -1126,7 +1127,7 @@ static int ext3_setup_super(struct super static int ext3_check_descriptors (struct super_block * sb) { struct ext3_sb_info *sbi = EXT3_SB(sb); - unsigned long block = le32_to_cpu(sbi->s_es->s_first_data_block); + sector_t block = le32_to_cpu(sbi->s_es->s_first_data_block); struct ext3_group_desc * gdp = NULL; int desc_block = 0; int i; @@ -1144,8 +1145,8 @@ static int ext3_check_descriptors (struc { ext3_error (sb, "ext3_check_descriptors", "Block bitmap for group %d" - " not in group (block %lu)!", - i, (unsigned long) + " not in group (block %llu)!", + i, (unsigned long long) le32_to_cpu(gdp->bg_block_bitmap)); return 0; } @@ -1155,8 +1156,8 @@ static int ext3_check_descriptors (struc { ext3_error (sb, "ext3_check_descriptors", "Inode bitmap for group %d" - " not in group (block %lu)!", - i, (unsigned long) + " not in group (block %llu)!", + i, (unsigned long long) le32_to_cpu(gdp->bg_inode_bitmap)); return 0; } @@ -1166,8 +1167,8 @@ static int ext3_check_descriptors (struc { ext3_error (sb, "ext3_check_descriptors", "Inode table for group %d" - " not in group (block %lu)!", - i, (unsigned long) + " not in group (block %llu)!", + i, (unsigned long long) le32_to_cpu(gdp->bg_inode_table)); return 0; } @@ -1313,12 +1314,12 @@ static loff_t ext3_max_size(int bits) return res; } -static unsigned long descriptor_loc(struct super_block *sb, - unsigned long logic_sb_block, +static sector_t descriptor_loc(struct super_block *sb, + sector_t logic_sb_block, int nr) { struct ext3_sb_info *sbi = EXT3_SB(sb); - unsigned long bg, first_data_block, first_meta_bg; + sector_t bg, first_data_block, first_meta_bg; int has_super = 0; first_data_block = le32_to_cpu(sbi->s_es->s_first_data_block); @@ -1339,9 +1340,9 @@ static int ext3_fill_super (struct super struct buffer_head * bh; struct ext3_super_block *es = NULL; struct ext3_sb_info *sbi; - unsigned long block; - unsigned long sb_block = get_sb_block(&data); - unsigned long logic_sb_block; + sector_t block; + sector_t sb_block = get_sb_block(&data); + sector_t logic_sb_block; unsigned long offset = 0; unsigned long journal_inum = 0; unsigned long journal_devnum = 0; @@ -1376,8 +1377,8 @@ static int ext3_fill_super (struct super * block sizes. We need to calculate the offset from buffer start. */ if (blocksize != EXT3_MIN_BLOCK_SIZE) { - logic_sb_block = (sb_block * EXT3_MIN_BLOCK_SIZE) / blocksize; - offset = (sb_block * EXT3_MIN_BLOCK_SIZE) % blocksize; + logic_sb_block = sb_block * EXT3_MIN_BLOCK_SIZE; + offset = sector_div(logic_sb_block, blocksize); } else { logic_sb_block = sb_block; } @@ -1451,6 +1452,7 @@ static int ext3_fill_super (struct super sb->s_id, le32_to_cpu(features)); goto failed_mount; } + features = EXT3_HAS_RO_COMPAT_FEATURE(sb, ~EXT3_FEATURE_RO_COMPAT_SUPP); if (!(sb->s_flags & MS_RDONLY) && features) { printk(KERN_ERR "EXT3-fs: %s: couldn't mount RDWR because of " @@ -1482,8 +1484,8 @@ static int ext3_fill_super (struct super brelse (bh); sb_set_blocksize(sb, blocksize); - logic_sb_block = (sb_block * EXT3_MIN_BLOCK_SIZE) / blocksize; - offset = (sb_block * EXT3_MIN_BLOCK_SIZE) % blocksize; + logic_sb_block = sb_block * EXT3_MIN_BLOCK_SIZE; + offset = sector_div(logic_sb_block, blocksize); bh = sb_bread(sb, logic_sb_block); if (!bh) { printk(KERN_ERR @@ -1835,7 +1837,7 @@ static journal_t *ext3_get_dev_journal(s int start; int len; int hblock, blocksize; - unsigned long sb_block; + sector_t sb_block; unsigned long offset; struct ext3_super_block * es; struct block_device *bdev; @@ -2208,7 +2210,7 @@ static int ext3_remount (struct super_bl { struct ext3_super_block * es; struct ext3_sb_info *sbi = EXT3_SB(sb); - unsigned long n_blocks_count = 0; + sector_t n_blocks_count = 0; unsigned long old_sb_flags; struct ext3_mount_options old_opts; int err; @@ -2326,7 +2328,7 @@ restore_opts: static int ext3_statfs (struct super_block * sb, struct kstatfs * buf) { struct ext3_super_block *es = EXT3_SB(sb)->s_es; - unsigned long overhead; + sector_t overhead; int i; if (test_opt (sb, MINIX_DF)) diff -puN fs/ext3/xattr.c~kernel_varibles_sector_t fs/ext3/xattr.c --- linux-2.6.16/fs/ext3/xattr.c~kernel_varibles_sector_t 2006-05-08 11:04:03.242187360 -0700 +++ linux-2.6.16-ming/fs/ext3/xattr.c 2006-05-08 11:04:03.276183423 -0700 @@ -82,9 +82,9 @@ } while (0) # define ea_bdebug(bh, f...) do { \ char b[BDEVNAME_SIZE]; \ - printk(KERN_DEBUG "block %s:%lu: ", \ + printk(KERN_DEBUG "block %s:%llu: ", \ bdevname(bh->b_bdev, b), \ - (unsigned long) bh->b_blocknr); \ + (unsigned long long) bh->b_blocknr); \ printk(f); \ printk("\n"); \ } while (0) @@ -792,14 +792,14 @@ inserted: get_bh(new_bh); } else { /* We need to allocate a new block */ - int goal = le32_to_cpu( + sector_t goal = le32_to_cpu( EXT3_SB(sb)->s_es->s_first_data_block) + EXT3_I(inode)->i_block_group * EXT3_BLOCKS_PER_GROUP(sb); - int block = ext3_new_block(handle, inode, goal, &error); + sector_t block = ext3_new_block(handle, inode, goal, &error); if (error) goto cleanup; - ea_idebug(inode, "creating block %d", block); + ea_idebug(inode, "creating block %llu", (unsigned long long)block); new_bh = sb_getblk(sb, block); if (!new_bh) { diff -puN include/linux/ext3_fs_i.h~kernel_varibles_sector_t include/linux/ext3_fs_i.h --- linux-2.6.16/include/linux/ext3_fs_i.h~kernel_varibles_sector_t 2006-05-08 11:04:03.247186781 -0700 +++ linux-2.6.16-ming/include/linux/ext3_fs_i.h 2006-05-08 11:25:31.344978478 -0700 @@ -21,8 +21,8 @@ #include struct ext3_reserve_window { - __u32 _rsv_start; /* First byte reserved */ - __u32 _rsv_end; /* Last byte reserved or 0 */ + sector_t _rsv_start; /* First byte reserved */ + sector_t _rsv_end; /* Last byte reserved or 0 */ }; struct ext3_reserve_window_node { @@ -41,7 +41,7 @@ struct ext3_block_alloc_info { * most-recently-allocated block in this file. * We use this for detecting linearly ascending allocation requests. */ - __u32 last_alloc_logical_block; + sector_t last_alloc_logical_block; /* * Was i_next_alloc_goal in ext3_inode_info * is the *physical* companion to i_next_alloc_block. @@ -49,7 +49,7 @@ struct ext3_block_alloc_info { * allocated to this file. This give us the goal (target) for the next * allocation when we detect linearly ascending requests. */ - __u32 last_alloc_physical_block; + sector_t last_alloc_physical_block; }; #define rsv_start rsv_window._rsv_start @@ -62,7 +62,7 @@ struct ext3_inode_info { __le32 i_data[15]; /* unconverted */ __u32 i_flags; #ifdef EXT3_FRAGMENTS - __u32 i_faddr; + sector_t i_faddr; __u8 i_frag_no; __u8 i_frag_size; #endif _