Skip to content

Commit

Permalink
f2fs: introduce f2fs_is_readonly() for readability
Browse files Browse the repository at this point in the history
Introduce f2fs_is_readonly() and use it to simplify code.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
  • Loading branch information
Yangtao Li authored and Jaegeuk Kim committed Dec 12, 2022
1 parent e480751 commit ed8ac22
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 5 additions & 0 deletions fs/f2fs/f2fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -4575,6 +4575,11 @@ static inline void f2fs_handle_page_eio(struct f2fs_sb_info *sbi, pgoff_t ofs,
}
}

static inline bool f2fs_is_readonly(struct f2fs_sb_info *sbi)
{
return f2fs_sb_has_readonly(sbi) || f2fs_readonly(sbi->sb);
}

#define EFSBADCRC EBADMSG /* Bad CRC detected */
#define EFSCORRUPTED EUCLEAN /* Filesystem is corrupted */

Expand Down
5 changes: 2 additions & 3 deletions fs/f2fs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -1351,8 +1351,7 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)
return -EINVAL;
}

if ((f2fs_sb_has_readonly(sbi) || f2fs_readonly(sbi->sb)) &&
test_opt(sbi, FLUSH_MERGE)) {
if (f2fs_is_readonly(sbi) && test_opt(sbi, FLUSH_MERGE)) {
f2fs_err(sbi, "FLUSH_MERGE not compatible with readonly mode");
return -EINVAL;
}
Expand Down Expand Up @@ -2083,7 +2082,7 @@ static void default_options(struct f2fs_sb_info *sbi)
set_opt(sbi, MERGE_CHECKPOINT);
F2FS_OPTION(sbi).unusable_cap = 0;
sbi->sb->s_flags |= SB_LAZYTIME;
if (!f2fs_sb_has_readonly(sbi) && !f2fs_readonly(sbi->sb))
if (!f2fs_is_readonly(sbi))
set_opt(sbi, FLUSH_MERGE);
if (f2fs_hw_support_discard(sbi) || f2fs_hw_should_discard(sbi))
set_opt(sbi, DISCARD);
Expand Down

0 comments on commit ed8ac22

Please sign in to comment.