Skip to contentSkip to conversation

f2fs: introduce mount_errors related api

PATCH New Yangtao Li 1 participant 1 message Apr 25, 2023 F2FS file system

lore
Share & tools
lore

Yangtao Li

author
#0 lore raw

PATCH 1/1 f2fs: introduce mount_errors related api

This patch introduces mount_errors related api and uses it in code.

---
 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(-)
fs/f2fs/data.c +1 -1
index f26eac327d6e..475635c0a905 100644
@@ -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;
 	}
fs/f2fs/f2fs.h +15 -0
index 7afc9aef127a..d75f58851b58 100644
@@ -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;
fs/f2fs/node.c +1 -1
index 834c6f099c95..168dbd884631 100644
@@ -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);
fs/f2fs/super.c +5 -6
index 51812f459581..107585797ffa 100644
@@ -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",
Signature · 8 lines
2.39.0



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel