f2fs: support errors=remount-ro|continue|panic mountoption
Subsystems (2)
Chao Yu
maintainerPATCH v10 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.
---
v10:
- add description of error mode in f2fs.rst
- keep pending node/non-dir pages in remount-ro mode
Documentation/filesystems/f2fs.rst | 13 +++ fs/f2fs/checkpoint.c | 7 +- fs/f2fs/data.c | 4 + fs/f2fs/f2fs.h | 20 ++++- fs/f2fs/file.c | 5 -- fs/f2fs/gc.c | 2 +- fs/f2fs/node.c | 3 + fs/f2fs/super.c | 134 ++++++++++++++++++++++++++--- 8 files changed, 164 insertions(+), 24 deletions(-)
Documentation/filesystems/f2fs.rst +13 -0
@@ -351,6 +351,19 @@ 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. + continue remount-ro panic + access ops normal noraml N/A + syscall errors -EIO -EROFS N/A + mount option rw ro N/A + pending dir write keep keep N/A + pending non-dir write drop keep N/A + pending node write drop keep N/A + pending meta write keep keep N/A ======================== ============================================================ 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/data.c +4 -0
@@ -2807,6 +2807,10 @@ int f2fs_write_single_data_page(struct page *page, int *submitted,if (S_ISDIR (inode->i_mode) && !is_sbi_flag_set (sbi,SBI_IS_CLOSE )) goto redirty_out; + +/* keep data pages in remount-ro mode */ +if (F2FS_OPTION (sbi).errors ==MOUNT_ERRORS_READONLY ) + goto redirty_out; goto out; }
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);
@@ -1721,8 +1728,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 */
@@ -3541,8 +3554,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/node.c +3 -0
@@ -1596,6 +1596,9 @@ static int __write_node_page(struct page *page, bool atomic, bool *submitted,trace_f2fs_writepage (page,NODE );if (unlikely (f2fs_cp_error (sbi))) { +/* keep node pages in remount-ro mode */ +if (F2FS_OPTION (sbi).errors ==MOUNT_ERRORS_READONLY ) + goto redirty_out;ClearPageUptodate (page);dec_page_count (sbi,F2FS_DIRTY_NODES );unlock_page (page);
fs/f2fs/super.c +124 -10
230 lines not on this page · raw message
Signature · 1 line
2.36.1
kernel test robot
build botkernel test robot noticed the following build warnings:
Hi Chao,
kernel test robot noticed the following build warnings:
[auto build test WARNING on jaegeuk-f2fs/dev-test]
[also build test WARNING on jaegeuk-f2fs/dev next-20230421] [cannot apply to linus/master v6.3-rc7]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Chao-Yu/f2fs-support-errors-remount-ro-continue-panic-mountoption/20230422-200811 base: https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev-test patch link: https://lore.kernel.org/r/20230422120754.97345-1-chao%40kernel.org patch subject: [PATCH v10] f2fs: support errors=remount-ro|continue|panic mountoption reproduce: # https://github.com/intel-lab-lkp/linux/commit/e9d2110ffe178cd6c5499b8f126190d25f2061a0 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Chao-Yu/f2fs-support-errors-remount-ro-continue-panic-mountoption/20230422-200811 git checkout e9d2110ffe178cd6c5499b8f126190d25f2061a0 make menuconfig # enable CONFIG_COMPILE_TEST, CONFIG_WARN_MISSING_DOCUMENTS, CONFIG_WARN_ABI_ERRORS make htmldocs
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> Documentation/filesystems/f2fs.rst:359: WARNING: Unexpected indentation.
vim +359 Documentation/filesystems/f2fs.rst
106
107
108 ======================== ============================================================
109 background_gc=%s Turn on/off cleaning operations, namely garbage
110 collection, triggered in background when I/O subsystem is
111 idle. If background_gc=on, it will turn on the garbage
112 collection and if background_gc=off, garbage collection
113 will be turned off. If background_gc=sync, it will turn
114 on synchronous garbage collection running in background.
115 Default value for this option is on. So garbage
116 collection is on by default.
117 gc_merge When background_gc is on, this option can be enabled to
118 let background GC thread to handle foreground GC requests,
119 it can eliminate the sluggish issue caused by slow foreground
120 GC operation when GC is triggered from a process with limited
121 I/O and CPU resources.
122 nogc_merge Disable GC merge feature.
123 disable_roll_forward Disable the roll-forward recovery routine
124 norecovery Disable the roll-forward recovery routine, mounted read-
125 only (i.e., -o ro,disable_roll_forward)
126 discard/nodiscard Enable/disable real-time discard in f2fs, if discard is
127 enabled, f2fs will issue discard/TRIM commands when a
128 segment is cleaned.
129 no_heap Disable heap-style segment allocation which finds free
130 segments for data from the beginning of main area, while
131 for node from the end of main area.
132 nouser_xattr Disable Extended User Attributes. Note: xattr is enabled
133 by default if CONFIG_F2FS_FS_XATTR is selected.
134 noacl Disable POSIX Access Control List. Note: acl is enabled
135 by default if CONFIG_F2FS_FS_POSIX_ACL is selected.
136 active_logs=%u Support configuring the number of active logs. In the
137 current design, f2fs supports only 2, 4, and 6 logs.
138 Default number is 6.
139 disable_ext_identify Disable the extension list configured by mkfs, so f2fs
140 is not aware of cold files such as media files.
141 inline_xattr Enable the inline xattrs feature.
142 noinline_xattr Disable the inline xattrs feature.
143 inline_xattr_size=%u Support configuring inline xattr size, it depends on
144 flexible inline xattr feature.
145 inline_data Enable the inline data feature: Newly created small (<~3.4k)
146 files can be written into inode block.
147 inline_dentry Enable the inline dir feature: data in newly created
148 directory entries can be written into inode block. The
149 space of inode block which is used to store inline
150 dentries is limited to ~3.4k.
151 noinline_dentry Disable the inline dentry feature.
152 flush_merge Merge concurrent cache_flush commands as much as possible
153 to eliminate redundant command issues. If the underlying
154 device handles the cache_flush command relatively slowly,
155 recommend to enable this option.
156 nobarrier This option can be used if underlying storage guarantees
157 its cached data should be written to the novolatile area.
158 If this option is set, no cache_flush commands are issued
159 but f2fs still guarantees the write ordering of all the
160 data writes.
161 barrier If this option is set, cache_flush commands are allowed to be
162 issued.
163 fastboot This option is used when a system wants to reduce mount
164 time as much as possible, even though normal performance
165 can be sacrificed.
166 extent_cache Enable an extent cache based on rb-tree, it can cache
167 as many as extent which map between contiguous logical
168 address and physical address per inode, resulting in
169 increasing the cache hit ratio. Set by default.
170 noextent_cache Disable an extent cache based on rb-tree explicitly, see
171 the above extent_cache mount option.
172 noinline_data Disable the inline data feature, inline data feature is
173 enabled by default.
174 data_flush Enable data flushing before checkpoint in order to
175 persist data of regular and symlink.
176 reserve_root=%d Support configuring reserved space which is used for
177 allocation from a privileged user with specified uid or
178 gid, unit: 4KB, the default limit is 0.2% of user blocks.
179 resuid=%d The user ID which may use the reserved blocks.
180 resgid=%d The group ID which may use the reserved blocks.
181 fault_injection=%d Enable fault injection in all supported types with
182 specified injection rate.
183 fault_type=%d Support configuring fault injection type, should be
184 enabled with fault_injection option, fault type value
185 is shown below, it supports single or combined type.
186
187 =================== ===========
188 Type_Name Type_Value
189 =================== ===========
190 FAULT_KMALLOC 0x000000001
191 FAULT_KVMALLOC 0x000000002
192 FAULT_PAGE_ALLOC 0x000000004
193 FAULT_PAGE_GET 0x000000008 194 FAULT_ALLOC_BIO 0x000000010 (obsolete) 195 FAULT_ALLOC_NID 0x000000020 196 FAULT_ORPHAN 0x000000040 197 FAULT_BLOCK 0x000000080 198 FAULT_DIR_DEPTH 0x000000100 199 FAULT_EVICT_INODE 0x000000200 200 FAULT_TRUNCATE 0x000000400 201 FAULT_READ_IO 0x000000800 202 FAULT_CHECKPOINT 0x000001000 203 FAULT_DISCARD 0x000002000 204 FAULT_WRITE_IO 0x000004000 205 FAULT_SLAB_ALLOC 0x000008000 206 FAULT_DQUOT_INIT 0x000010000 207 FAULT_LOCK_OP 0x000020000 208 FAULT_BLKADDR 0x000040000 209 =================== =========== 210 mode=%s Control block allocation mode which supports "adaptive" 211 and "lfs". In "lfs" mode, there should be no random 212 writes towards main area. 213 "fragment:segment" and "fragment:block" are newly added here. 214 These are developer options for experiments to simulate filesystem 215 fragmentation/after-GC situation itself. The developers use these 216 modes to understand filesystem fragmentation/after-GC condition well, 217 and eventually get some insights to handle them better. 218 In "fragment:segment", f2fs allocates a new segment in ramdom 219 position. With this, we can simulate the after-GC condition. 220 In "fragment:block", we can scatter block allocation with 221 "max_fragment_chunk" and "max_fragment_hole" sysfs nodes. 222 We added some randomness to both chunk and hole size to make 223 it close to realistic IO pattern. So, in this mode, f2fs will allocate 224 1..<max_fragment_chunk> blocks in a chunk and make a hole in the 225 length of 1..<max_fragment_hole> by turns. With this, the newly 226 allocated blocks will be scattered throughout the whole partition. 227 Note that "fragment:block" implicitly enables "fragment:segment" 228 option for more randomness. 229 Please, use these options for your experiments and we strongly 230 recommend to re-format the filesystem after using these options. 231 io_bits=%u Set the bit size of write IO requests. It should be set 232 with "mode=lfs". 233 usrquota Enable plain user disk quota accounting. 234 grpquota Enable plain group disk quota accounting. 235 prjquota Enable plain project quota accounting. 236 usrjquota=<file> Appoint specified file and type during mount, so that quota 237 grpjquota=<file> information can be properly updated during recovery flow, 238 prjjquota=<file> <quota file>: must be in root directory; 239 jqfmt=<quota type> <quota type>: [vfsold,vfsv0,vfsv1]. 240 offusrjquota Turn off user journalled quota. 241 offgrpjquota Turn off group journalled quota. 242 offprjjquota Turn off project journalled quota. 243 quota Enable plain user disk quota accounting. 244 noquota Disable all plain disk quota option. 245 alloc_mode=%s Adjust block allocation policy, which supports "reuse" 246 and "default". 247 fsync_mode=%s Control the policy of fsync. Currently supports "posix", 248 "strict", and "nobarrier". In "posix" mode, which is 249 default, fsync will follow POSIX semantics and does a 250 light operation to improve the filesystem performance. 251 In "strict" mode, fsync will be heavy and behaves in line 252 with xfs, ext4 and btrfs, where xfstest generic/342 will 253 pass, but the performance will regress. "nobarrier" is 254 based on "posix", but doesn't issue flush command for 255 non-atomic files likewise "nobarrier" mount option. 256 test_dummy_encryption 257 test_dummy_encryption=%s 258 Enable dummy encryption, which provides a fake fscrypt 259 context. The fake fscrypt context is used by xfstests. 260 The argument may be either "v1" or "v2", in order to 261 select the corresponding fscrypt policy version. 262 checkpoint=%s[:%u[%]] Set to "disable" to turn off checkpointing. Set to "enable" 263 to reenable checkpointing. Is enabled by default. While 264 disabled, any unmounting or unexpected shutdowns will cause 265 the filesystem contents to appear as they did when the 266 filesystem was mounted with that option. 267 While mounting with checkpoint=disable, the filesystem must 268 run garbage collection to ensure that all available space can 269 be used. If this takes too much time, the mount may return 270 EAGAIN. You may optionally add a value to indicate how much 271 of the disk you would be willing to temporarily give up to 272 avoid additional garbage collection. This can be given as a 273 number of blocks, or as a percent. For instance, mounting 274 with checkpoint=disable:100% would always succeed, but it may 275 hide up to all remaining free space. The actual space that 276 would be unusable can be viewed at /sys/fs/f2fs/<disk>/unusable 277 This space is reclaimed once checkpoint=enable. 278 checkpoint_merge When checkpoint is enabled, this can be used to create a kernel 279 daemon and make it to merge concurrent checkpoint requests as 280 much as possible to eliminate redundant checkpoint issues. Plus, 281 we can eliminate the sluggish issue caused by slow checkpoint 282 operation when the checkpoint is done in a process context in 283 a cgroup having low i/o budget and cpu shares. To make this 284 do better, we set the default i/o priority of the kernel daemon 285 to "3", to give one higher priority than other kernel threads. 286 This is the same way to give a I/O priority to the jbd2 287 journaling thread of ext4 filesystem. 288 nocheckpoint_merge Disable checkpoint merge feature. 289 compress_algorithm=%s Control compress algorithm, currently f2fs supports "lzo", 290 "lz4", "zstd" and "lzo-rle" algorithm. 291 compress_algorithm=%s:%d Control compress algorithm and its compress level, now, only 292 "lz4" and "zstd" support compress level config. 293 algorithm level range 294 lz4 3 - 16 295 zstd 1 - 22 296 compress_log_size=%u Support configuring compress cluster size. The size will 297 be 4KB * (1 << %u). The default and minimum sizes are 16KB. 298 compress_extension=%s Support adding specified extension, so that f2fs can enable 299 compression on those corresponding files, e.g. if all files 300 with '.ext' has high compression rate, we can set the '.ext' 301 on compression extension list and enable compression on 302 these file by default rather than to enable it via ioctl. 303 For other files, we can still enable compression via ioctl. 304 Note that, there is one reserved special extension '*', it 305 can be set to enable compression for all files. 306 nocompress_extension=%s Support adding specified extension, so that f2fs can disable 307 compression on those corresponding files, just contrary to compression extension. 308 If you know exactly which files cannot be compressed, you can use this. 309 The same extension name can't appear in both compress and nocompress 310 extension at the same time. 311 If the compress extension specifies all files, the types specified by the 312 nocompress extension will be treated as special cases and will not be compressed. 313 Don't allow use '*' to specifie all file in nocompress extension. 314 After add nocompress_extension, the priority should be: 315 dir_flag < comp_extention,nocompress_extension < comp_file_flag,no_comp_file_flag. 316 See more in compression sections. 317 318 compress_chksum Support verifying chksum of raw data in compressed cluster. 319 compress_mode=%s Control file compression mode. This supports "fs" and "user" 320 modes. In "fs" mode (default), f2fs does automatic compression 321 on the compression enabled files. In "user" mode, f2fs disables 322 the automaic compression and gives the user discretion of 323 choosing the target file and the timing. The user can do manual 324 compression/decompression on the compression enabled files using 325 ioctls. 326 compress_cache Support to use address space of a filesystem managed inode to 327 cache compressed block, in order to improve cache hit ratio of 328 random read. 329 inlinecrypt When possible, encrypt/decrypt the contents of encrypted 330 files using the blk-crypto framework rather than 331 filesystem-layer encryption. This allows the use of 332 inline encryption hardware. The on-disk format is 333 unaffected. For more details, see 334 Documentation/block/inline-encryption.rst. 335 atgc Enable age-threshold garbage collection, it provides high 336 effectiveness and efficiency on background GC. 337 discard_unit=%s Control discard unit, the argument can be "block", "segment" 338 and "section", issued discard command's offset/size will be 339 aligned to the unit, by default, "discard_unit=block" is set, 340 so that small discard functionality is enabled. 341 For blkzoned device, "discard_unit=section" will be set by 342 default, it is helpful for large sized SMR or ZNS devices to 343 reduce memory cost by getting rid of fs metadata supports small 344 discard. 345 memory=%s Control memory mode. This supports "normal" and "low" modes. 346 "low" mode is introduced to support low memory devices. 347 Because of the nature of low memory devices, in this mode, f2fs 348 will try to save memory sometimes by sacrificing performance. 349 "normal" mode is the default mode and same as before. 350 age_extent_cache Enable an age extent cache based on rb-tree. It records 351 data block update frequency of the extent per inode, in 352 order to provide better temperature hints for data block 353 allocation. 354 errors=%s Specify f2fs behavior on critical errors. This supports modes: 355 "panic", "continue" and "remount-ro", respectively, trigger 356 panic immediately, continue without doing anything, and remount 357 the partition in read-only mode. By default it uses "continue" 358 mode. > 359 continue remount-ro panic
360 access ops normal noraml N/A
361 syscall errors -EIO -EROFS N/A
362 mount option rw ro N/A
363 pending dir write keep keep N/A
364 pending non-dir write drop keep N/A
365 pending node write drop keep N/A
366 pending meta write keep keep N/A
367 ======================== ============================================================
368
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests