f2fs: introduce mount_errors related api
Commit Message
This patch introduces mount_errors related api and uses it in code.
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
fs/f2fs/data.c | 2 +-
fs/f2fs/f2fs.h | 15 +++++++++++++++
fs/f2fs/node.c | 2 +-
fs/f2fs/super.c | 11 +++++------
4 files changed, 22 insertions(+), 8 deletions(-)
@@ -2809,7 +2809,7 @@ int f2fs_write_single_data_page(struct page *page, int *submitted,
goto redirty_out;
/* keep data pages in remount-ro mode */
- if (F2FS_OPTION(sbi).errors == MOUNT_ERRORS_READONLY)
+ if (mount_errors_readonly(sbi))
goto redirty_out;
goto out;
}
@@ -4456,6 +4456,21 @@ static inline bool f2fs_dev_is_readonly(struct f2fs_sb_info *sbi)
return f2fs_sb_has_readonly(sbi) || f2fs_hw_is_readonly(sbi);
}
+static inline bool mount_errors_readonly(struct f2fs_sb_info *sbi)
+{
+ return F2FS_OPTION(sbi).errors == MOUNT_ERRORS_READONLY;
+}
+
+static inline bool mount_errors_continue(struct f2fs_sb_info *sbi)
+{
+ return F2FS_OPTION(sbi).errors == MOUNT_ERRORS_CONTINUE;
+}
+
+static inline bool mount_errors_panic(struct f2fs_sb_info *sbi)
+{
+ return F2FS_OPTION(sbi).errors == MOUNT_ERRORS_PANIC;
+}
+
static inline bool f2fs_lfs_mode(struct f2fs_sb_info *sbi)
{
return F2FS_OPTION(sbi).fs_mode == FS_MODE_LFS;
@@ -1597,7 +1597,7 @@ static int __write_node_page(struct page *page, bool atomic, bool *submitted,
if (unlikely(f2fs_cp_error(sbi))) {
/* keep node pages in remount-ro mode */
- if (F2FS_OPTION(sbi).errors == MOUNT_ERRORS_READONLY)
+ if (mount_errors_readonly(sbi))
goto redirty_out;
ClearPageUptodate(page);
dec_page_count(sbi, F2FS_DIRTY_NODES);
@@ -2076,11 +2076,11 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)
else if (F2FS_OPTION(sbi).memory_mode == MEMORY_MODE_LOW)
seq_printf(seq, ",memory=%s", "low");
- if (F2FS_OPTION(sbi).errors == MOUNT_ERRORS_READONLY)
+ if (mount_errors_readonly(sbi))
seq_printf(seq, ",errors=%s", "remount-ro");
- else if (F2FS_OPTION(sbi).errors == MOUNT_ERRORS_CONTINUE)
+ else if (mount_errors_continue(sbi))
seq_printf(seq, ",errors=%s", "continue");
- else if (F2FS_OPTION(sbi).errors == MOUNT_ERRORS_PANIC)
+ else if (mount_errors_panic(sbi))
seq_printf(seq, ",errors=%s", "panic");
return 0;
@@ -4049,8 +4049,7 @@ void f2fs_handle_critical_error(struct f2fs_sb_info *sbi, unsigned char reason,
{
struct super_block *sb = sbi->sb;
bool shutdown = reason == STOP_CP_REASON_SHUTDOWN;
- bool continue_fs = !shutdown &&
- F2FS_OPTION(sbi).errors == MOUNT_ERRORS_CONTINUE;
+ bool continue_fs = !shutdown && mount_errors_continue(sbi);
set_ckpt_flags(sbi, CP_ERROR_FLAG);
@@ -4068,7 +4067,7 @@ void f2fs_handle_critical_error(struct f2fs_sb_info *sbi, unsigned char reason,
* could panic during 'reboot -f' as the underlying device got already
* disabled.
*/
- if (F2FS_OPTION(sbi).errors == MOUNT_ERRORS_PANIC &&
+ if (mount_errors_panic(sbi) &&
!shutdown && !system_going_down() &&
!is_sbi_flag_set(sbi, SBI_IS_SHUTDOWN))
panic("F2FS-fs (device %s): panic forced after error\n",