Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

f2fs: add mount option to select fault injection ratio

This patch adds a mount option to select fault ratio.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

+28
+8
fs/f2fs/Kconfig
··· 94 94 information and block IO patterns in the filesystem level. 95 95 96 96 If unsure, say N. 97 + 98 + config F2FS_FAULT_INJECTION 99 + bool "F2FS fault injection facility" 100 + depends on F2FS_FS 101 + help 102 + Test F2FS to inject faults such as ENOMEM, ENOSPC, and so on. 103 + 104 + If unsure, say N.
+1
fs/f2fs/f2fs.h
··· 56 56 #define F2FS_MOUNT_EXTENT_CACHE 0x00002000 57 57 #define F2FS_MOUNT_FORCE_FG_GC 0x00004000 58 58 #define F2FS_MOUNT_DATA_FLUSH 0x00008000 59 + #define F2FS_MOUNT_FAULT_INJECTION 0x00010000 59 60 60 61 #define clear_opt(sbi, option) (sbi->mount_opt.opt &= ~F2FS_MOUNT_##option) 61 62 #define set_opt(sbi, option) (sbi->mount_opt.opt |= F2FS_MOUNT_##option)
+19
fs/f2fs/super.c
··· 39 39 static struct kmem_cache *f2fs_inode_cachep; 40 40 static struct kset *f2fs_kset; 41 41 42 + #ifdef CONFIG_F2FS_FAULT_INJECTION 43 + u32 f2fs_fault_rate = 0; 44 + #endif 45 + 42 46 /* f2fs-wide shrinker description */ 43 47 static struct shrinker f2fs_shrinker_info = { 44 48 .scan_objects = f2fs_shrink_scan, ··· 72 68 Opt_noextent_cache, 73 69 Opt_noinline_data, 74 70 Opt_data_flush, 71 + Opt_fault_injection, 75 72 Opt_err, 76 73 }; 77 74 ··· 98 93 {Opt_noextent_cache, "noextent_cache"}, 99 94 {Opt_noinline_data, "noinline_data"}, 100 95 {Opt_data_flush, "data_flush"}, 96 + {Opt_fault_injection, "fault_injection=%u"}, 101 97 {Opt_err, NULL}, 102 98 }; 103 99 ··· 306 300 char *p, *name; 307 301 int arg = 0; 308 302 303 + #ifdef CONFIG_F2FS_FAULT_INJECTION 304 + f2fs_fault_rate = 0; 305 + #endif 309 306 if (!options) 310 307 return 0; 311 308 ··· 441 432 break; 442 433 case Opt_data_flush: 443 434 set_opt(sbi, DATA_FLUSH); 435 + break; 436 + case Opt_fault_injection: 437 + if (args->from && match_int(args, &arg)) 438 + return -EINVAL; 439 + #ifdef CONFIG_F2FS_FAULT_INJECTION 440 + f2fs_fault_rate = arg; 441 + #else 442 + f2fs_msg(sb, KERN_INFO, 443 + "FAULT_INJECTION was not selected"); 444 + #endif 444 445 break; 445 446 default: 446 447 f2fs_msg(sb, KERN_ERR,