Small cleanup of ext[34] get_blocks function
Jan Kara
reviewercover Small cleanup of ext[34] get_blocks function
Hi,
two patches below cleanup get_blocks() functions of ext3 and ext4 - they
remove parameter extend_disksize which was in fact unused. Ted, would you merge the ext4 patch and Andrew, would you merge the ext3 patch? Thanks.
Honza
Jan Kara
reviewerPATCH 1/2 ext3: Get rid of extenddisksize parameter of ext3_get_blocks_handle()
Get rid of extenddisksize parameter of ext3_get_blocks_handle(). This seems to be a relict from some old days and setting disksize in this function does not make much sence. Currently it was set only by ext3_getblk(). Since the parameter has some effect only if create == 1, it is easy to check that the three callers which end up calling ext3_getblk() with create == 1 (ext3_append, ext3_quota_write, ext3_mkdir) do the right thing and set disksize themselves.
--- fs/ext3/dir.c | 3 +-- fs/ext3/inode.c | 13 +++---------- include/linux/ext3_fs.h | 2 +- 3 files changed, 5 insertions(+), 13 deletions(-)
fs/ext3/dir.c +1 -2
@@ -130,8 +130,7 @@ static int ext3_readdir(struct file * filp,struct buffer_head *bh =NULL ; map_bh.b_state =0 ; - err =ext3_get_blocks_handle (NULL , inode, blk,1 , - &map_bh,0 ,0 ); + err =ext3_get_blocks_handle (NULL , inode, blk,1 , &map_bh,0 );if (err >0 ) {pgoff_t index = map_bh.b_blocknr >> (PAGE_CACHE_SHIFT - inode->i_blkbits);
fs/ext3/inode.c +3 -10
@@ -788,7 +788,7 @@ err_out:int ext3_get_blocks_handle (handle_t *handle,struct inode *inode,sector_t iblock,unsigned long maxblocks,struct buffer_head *bh_result, -int create,int extend_disksize) +int create) {int err = -EIO ;int offsets[4 ];
@@ -911,13 +911,6 @@ int ext3_get_blocks_handle(handle_t *handle, struct inode *inode,if (!err) err =ext3_splice_branch (handle, inode, iblock, partial, indirect_blks, count); -/* -* i_disksize growing is protected by truncate_mutex. Don't forget to -* protect it if you're about to implement concurrent -* ext3_get_block() -bzzz -*/ -if (!err && extend_disksize && inode->i_size > ei->i_disksize) - ei->i_disksize = inode->i_size;mutex_unlock (&ei->truncate_mutex);if (err) goto cleanup;
@@ -972,7 +965,7 @@ static int ext3_get_block(struct inode *inode, sector_t iblock, } ret =ext3_get_blocks_handle (handle, inode, iblock, - max_blocks, bh_result, create,0 ); + max_blocks, bh_result, create);if (ret >0 ) { bh_result->b_size = (ret << inode->i_blkbits); ret =0 ;
@@ -1005,7 +998,7 @@ struct buffer_head *ext3_getblk(handle_t *handle, struct inode *inode, dummy.b_blocknr =-1000 ;buffer_trace_init (&dummy.b_history); err =ext3_get_blocks_handle (handle, inode, block,1 , - &dummy, create,1 ); + &dummy, create);/* * ext3_get_blocks_handle() returns number of blocks * mapped. 0 in case of a HOLE.
include/linux/ext3_fs.h +1 -1
@@ -874,7 +874,7 @@ 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,sector_t iblock,unsigned long maxblocks,struct buffer_head *bh_result, -int create,int extend_disksize); +int create);extern struct inode *ext3_iget (struct super_block *,unsigned long );extern int ext3_write_inode (struct inode *,int );
Signature · 1 line
1.6.0.2
Jan Kara
reviewerPATCH 2/2 ext4: Get rid of extend_disksize parameter of ext4_get_blocks_handle()
In reply to Jan KaraGet rid of extenddisksize parameter of ext4_get_blocks_handle(). This seems to be a relict from some old days and setting disksize in this function does not make much sence. Currently it was set only by ext4_getblk(). Since the parameter has some effect only if create == 1, it is easy to check that the three callers which end up calling ext4_getblk() with create == 1 (ext4_append, ext4_quota_write, ext4_mkdir) do the right thing and set disksize themselves.
--- fs/ext4/dir.c | 3 +-- fs/ext4/ext4.h | 6 ++---- fs/ext4/extents.c | 16 +++------------- fs/ext4/inode.c | 43 ++++++++++++------------------------------- 4 files changed, 18 insertions(+), 50 deletions(-)
fs/ext4/dir.c +1 -2
@@ -131,8 +131,7 @@ static int ext4_readdir(struct file *filp,struct buffer_head *bh =NULL ; map_bh.b_state =0 ; - err =ext4_get_blocks_wrap (NULL , inode, blk,1 , &map_bh, -0 ,0 ,0 ); + err =ext4_get_blocks_wrap (NULL , inode, blk,1 , &map_bh,0 ,0 );if (err >0 ) {pgoff_t index = map_bh.b_blocknr >> (PAGE_CACHE_SHIFT - inode->i_blkbits);
fs/ext4/ext4.h +2 -4
@@ -1338,8 +1338,7 @@ 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 int max_blocks, -struct buffer_head *bh_result, -int create,int extend_disksize); +struct buffer_head *bh_result,int create);extern void ext4_ext_truncate (struct inode *);extern void ext4_ext_init (struct super_block *);extern void ext4_ext_release (struct super_block *);
@@ -1347,8 +1346,7 @@ 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 int max_blocks, -struct buffer_head *bh,int create, -int extend_disksize,int flag); +struct buffer_head *bh,int create,int flag);extern int ext4_fiemap (struct inode *inode,struct fiemap_extent_info *fieinfo,__u64 start,__u64 len);
fs/ext4/extents.c +3 -13
@@ -2775,9 +2775,8 @@ fix_extent_len:* return < 0, error case. */ int ext4_ext_get_blocks (handle_t *handle,struct inode *inode, -ext4_lblk_t iblock, -unsigned int max_blocks,struct buffer_head *bh_result, -int create,int extend_disksize) +ext4_lblk_t iblock,unsigned int max_blocks, +struct buffer_head *bh_result,int create) {struct ext4_ext_path *path =NULL ;struct ext4_extent_header *eh;
@@ -2786,7 +2785,6 @@ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,int err =0 , depth, ret, cache_type;unsigned int allocated =0 ;struct ext4_allocation_request ar; -loff_t disksize;__clear_bit (BH_New, &bh_result->b_state); ext_debug("blocks %u/%u requested for inode %u\n",
@@ -2974,14 +2972,6 @@ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode, newblock =ext_pblock (&newex); allocated =ext4_ext_get_actual_len (&newex); outnew: -if (extend_disksize) { - disksize = ((loff_t ) iblock + ar.len) << inode->i_blkbits; -if (disksize >i_size_read (inode)) - disksize =i_size_read (inode); -if (disksize >EXT4_I (inode)->i_disksize) -EXT4_I (inode)->i_disksize = disksize; - } -set_buffer_new (bh_result);/* Cache only when it is _not_ an uninitialized extent */
@@ -3143,7 +3133,7 @@ retry: } ret =ext4_get_blocks_wrap (handle, inode, block, max_blocks, &map_bh, -EXT4_CREATE_UNINITIALIZED_EXT ,0 ,0 ); +EXT4_CREATE_UNINITIALIZED_EXT ,0 );if (ret <=0 ) {#ifdef EXT4FS_DEBUG WARN_ON (ret <=0 );
fs/ext4/inode.c +12 -31
121 lines not on this page · raw message
Signature · 1 line
1.6.0.2
Theodore Tso
maintainerRe: [PATCH 2/2] ext4: Get rid of extend_disksize parameter of ext4_get_blocks_handle()
Quoted 3 lines · Jan Kara
Get rid of extenddisksize parameter of
ext4_get_blocks_handle(). This seems to be a relict from some old days and setting disksize in this function does not make much sence. Currently it was set only byext4_getblk(). Since the
s/sence/sense/
Quoted 3 lines
parameter has some effect only if create == 1, it is easy to check that the three callers which end up calling
ext4_getblk()with create == 1 (ext4_append,ext4_quota_write,ext4_mkdir) do the right thing and set disksize themselves.
So this patch doesn't apply any more since I've done my own set of cleanups to the ext4 code base, so extend_disksize is no longer a separate parameter, but a bit flag (and ext4_get_blocks_wrap has been renamed to a more sensible ext4_get_blocks).
More to the point, this removess the code which sets the disksize -- which I agree is funny that it is done in ext4_ext4_get_blocks() and ext4_ind_get_blocks() --- but I don't see anything in your patch which actually sets disksize in ext4_append(), ext4_quota_write(), or ext4_mkdir(). Do none of these actually need disksize to be set? If so, the commit message should explain that.
If not, perhaps it would be better if the update of the disksize field be done in ext4_getblk()?
(And the same question here applies to the ext3 patch; it seems to remove the code which manages the i_disksize without replacing it anywhere that I can see.)
- Ted
Jan Kara
reviewerRe: [PATCH 2/2] ext4: Get rid of extend_disksize parameter of ext4_get_blocks_handle()
Hi,
Quoted 6 lines · Theodore Tso
Quoted 3 lines · Jan Kara
Get rid of extenddisksize parameter of
ext4_get_blocks_handle(). This seems to be a relict from some old days and setting disksize in this function does not make much sence. Currently it was set only byext4_getblk(). Since thes/sence/sense/
Thanks.
Quoted 9 lines
Quoted 3 lines
parameter has some effect only if create == 1, it is easy to check that the three callers which end up calling
ext4_getblk()with create == 1 (ext4_append,ext4_quota_write,ext4_mkdir) do the right thing and set disksize themselves.So this patch doesn't apply any more since I've done my own set of cleanups to the ext4 code base, so
extend_disksizeis no longer a separate parameter, but a bit flag (andext4_get_blocks_wraphas been renamed to a more sensibleext4_get_blocks).
Quoted 6 lines
More to the point, this removess the code which sets the disksize -- which I agree is funny that it is done in
ext4_ext4_get_blocks()andext4_ind_get_blocks()--- but I don't see anything in your patch which actually sets disksize inext4_append(),ext4_quota_write(), orext4_mkdir(). Do none of these actually need disksize to be set? If so, the commit message should explain that.
All these functions already set i_disksize themselves. E.g. ext4_append()
does
bh = ext4_bread(handle, inode, *block, 1, err);
if (bh) {
inode->i_size += inode->i_sb->s_blocksize;
EXT4_I(inode)->i_disksize = inode->i_size;
*err = ext4_journal_get_write_access(handle, bh);...
BTW: I've tried to mention this in the changelog but obviously I've
failed doing it clearly enough ;).
Quoted 2 lines
If not, perhaps it would be better if the update of the disksize field be done in
ext4_getblk()?
I'd keep ext4_getblk() and ext4_bread() just being lowlevel functions
mapping / allocating a block. The caller is responsible for updating i_size and i_disksize if it needs to be changed.
I'll rediff the ext4 patch against your tree and resend it.
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR