f2fs: support errors=remount-ro|continue|panic mountoption
Subsystems (2)
Chao Yu
maintainerPATCH v9 1/1 f2fs: support errors=remount-ro|continue|panic mountoption
This patch supports errors=remount-ro|continue|panic mount option, by default it uses "continue" mode.
Signed-off-by Yangtao Li <[email protected]>
Signed-off-by Chao Yu <[email protected]>
---
v9:
- use continue mode by default.
Documentation/filesystems/f2fs.rst | 5 ++ fs/f2fs/checkpoint.c | 7 +- fs/f2fs/f2fs.h | 20 ++++- fs/f2fs/file.c | 5 -- fs/f2fs/gc.c | 2 +- fs/f2fs/super.c | 134 ++++++++++++++++++++++++++--- 6 files changed, 149 insertions(+), 24 deletions(-)
Documentation/filesystems/f2fs.rst +5 -0
@@ -351,6 +351,11 @@ age_extent_cache Enable an age extent cache based on rb-tree. It records data block update frequency of the extent per inode, in order to provide better temperature hints for data block allocation. +errors=%s Specify f2fs behavior on critical errors. This supports modes: + "panic", "continue" and "remount-ro", respectively, trigger + panic immediately, continue without doing anything, and remount + the partition in read-only mode. By default it uses "continue" + mode. ======================== ============================================================ Debugfs Entries
fs/f2fs/checkpoint.c +2 -5
@@ -30,12 +30,9 @@ void f2fs_stop_checkpoint(struct f2fs_sb_info *sbi, bool end_io, unsigned char reason) {f2fs_build_fault_attr (sbi,0 ,0 ); -set_ckpt_flags (sbi,CP_ERROR_FLAG ); -if (!end_io) { +if (!end_io)f2fs_flush_merged_writes (sbi); - -f2fs_handle_stop (sbi, reason); - } +f2fs_handle_critical_error (sbi, reason, end_io); }/*
fs/f2fs/f2fs.h +17 -3
@@ -162,6 +162,7 @@ struct f2fs_mount_info {int fs_mode;/* fs mode: LFS or ADAPTIVE */ int bggc_mode;/* bggc mode: off, on or sync */ int memory_mode;/* memory mode */ +int errors;/* errors parameter */ int discard_unit;/* * discard command's offset/size should * be aligned to this unit: block,
@@ -1370,6 +1371,12 @@ enum { MEMORY_MODE_LOW, /* memory mode for low memry devices */ }; +enum errors_option { +MOUNT_ERRORS_READONLY ,/* remount fs ro on errors */ +MOUNT_ERRORS_CONTINUE ,/* continue on errors */ +MOUNT_ERRORS_PANIC ,/* panic on errors */ +}; +static inline int f2fs_test_bit (unsigned int nr,char *addr);static inline void f2fs_set_bit (unsigned int nr,char *addr);static inline void f2fs_clear_bit (unsigned int nr,char *addr);
@@ -1722,8 +1729,14 @@ struct f2fs_sb_info {struct workqueue_struct *post_read_wq;/* post read workqueue */ -unsigned char errors[MAX_F2FS_ERRORS ];/* error flags */ -spinlock_t error_lock;/* protect errors array */ +/* +* If we are in irq context, let's update error information into +* on-disk superblock in the work. +*/ +struct work_struct s_error_work; +unsigned char errors[MAX_F2FS_ERRORS ];/* error flags */ +unsigned char stop_reason[MAX_STOP_REASON ];/* stop reason */ +spinlock_t error_lock;/* protect errors/stop_reason array */ bool error_dirty;/* errors of sb is dirty */ struct kmem_cache *inline_xattr_slab;/* inline xattr entry */
@@ -3529,8 +3542,9 @@ int f2fs_enable_quota_files(struct f2fs_sb_info *sbi, bool rdonly);int f2fs_quota_sync (struct super_block *sb,int type);loff_t max_file_blocks (struct inode *inode);void f2fs_quota_off_umount (struct super_block *sb); -void f2fs_handle_stop (struct f2fs_sb_info *sbi,unsigned char reason);void f2fs_save_errors (struct f2fs_sb_info *sbi,unsigned char flag); +void f2fs_handle_critical_error (struct f2fs_sb_info *sbi,unsigned char reason, +bool irq_context);void f2fs_handle_error (struct f2fs_sb_info *sbi,unsigned char error);int f2fs_commit_super (struct f2fs_sb_info *sbi,bool recover);int f2fs_sync_fs (struct super_block *sb,int sync);
fs/f2fs/file.c +0 -5
@@ -2225,7 +2225,6 @@ static int f2fs_ioc_shutdown(struct file *filp, unsigned long arg) ret =0 ;f2fs_stop_checkpoint (sbi, false,STOP_CP_REASON_SHUTDOWN ); -set_sbi_flag (sbi,SBI_IS_SHUTDOWN );trace_f2fs_shutdown (sbi, in, ret); }return ret;
@@ -2238,7 +2237,6 @@ static int f2fs_ioc_shutdown(struct file *filp, unsigned long arg)if (ret) goto out;f2fs_stop_checkpoint (sbi, false,STOP_CP_REASON_SHUTDOWN ); -set_sbi_flag (sbi,SBI_IS_SHUTDOWN );thaw_bdev (sb->s_bdev);break ;case F2FS_GOING_DOWN_METASYNC :
@@ -2247,16 +2245,13 @@ static int f2fs_ioc_shutdown(struct file *filp, unsigned long arg)if (ret) goto out;f2fs_stop_checkpoint (sbi, false,STOP_CP_REASON_SHUTDOWN ); -set_sbi_flag (sbi,SBI_IS_SHUTDOWN );break ;case F2FS_GOING_DOWN_NOSYNC :f2fs_stop_checkpoint (sbi, false,STOP_CP_REASON_SHUTDOWN ); -set_sbi_flag (sbi,SBI_IS_SHUTDOWN );break ;case F2FS_GOING_DOWN_METAFLUSH :f2fs_sync_meta_pages (sbi,META ,LONG_MAX ,FS_META_IO );f2fs_stop_checkpoint (sbi, false,STOP_CP_REASON_SHUTDOWN ); -set_sbi_flag (sbi,SBI_IS_SHUTDOWN );break ;case F2FS_GOING_DOWN_NEED_FSCK :set_sbi_flag (sbi,SBI_NEED_FSCK );
fs/f2fs/gc.c +1 -1
@@ -59,7 +59,7 @@ static int gc_thread_func(void *data)if (gc_th->gc_wake) gc_th->gc_wake = false; -if (try_to_freeze ()) { +if (try_to_freeze () ||f2fs_readonly (sbi->sb)) {stat_other_skip_bggc_count (sbi);continue ; }
fs/f2fs/super.c +124 -10
230 lines not on this page · raw message
Signature · 1 line
2.25.1