All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ext4: remove redundant condition check
@ 2018-11-13 23:24 Chengguang Xu
  2018-11-27  9:43 ` Jan Kara
  0 siblings, 1 reply; 3+ messages in thread
From: Chengguang Xu @ 2018-11-13 23:24 UTC (permalink / raw)
  To: tytso, adilger.kernel; +Cc: linux-ext4, Chengguang Xu

ext4_xattr_destroy_cache() can handle NULL pointer correctly,
so there is no need to check NULL pointer before calling
ext4_xattr_destroy_cache().

Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
---
 fs/ext4/super.c | 29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 53ff6c2a26ed..30d4a4e69de8 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1000,14 +1000,13 @@ static void ext4_put_super(struct super_block *sb)
 		invalidate_bdev(sbi->journal_bdev);
 		ext4_blkdev_remove(sbi);
 	}
-	if (sbi->s_ea_inode_cache) {
-		ext4_xattr_destroy_cache(sbi->s_ea_inode_cache);
-		sbi->s_ea_inode_cache = NULL;
-	}
-	if (sbi->s_ea_block_cache) {
-		ext4_xattr_destroy_cache(sbi->s_ea_block_cache);
-		sbi->s_ea_block_cache = NULL;
-	}
+
+	ext4_xattr_destroy_cache(sbi->s_ea_inode_cache);
+	sbi->s_ea_inode_cache = NULL;
+
+	ext4_xattr_destroy_cache(sbi->s_ea_block_cache);
+	sbi->s_ea_block_cache = NULL;
+
 	if (sbi->s_mmp_tsk)
 		kthread_stop(sbi->s_mmp_tsk);
 	brelse(sbi->s_sbh);
@@ -4522,14 +4521,12 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
 	if (EXT4_SB(sb)->rsv_conversion_wq)
 		destroy_workqueue(EXT4_SB(sb)->rsv_conversion_wq);
 failed_mount_wq:
-	if (sbi->s_ea_inode_cache) {
-		ext4_xattr_destroy_cache(sbi->s_ea_inode_cache);
-		sbi->s_ea_inode_cache = NULL;
-	}
-	if (sbi->s_ea_block_cache) {
-		ext4_xattr_destroy_cache(sbi->s_ea_block_cache);
-		sbi->s_ea_block_cache = NULL;
-	}
+	ext4_xattr_destroy_cache(sbi->s_ea_inode_cache);
+	sbi->s_ea_inode_cache = NULL;
+
+	ext4_xattr_destroy_cache(sbi->s_ea_block_cache);
+	sbi->s_ea_block_cache = NULL;
+
 	if (sbi->s_journal) {
 		jbd2_journal_destroy(sbi->s_journal);
 		sbi->s_journal = NULL;
-- 
2.17.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ext4: remove redundant condition check
  2018-11-13 23:24 [PATCH] ext4: remove redundant condition check Chengguang Xu
@ 2018-11-27  9:43 ` Jan Kara
  2018-12-04  5:25   ` Theodore Y. Ts'o
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kara @ 2018-11-27  9:43 UTC (permalink / raw)
  To: Chengguang Xu; +Cc: tytso, adilger.kernel, linux-ext4

On Wed 14-11-18 07:24:48, Chengguang Xu wrote:
> ext4_xattr_destroy_cache() can handle NULL pointer correctly,
> so there is no need to check NULL pointer before calling
> ext4_xattr_destroy_cache().
> 
> Signed-off-by: Chengguang Xu <cgxu519@gmx.com>

The patch looks good. You can add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/ext4/super.c | 29 +++++++++++++----------------
>  1 file changed, 13 insertions(+), 16 deletions(-)
> 
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index 53ff6c2a26ed..30d4a4e69de8 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -1000,14 +1000,13 @@ static void ext4_put_super(struct super_block *sb)
>  		invalidate_bdev(sbi->journal_bdev);
>  		ext4_blkdev_remove(sbi);
>  	}
> -	if (sbi->s_ea_inode_cache) {
> -		ext4_xattr_destroy_cache(sbi->s_ea_inode_cache);
> -		sbi->s_ea_inode_cache = NULL;
> -	}
> -	if (sbi->s_ea_block_cache) {
> -		ext4_xattr_destroy_cache(sbi->s_ea_block_cache);
> -		sbi->s_ea_block_cache = NULL;
> -	}
> +
> +	ext4_xattr_destroy_cache(sbi->s_ea_inode_cache);
> +	sbi->s_ea_inode_cache = NULL;
> +
> +	ext4_xattr_destroy_cache(sbi->s_ea_block_cache);
> +	sbi->s_ea_block_cache = NULL;
> +
>  	if (sbi->s_mmp_tsk)
>  		kthread_stop(sbi->s_mmp_tsk);
>  	brelse(sbi->s_sbh);
> @@ -4522,14 +4521,12 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
>  	if (EXT4_SB(sb)->rsv_conversion_wq)
>  		destroy_workqueue(EXT4_SB(sb)->rsv_conversion_wq);
>  failed_mount_wq:
> -	if (sbi->s_ea_inode_cache) {
> -		ext4_xattr_destroy_cache(sbi->s_ea_inode_cache);
> -		sbi->s_ea_inode_cache = NULL;
> -	}
> -	if (sbi->s_ea_block_cache) {
> -		ext4_xattr_destroy_cache(sbi->s_ea_block_cache);
> -		sbi->s_ea_block_cache = NULL;
> -	}
> +	ext4_xattr_destroy_cache(sbi->s_ea_inode_cache);
> +	sbi->s_ea_inode_cache = NULL;
> +
> +	ext4_xattr_destroy_cache(sbi->s_ea_block_cache);
> +	sbi->s_ea_block_cache = NULL;
> +
>  	if (sbi->s_journal) {
>  		jbd2_journal_destroy(sbi->s_journal);
>  		sbi->s_journal = NULL;
> -- 
> 2.17.2
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ext4: remove redundant condition check
  2018-11-27  9:43 ` Jan Kara
@ 2018-12-04  5:25   ` Theodore Y. Ts'o
  0 siblings, 0 replies; 3+ messages in thread
From: Theodore Y. Ts'o @ 2018-12-04  5:25 UTC (permalink / raw)
  To: Jan Kara; +Cc: Chengguang Xu, adilger.kernel, linux-ext4

On Tue, Nov 27, 2018 at 10:43:58AM +0100, Jan Kara wrote:
> On Wed 14-11-18 07:24:48, Chengguang Xu wrote:
> > ext4_xattr_destroy_cache() can handle NULL pointer correctly,
> > so there is no need to check NULL pointer before calling
> > ext4_xattr_destroy_cache().
> > 
> > Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
> 
> The patch looks good. You can add:
> 
> Reviewed-by: Jan Kara <jack@suse.cz>

Thanks, applied.

					- Ted

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-12-04  5:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-13 23:24 [PATCH] ext4: remove redundant condition check Chengguang Xu
2018-11-27  9:43 ` Jan Kara
2018-12-04  5:25   ` Theodore Y. Ts'o

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.