Skip to content

Commit ed8ac22

Browse files
bbkzzJaegeuk Kim
authored andcommitted
f2fs: introduce f2fs_is_readonly() for readability
Introduce f2fs_is_readonly() and use it to simplify code. Signed-off-by: Yangtao Li <[email protected]> Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent e480751 commit ed8ac22

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

fs/f2fs/f2fs.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4575,6 +4575,11 @@ static inline void f2fs_handle_page_eio(struct f2fs_sb_info *sbi, pgoff_t ofs,
45754575
}
45764576
}
45774577

4578+
static inline bool f2fs_is_readonly(struct f2fs_sb_info *sbi)
4579+
{
4580+
return f2fs_sb_has_readonly(sbi) || f2fs_readonly(sbi->sb);
4581+
}
4582+
45784583
#define EFSBADCRC EBADMSG /* Bad CRC detected */
45794584
#define EFSCORRUPTED EUCLEAN /* Filesystem is corrupted */
45804585

fs/f2fs/super.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,8 +1351,7 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)
13511351
return -EINVAL;
13521352
}
13531353

1354-
if ((f2fs_sb_has_readonly(sbi) || f2fs_readonly(sbi->sb)) &&
1355-
test_opt(sbi, FLUSH_MERGE)) {
1354+
if (f2fs_is_readonly(sbi) && test_opt(sbi, FLUSH_MERGE)) {
13561355
f2fs_err(sbi, "FLUSH_MERGE not compatible with readonly mode");
13571356
return -EINVAL;
13581357
}
@@ -2083,7 +2082,7 @@ static void default_options(struct f2fs_sb_info *sbi)
20832082
set_opt(sbi, MERGE_CHECKPOINT);
20842083
F2FS_OPTION(sbi).unusable_cap = 0;
20852084
sbi->sb->s_flags |= SB_LAZYTIME;
2086-
if (!f2fs_sb_has_readonly(sbi) && !f2fs_readonly(sbi->sb))
2085+
if (!f2fs_is_readonly(sbi))
20872086
set_opt(sbi, FLUSH_MERGE);
20882087
if (f2fs_hw_support_discard(sbi) || f2fs_hw_should_discard(sbi))
20892088
set_opt(sbi, DISCARD);

0 commit comments

Comments
 (0)