From 98783e453c1084527388ec1a7f6367cd6aabbe63 Mon Sep 17 00:00:00 2001 From: Wang Shilong Date: Wed, 6 Feb 2013 14:14:26 +0800 Subject: Ext2: remove the overhead check about sb in the function ext2_new_blocks It can be guranteed that inode->i_sb should not be null in vfs. So here the check about it is overhead. Signed-off-by: Wang Shilong Signed-off-by: Jan Kara --- fs/ext2/balloc.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'fs/ext2/balloc.c') diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c index 2616d0ea5c5c..ea88181932df 100644 --- a/fs/ext2/balloc.c +++ b/fs/ext2/balloc.c @@ -1239,10 +1239,6 @@ ext2_fsblk_t ext2_new_blocks(struct inode *inode, ext2_fsblk_t goal, *errp = -ENOSPC; sb = inode->i_sb; - if (!sb) { - printk("ext2_new_blocks: nonexistent device"); - return 0; - } /* * Check quota for allocation of this block. -- cgit v1.2.3 From 8e3dffc651cb668e1ff4d8b89cc1c3dde7540d3b Mon Sep 17 00:00:00 2001 From: Wang Shilong Date: Thu, 7 Feb 2013 22:57:53 +0800 Subject: Ext2: mark inode dirty after the function dquot_free_block_nodirty is called We should mark inode dirty after the function dquot_free_block_nodirty is called.Besides,add a check whether it is necessary to call dquot_free_block_nodirty functon. Signed-off-by: Wang Shilong Signed-off-by: Jan Kara --- fs/ext2/balloc.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'fs/ext2/balloc.c') diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c index ea88181932df..132da4c0692f 100644 --- a/fs/ext2/balloc.c +++ b/fs/ext2/balloc.c @@ -568,8 +568,11 @@ do_more: } error_return: brelse(bitmap_bh); - release_blocks(sb, freed); - dquot_free_block_nodirty(inode, freed); + if (freed) { + release_blocks(sb, freed); + dquot_free_block_nodirty(inode, freed); + mark_inode_dirty(inode); + } } /** @@ -1412,9 +1415,11 @@ allocated: *errp = 0; brelse(bitmap_bh); - dquot_free_block_nodirty(inode, *count-num); - mark_inode_dirty(inode); - *count = num; + if (num < *count) { + dquot_free_block_nodirty(inode, *count-num); + mark_inode_dirty(inode); + *count = num; + } return ret_block; io_error: -- cgit v1.2.3 From 712ddc52ffa1f5324cd8f682d9e5b047b91f34d3 Mon Sep 17 00:00:00 2001 From: Wang Shilong Date: Thu, 7 Feb 2013 22:57:54 +0800 Subject: Ext2: remove the static function release_blocks to optimize the kernel Because the static function 'release_blocks' is only called when releasing blocks,it will be more simple and efficient to call the function 'percpu_counter_add' directly. Signed-off-by: Wang Shilong Signed-off-by: Jan Kara --- fs/ext2/balloc.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'fs/ext2/balloc.c') diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c index 132da4c0692f..9f9992b37924 100644 --- a/fs/ext2/balloc.c +++ b/fs/ext2/balloc.c @@ -159,15 +159,6 @@ read_block_bitmap(struct super_block *sb, unsigned int block_group) return bh; } -static void release_blocks(struct super_block *sb, int count) -{ - if (count) { - struct ext2_sb_info *sbi = EXT2_SB(sb); - - percpu_counter_add(&sbi->s_freeblocks_counter, count); - } -} - static void group_adjust_blocks(struct super_block *sb, int group_no, struct ext2_group_desc *desc, struct buffer_head *bh, int count) { @@ -569,7 +560,7 @@ do_more: error_return: brelse(bitmap_bh); if (freed) { - release_blocks(sb, freed); + percpu_counter_add(&sbi->s_freeblocks_counter, freed); dquot_free_block_nodirty(inode, freed); mark_inode_dirty(inode); } -- cgit v1.2.3