ext3_fsblk_t: filesystem, group blocks and bug fixes
PATCH 1/2 ext3_fsblk_t: filesystem, group blocks and bug fixes
[Patch 1]ext3_fsblk_t, ext3_grpblk_t and type fixes.
defines ext3_fsblk_t and ext3_grpblk_t, and the printk format string for filesystem wide blocks.
This patch classifies all block group relative blocks, and ext3_fsblk_t blocks occurs in the same function where used to be confusing before. Also include kernel bug fixes for filesystem wide in-kernel block variables. There are some fileystem wide blocks are treated as int/unsigned int type in the kernel currently, especially in ext3 block allocation and reservation code. This patch fixed those bugs by converting those variables to ext3_fsblk_t(unsigned long) type.
---
linux-2.6.17-rc4-ming/fs/ext3/balloc.c | 215 ++++++++++++------------ linux-2.6.17-rc4-ming/fs/ext3/ialloc.c | 10 - linux-2.6.17-rc4-ming/fs/ext3/inode.c | 2 linux-2.6.17-rc4-ming/fs/ext3/resize.c | 43 ++-- linux-2.6.17-rc4-ming/fs/ext3/super.c | 2 linux-2.6.17-rc4-ming/fs/ext3/xattr.c | 27 +-- linux-2.6.17-rc4-ming/include/linux/ext3_fs.h | 19 +- linux-2.6.17-rc4-ming/include/linux/ext3_fs_i.h | 8 8 files changed, 177 insertions(+), 149 deletions(-)
include/linux/ext3_fs_i.h renamed from include/linux/ext3_fs_i.h~ext3_fsblk_t_fixes +8 -0
@@ -21,6 +21,14 @@#include <linux/seqlock.h> #include <linux/mutex.h> +/* data type for block offset of block group */ +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 */ __u32 _rsv_end;/* Last byte reserved or 0 */
include/linux/ext3_fs.h renamed from include/linux/ext3_fs.h~ext3_fsblk_t_fixes +11 -8
@@ -732,13 +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 int ext3_new_block (handle_t *,struct inode *,unsigned long ,int *); -extern int ext3_new_blocks (handle_t *,struct inode *,unsigned long , -unsigned long *,int *); -extern void ext3_free_blocks (handle_t *,struct inode *,unsigned long , -unsigned long ); -extern void ext3_free_blocks_sb (handle_t *,struct super_block *, -unsigned long ,unsigned long ,int *); +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,
@@ -775,7 +777,8 @@ extern unsigned long ext3_count_free (st/* inode.c */ -int ext3_forget (handle_t *,int ,struct inode *,struct buffer_head *,int ); +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,
fs/ext3/balloc.c renamed from fs/ext3/balloc.c~ext3_fsblk_t_fixes +112 -103
523 lines not on this page · raw message
fs/ext3/ialloc.c renamed from fs/ext3/ialloc.c~ext3_fsblk_t_fixes +6 -4
@@ -262,9 +262,11 @@ static int find_group_orlov(struct superint ngroups = sbi->s_groups_count;int inodes_per_group =EXT3_INODES_PER_GROUP (sb);int freei, avefreei; -int freeb, avefreeb; -int blocks_per_dir, ndirs; -int max_debt, max_dirs, min_blocks, min_inodes; +ext3_fsblk_t freeb, avefreeb; +ext3_fsblk_t blocks_per_dir; +int ndirs; +int max_debt, max_dirs, min_inodes; +ext3_grpblk_t min_blocks;int group =-1 , i;struct ext3_group_desc *desc;struct buffer_head *bh;
@@ -307,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 )
fs/ext3/inode.c renamed from fs/ext3/inode.c~ext3_fsblk_t_fixes +1 -1
@@ -62,7 +62,7 @@ static int ext3_inode_is_fast_symlink(st* still needs to be revoked. */ int ext3_forget (handle_t *handle,int is_metadata,struct inode *inode, -struct buffer_head *bh,int blocknr) +struct buffer_head *bh,ext3_fsblk_t blocknr) {int err;
fs/ext3/resize.c renamed from fs/ext3/resize.c~ext3_fsblk_t_fixes +24 -19
113 lines not on this page · raw message
fs/ext3/super.c renamed from fs/ext3/super.c~ext3_fsblk_t_fixes +1 -1
@@ -1840,7 +1840,7 @@ static journal_t *ext3_get_dev_journal(sstruct buffer_head * bh;journal_t *journal;int start; -int len; +ext3_fsblk_t len;int hblock, blocksize;unsigned long sb_block;unsigned long offset;
fs/ext3/xattr.c renamed from fs/ext3/xattr.c~ext3_fsblk_t_fixes +14 -13
@@ -225,7 +225,7 @@ ext3_xattr_block_get(struct inode *inode error = -ENODATA ;if (!EXT3_I (inode)->i_file_acl) goto cleanup; -ea_idebug (inode,"reading block %d" ,EXT3_I (inode)->i_file_acl); +ea_idebug (inode,"reading block %u" ,EXT3_I (inode)->i_file_acl); bh =sb_bread (inode->i_sb,EXT3_I (inode)->i_file_acl);if (!bh) goto cleanup;
@@ -233,7 +233,7 @@ ext3_xattr_block_get(struct inode *inode atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount));if (ext3_xattr_check_block (bh)) { bad_block:ext3_error (inode->i_sb, __FUNCTION__, -"inode %ld: bad block %d" , inode->i_ino, +"inode %ld: bad block %u" , inode->i_ino,EXT3_I (inode)->i_file_acl); error = -EIO ; goto cleanup;
@@ -366,7 +366,7 @@ ext3_xattr_block_list(struct inode *inod error =0 ;if (!EXT3_I (inode)->i_file_acl) goto cleanup; -ea_idebug (inode,"reading block %d" ,EXT3_I (inode)->i_file_acl); +ea_idebug (inode,"reading block %u" ,EXT3_I (inode)->i_file_acl); bh =sb_bread (inode->i_sb,EXT3_I (inode)->i_file_acl); error = -EIO ;if (!bh)
@@ -375,7 +375,7 @@ ext3_xattr_block_list(struct inode *inod atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount));if (ext3_xattr_check_block (bh)) {ext3_error (inode->i_sb, __FUNCTION__, -"inode %ld: bad block %d" , inode->i_ino, +"inode %ld: bad block %u" , inode->i_ino,EXT3_I (inode)->i_file_acl); error = -EIO ; goto cleanup;
@@ -647,7 +647,7 @@ ext3_xattr_block_find(struct inode *inod le32_to_cpu(BHDR(bs->bh)->h_refcount));if (ext3_xattr_check_block (bs->bh)) {ext3_error (sb, __FUNCTION__, -"inode %ld: bad block %d" , inode->i_ino, +"inode %ld: bad block %u" , inode->i_ino,EXT3_I (inode)->i_file_acl); error = -EIO ; goto cleanup;
@@ -792,11 +792,12 @@ inserted:get_bh (new_bh); }else {/* We need to allocate a new block */ -int goal =le32_to_cpu ( +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); -int block =ext3_new_block (handle, inode, goal, &error); +ext3_fsblk_t block =ext3_new_block (handle, inode, + goal, &error);if (error) goto cleanup;ea_idebug (inode,"creating block %d" , block);
@@ -847,7 +848,7 @@ cleanup_dquot: bad_block:ext3_error (inode->i_sb, __FUNCTION__, -"inode %ld: bad block %d" , inode->i_ino, +"inode %ld: bad block %u" , inode->i_ino,EXT3_I (inode)->i_file_acl); goto cleanup;
@@ -1076,14 +1077,14 @@ ext3_xattr_delete_inode(handle_t *handle bh =sb_bread (inode->i_sb,EXT3_I (inode)->i_file_acl);if (!bh) {ext3_error (inode->i_sb, __FUNCTION__, -"inode %ld: block %d read error" , inode->i_ino, +"inode %ld: block %u read error" , inode->i_ino,EXT3_I (inode)->i_file_acl); goto cleanup; }if (BHDR (bh)->h_magic !=cpu_to_le32 (EXT3_XATTR_MAGIC ) ||BHDR (bh)->h_blocks !=cpu_to_le32 (1 )) {ext3_error (inode->i_sb, __FUNCTION__, -"inode %ld: bad block %d" , inode->i_ino, +"inode %ld: bad block %u" , inode->i_ino,EXT3_I (inode)->i_file_acl); goto cleanup; }
@@ -1210,11 +1211,11 @@ again: bh =sb_bread (inode->i_sb, ce->e_block);if (!bh) {ext3_error (inode->i_sb, __FUNCTION__, -"inode %ld: block %ld read error" , +"inode %ld: block %lu read error" , inode->i_ino, (unsigned long ) ce->e_block); }else if (le32_to_cpu (BHDR (bh)->h_refcount) >=EXT3_XATTR_REFCOUNT_MAX ) { -ea_idebug (inode,"block %ld refcount %d>=%d" , +ea_idebug (inode,"block %lu refcount %d>=%d" , (unsigned long ) ce->e_block,le32_to_cpu (BHDR (bh)->h_refcount),EXT3_XATTR_REFCOUNT_MAX );
_