ext4: remove unsafe and unnecessary memset()
PATCH 1/4 ext4: remove unsafe and unnecessary memset()
We memset this page before checking whether it's valid. But we need not memset zeroed page at all.
--- fs/ext4/super.c | 1 - 1 file changed, 1 deletion(-)
fs/ext4/super.c +0 -1
@@ -3206,7 +3206,6 @@ int ext4_calculate_overhead(struct super_block *sb)ext4_fsblk_t overhead =0 ;char *buf = (char *)get_zeroed_page (GFP_KERNEL ); -memset (buf,0 ,PAGE_SIZE );if (!buf)return -ENOMEM ;
Signature · 1 line
1.7.9.5
PATCH 2/4 ext4: use sync_inode_metadata() when sync inode metadata
We have a dedicated interface to sync inode metadata.
--- fs/ext4/fsync.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
fs/ext4/fsync.c +1 -5
@@ -44,7 +44,6 @@*/ static int ext4_sync_parent (struct inode *inode) { -struct writeback_control wbc;struct dentry *dentry =NULL ;struct inode *next;int ret =0 ;
@@ -66,10 +65,7 @@ static int ext4_sync_parent(struct inode *inode) ret =sync_mapping_buffers (inode->i_mapping);if (ret)break ; -memset (&wbc,0 ,sizeof (wbc)); - wbc.sync_mode =WB_SYNC_ALL ; - wbc.nr_to_write =0 ;/* only write out the inode */ - ret =sync_inode (inode, &wbc); + ret =sync_inode_metadata (inode,1 );if (ret)break ; }
Signature · 1 line
1.7.9.5
Re: [PATCH 2/4] ext4: use sync_inode_metadata() when sync inode metadata
Quoted 28 lines · Guo Chao
Date: Fri, 30 Nov 2012 14:41:44 +0800
From: Guo Chao <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: [PATCH 2/4] ext4: usesync_inode_metadata()when sync inode metadataWe have a dedicated interface to sync inode metadata.
Signed-off-by Guo Chao <[email protected]>--- fs/ext4/fsync.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)fs/ext4/fsync.c +0
-1@@ -44,7 +44,6 @@*/ static int ext4_sync_parent (struct inode *inode) { -struct writeback_control wbc;struct dentry *dentry =NULL ;struct inode *next;int ret =0 ;@@ -66,10 +65,7 @@ static int ext4_sync_parent(struct inode *inode) ret =sync_mapping_buffers (inode->i_mapping);
fs/ext4/fsync.c static int ext4_sync_parent(struct inode *inode) · line 71
Quoted 10 lines
fs/ext4/fsync.c +1
-4if (ret)break ; -memset (&wbc,0 ,sizeof (wbc)); - wbc.sync_mode =WB_SYNC_ALL ; - wbc.nr_to_write =0 ;/* only write out the inode */ - ret =sync_inode (inode, &wbc); + ret =sync_inode_metadata (inode,1 );if (ret)break ; }
Makes sense.
Re: [PATCH 2/4] ext4: use sync_inode_metadata() when sync inode metadata
In reply to Guo ChaoQuoted 3 lines · Guo Chao
We have a dedicated interface to sync inode metadata.
Signed-off-by Guo Chao <[email protected]>
Thanks, applied.
- Ted
PATCH 3/4 ext4: remove redundant code in ext4_alloc_inode()
In reply to Guo Chaoinode_init_always() will initialize inode->i_data.writeback_index anyway, no need to do this in ext4_alloc_inode().
--- fs/ext4/super.c | 1 - 1 file changed, 1 deletion(-)
fs/ext4/super.c +0 -1
@@ -940,7 +940,6 @@ static struct inode *ext4_alloc_inode(struct super_block *sb)return NULL ; ei->vfs_inode.i_version =1 ; - ei->vfs_inode.i_data.writeback_index =0 ;memset (&ei->i_cached_extent,0 ,sizeof (struct ext4_ext_cache ));INIT_LIST_HEAD (&ei->i_prealloc_list);spin_lock_init (&ei->i_prealloc_lock);
Signature · 1 line
1.7.9.5
Re: [PATCH 3/4] ext4: remove redundant code in ext4_alloc_inode()
Quoted 20 lines · Guo Chao
Date: Fri, 30 Nov 2012 14:41:45 +0800
From: Guo Chao <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: [PATCH 3/4] ext4: remove redundant code inext4_alloc_inode()
inode_init_always()will initializeinode->i_data.writeback_indexanyway, no need to do this inext4_alloc_inode().Signed-off-by Guo Chao <[email protected]>--- fs/ext4/super.c | 1 - 1 file changed, 1 deletion(-)fs/ext4/super.c +0
-0
fs/ext4/super.c static struct inode *ext4_alloc_inode(struct super_block *sb) · line 945
Quoted 7 lines
fs/ext4/super.c +0
-1@@ -940,7 +940,6 @@ static struct inode *ext4_alloc_inode(struct super_block *sb)return NULL ; ei->vfs_inode.i_version =1 ; - ei->vfs_inode.i_data.writeback_index =0 ;memset (&ei->i_cached_extent,0 ,sizeof (struct ext4_ext_cache ));INIT_LIST_HEAD (&ei->i_prealloc_list);spin_lock_init (&ei->i_prealloc_lock);
Looks good
Re: [PATCH 3/4] ext4: remove redundant code in ext4_alloc_inode()
In reply to Guo ChaoQuoted 4 lines · Guo Chao
inode_init_always()will initializeinode->i_data.writeback_indexanyway, no need to do this inext4_alloc_inode().Signed-off-by Guo Chao <[email protected]>
Thanks, applied.
- Ted
PATCH 4/4 ext4: remove redundant initialization in ext4_fill_super()
In reply to Guo ChaoWe use kzalloc() to allocate sbi, no need to zero its field.
--- fs/ext4/super.c | 1 - 1 file changed, 1 deletion(-)
fs/ext4/super.c +0 -1
@@ -3799,7 +3799,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)INIT_LIST_HEAD (&sbi->s_orphan);/* unlinked but open files */ mutex_init (&sbi->s_orphan_lock); - sbi->s_resize_flags =0 ; sb->s_root =NULL ;
Signature · 1 line
1.7.9.5
Re: [PATCH 4/4] ext4: remove redundant initialization in ext4_fill_super()
Quoted 20 lines · Guo Chao
Date: Fri, 30 Nov 2012 14:41:46 +0800
From: Guo Chao <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: [PATCH 4/4] ext4: remove redundant initialization inext4_fill_super()We use
kzalloc()to allocate sbi, no need to zero its field.Signed-off-by Guo Chao <[email protected]>--- fs/ext4/super.c | 1 - 1 file changed, 1 deletion(-)fs/ext4/super.c +0
-0
fs/ext4/super.c static int ext4_fill_super(struct super_block *sb, void *data, int silent) · line 3804
Quoted 7 lines
fs/ext4/super.c +0
-1@@ -3799,7 +3799,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)INIT_LIST_HEAD (&sbi->s_orphan);/* unlinked but open files */ mutex_init (&sbi->s_orphan_lock); - sbi->s_resize_flags =0 ; sb->s_root =NULL ;
There are other members of sbi which we initialize to zero even though we use kzalloc.
Thanks!
-Lukas
Re: [PATCH 4/4] ext4: remove redundant initialization in ext4_fill_super()
In reply to Guo ChaoQuoted 3 lines · Guo Chao
We use
kzalloc()to allocate sbi, no need to zero its field.Signed-off-by Guo Chao <[email protected]>
Thanks, applied.
- Ted
Quoted 19 lines · Guo Chao
Date: Fri, 30 Nov 2012 14:41:43 +0800
From: Guo Chao <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: [PATCH 1/4] ext4: remove unsafe and unnecessarymemset()We memset this page before checking whether it's valid. But we need not memset zeroed page at all.
Signed-off-by Guo Chao <[email protected]>--- fs/ext4/super.c | 1 - 1 file changed, 1 deletion(-)fs/ext4/super.c +0
-0
fs/ext4/super.c int ext4_calculate_overhead(struct super_block *sb) · line 3210
Quoted 6 lines
fs/ext4/super.c +0
-1@@ -3206,7 +3206,6 @@ int ext4_calculate_overhead(struct super_block *sb)ext4_fsblk_t overhead =0 ;char *buf = (char *)get_zeroed_page (GFP_KERNEL ); -memset (buf,0 ,PAGE_SIZE );if (!buf)return -ENOMEM ;
Good catch, thanks!
Quoted 30 lines · Lukáš Czerner
Date: Fri, 30 Nov 2012 14:20:42 +0100 (CET)
From: Lukáš Czerner <[email protected]>
To: Guo Chao <[email protected]>
Cc: [email protected], [email protected]
Subject: Re: [PATCH 1/4] ext4: remove unsafe and unnecessarymemset()Quoted 22 lines · Guo Chao
Date: Fri, 30 Nov 2012 14:41:43 +0800
From: Guo Chao <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: [PATCH 1/4] ext4: remove unsafe and unnecessarymemset()We memset this page before checking whether it's valid. But we need not memset zeroed page at all.
Signed-off-by Guo Chao <[email protected]>--- fs/ext4/super.c | 1 - 1 file changed, 1 deletion(-)fs/ext4/super.c +0
-0@@ -3206,7 +3206,6 @@ int ext4_calculate_overhead(struct super_block *sb)ext4_fsblk_t overhead =0 ;char *buf = (char *)get_zeroed_page (GFP_KERNEL );
Quoted 7 lines
fs/ext4/super.c int ext4_calculate_overhead(struct super_block *sb) · line 3210
Quoted 3 lines
fs/ext4/super.c +0
-1-memset (buf,0 ,PAGE_SIZE );if (!buf)return -ENOMEM ;Good catch, thanks!
Reviewed-by Lukas Czerner <[email protected]>
It looks like that it has been already fixed with a different patch.
http://www.spinics.net/lists/linux-ext4/msg35310.html
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 5 lines · Lukáš Czerner
On Fri, 30 Nov 2012, Lukáš Czerner wrote:
It looks like that it has been already fixed with a different patch.
Hmm ... I did search this function in marc.info. Looks like I should switch to another database. Thank you for review.
Thanks,
Guo Chao
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html