From c0ed7b51ca9983086e03668f0ca20dc67ac663f4 Mon Sep 17 00:00:00 2001 From: Chengguang Xu Date: Wed, 7 Nov 2018 21:47:04 +0800 Subject: ext2: avoid unnecessary operation in ext2_error() If filesystem has already mounted as read-only, then we don't have to do it again. Signed-off-by: Chengguang Xu Signed-off-by: Jan Kara --- fs/ext2/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fs/ext2') diff --git a/fs/ext2/super.c b/fs/ext2/super.c index cb91baa4275d..5e2861b947a6 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c @@ -73,7 +73,7 @@ void ext2_error(struct super_block *sb, const char *function, if (test_opt(sb, ERRORS_PANIC)) panic("EXT2-fs: panic from previous error\n"); - if (test_opt(sb, ERRORS_RO)) { + if (!sb_rdonly(sb) && test_opt(sb, ERRORS_RO)) { ext2_msg(sb, KERN_CRIT, "error: remounting filesystem read-only"); sb->s_flags |= SB_RDONLY; -- cgit From 569ae9209425560e1a94114231d0782e1cc19df1 Mon Sep 17 00:00:00 2001 From: Chengguang Xu Date: Wed, 14 Nov 2018 07:23:53 +0800 Subject: ext2: remove redundant condition check ext2_xattr_destroy_cache() can handle NULL pointer correctly, so there is no need to check NULL pointer before calling ext2_xattr_destroy_cache(). Signed-off-by: Chengguang Xu Signed-off-by: Jan Kara --- fs/ext2/super.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'fs/ext2') diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 5e2861b947a6..94cd10c463c2 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c @@ -148,10 +148,9 @@ static void ext2_put_super (struct super_block * sb) ext2_quota_off_umount(sb); - if (sbi->s_ea_block_cache) { - ext2_xattr_destroy_cache(sbi->s_ea_block_cache); - sbi->s_ea_block_cache = NULL; - } + ext2_xattr_destroy_cache(sbi->s_ea_block_cache); + sbi->s_ea_block_cache = NULL; + if (!sb_rdonly(sb)) { struct ext2_super_block *es = sbi->s_es; @@ -1197,8 +1196,7 @@ cantfind_ext2: sb->s_id); goto failed_mount; failed_mount3: - if (sbi->s_ea_block_cache) - ext2_xattr_destroy_cache(sbi->s_ea_block_cache); + ext2_xattr_destroy_cache(sbi->s_ea_block_cache); percpu_counter_destroy(&sbi->s_freeblocks_counter); percpu_counter_destroy(&sbi->s_freeinodes_counter); percpu_counter_destroy(&sbi->s_dirs_counter); -- cgit From 3e159b9553e4024cbdaa25bb8059f79f47c26925 Mon Sep 17 00:00:00 2001 From: Chengguang Xu Date: Thu, 15 Nov 2018 14:40:08 +0800 Subject: ext2: change reusable parameter to true when calling mb_cache_entry_create() Reusable parameter of mb_cache_entry_create() is bool type, so it's better to set true instead of 1. Signed-off-by: Chengguang Xu Signed-off-by: Jan Kara --- fs/ext2/xattr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'fs/ext2') diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c index 62d9a659a8ff..67970bfa79fb 100644 --- a/fs/ext2/xattr.c +++ b/fs/ext2/xattr.c @@ -835,7 +835,8 @@ ext2_xattr_cache_insert(struct mb_cache *cache, struct buffer_head *bh) __u32 hash = le32_to_cpu(HDR(bh)->h_hash); int error; - error = mb_cache_entry_create(cache, GFP_NOFS, hash, bh->b_blocknr, 1); + error = mb_cache_entry_create(cache, GFP_NOFS, hash, bh->b_blocknr, + true); if (error) { if (error == -EBUSY) { ea_bdebug(bh, "already in cache (%d cache entries)", -- cgit