lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Date:   Wed, 26 Apr 2023 02:02:43 +0800
From:   Yangtao Li <frank.li@...o.com>
To:     Jaegeuk Kim <jaegeuk@...nel.org>, Chao Yu <chao@...nel.org>
Cc:     Yangtao Li <frank.li@...o.com>,
        linux-f2fs-devel@...ts.sourceforge.net,
        linux-kernel@...r.kernel.org
Subject: [PATCH] f2fs: introduce mount_errors related api

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

Signed-off-by: Yangtao Li <frank.li@...o.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(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index f26eac327d6e..475635c0a905 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -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;
 	}
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 7afc9aef127a..d75f58851b58 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -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;
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 834c6f099c95..168dbd884631 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -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);
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 51812f459581..107585797ffa 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -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",
-- 
2.39.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ