f2fs: try to use common fault injection framework
Subsystems (2)
cover f2fs: try to use common fault injection framework
Hi,
Kernel fault injection framework have provided a a systematic way to support error injection via debugfs in the /sys/kernel/debug directory.
Compared to the current fault injection by mount options and sysfs, fault injection framework can provide more easy used fault injection control means.
Thus, this patchset try to use common fault injection for f2fs.
Yufen Yu (5):
f2fs: extract f2fs root debugfs to init_f2fs_fs
f2fs: use common fault injection frmework
f2fs: replace function time_to_inject by f2fs_should_fail
f2fs: get rid of stale fault injection code
f2fs: update doc for f2fs fault injection
Documentation/filesystems/f2fs.rst | 118 ++++++++++++++++++++++------- fs/f2fs/Kconfig | 2 +- fs/f2fs/Makefile | 1 + fs/f2fs/checkpoint.c | 4 +- fs/f2fs/data.c | 4 +- fs/f2fs/debug.c | 19 +---- fs/f2fs/dir.c | 2 +- fs/f2fs/f2fs.h | 81 ++++++++------------ fs/f2fs/fault_inject.c | 67 ++++++++++++++++ fs/f2fs/file.c | 2 +- fs/f2fs/gc.c | 2 +- fs/f2fs/inode.c | 2 +- fs/f2fs/node.c | 2 +- fs/f2fs/segment.c | 4 +- fs/f2fs/super.c | 82 ++++++-------------- fs/f2fs/sysfs.c | 23 ------ 16 files changed, 227 insertions(+), 188 deletions(-) create mode 100644 fs/f2fs/fault_inject.c
Signature · 1 line
2.31.1
PATCH 1/5 f2fs: extract f2fs root debugfs to init_f2fs_fs
Then, we don't need to depend on CONFIG_F2FS_STAT_FS to create f2fs root debugfs directory /sys/kernel/debug/f2fs.
This patch is prepared for following f2fs fault injection, which will create sub directory 'fault_inject' into f2fs root debugfs.
--- fs/f2fs/debug.c | 19 ++----------------- fs/f2fs/f2fs.h | 4 ++-- fs/f2fs/super.c | 22 ++++++++++++++++++++-- 3 files changed, 24 insertions(+), 21 deletions(-)
fs/f2fs/debug.c +2 -17
@@ -22,9 +22,6 @@static LIST_HEAD (f2fs_stat_list);static DEFINE_RAW_SPINLOCK (f2fs_stat_lock); -#ifdef CONFIG_DEBUG_FS -static struct dentry *f2fs_debugfs_root; -#endif /* * This function calculates BDF of every segments
@@ -648,18 +645,6 @@ void f2fs_destroy_stats(struct f2fs_sb_info *sbi)void __init f2fs_create_root_stats (void ) { -#ifdef CONFIG_DEBUG_FS - f2fs_debugfs_root =debugfs_create_dir ("f2fs" ,NULL ); - -debugfs_create_file ("status" ,0444 , f2fs_debugfs_root,NULL , - &stat_fops); -#endif -} - -void f2fs_destroy_root_stats (void ) -{ -#ifdef CONFIG_DEBUG_FS -debugfs_remove_recursive (f2fs_debugfs_root); - f2fs_debugfs_root =NULL ; -#endif +if (f2fs_debugfs_root) +debugfs_create_file ("status" ,0444 , f2fs_debugfs_root,NULL , &stat_fops); }
fs/f2fs/f2fs.h +2 -2
@@ -62,6 +62,8 @@ enum { FAULT_MAX, }; +extern struct dentry *f2fs_debugfs_root; +#ifdef CONFIG_F2FS_FAULT_INJECTION #define F2FS_ALL_FAULT_TYPE ((1 << FAULT_MAX) - 1)
@@ -3994,7 +3996,6 @@ static inline struct f2fs_stat_info *F2FS_STAT(struct f2fs_sb_info *sbi)int f2fs_build_stats (struct f2fs_sb_info *sbi);void f2fs_destroy_stats (struct f2fs_sb_info *sbi);void __init f2fs_create_root_stats (void ); -void f2fs_destroy_root_stats (void );void f2fs_update_sit_info (struct f2fs_sb_info *sbi);#else #define stat_inc_cp_count (si) do { } while (0)
@@ -4035,7 +4036,6 @@ void f2fs_update_sit_info(struct f2fs_sb_info *sbi);static inline int f2fs_build_stats (struct f2fs_sb_info *sbi) {return 0 ; }static inline void f2fs_destroy_stats (struct f2fs_sb_info *sbi) { }static inline void __init f2fs_create_root_stats (void ) { } -static inline void f2fs_destroy_root_stats (void ) { }static inline void f2fs_update_sit_info (struct f2fs_sb_info *sbi) {}#endif
fs/f2fs/super.c +20 -2
@@ -27,6 +27,7 @@#include <linux/part_stat.h> #include <linux/zstd.h> #include <linux/lz4.h> +#include <linux/debugfs.h> #include "f2fs.h" #include "node.h"
@@ -39,6 +40,7 @@#include <trace/events/f2fs.h> static struct kmem_cache *f2fs_inode_cachep; +struct dentry *f2fs_debugfs_root;#ifdef CONFIG_F2FS_FAULT_INJECTION
@@ -4575,6 +4577,21 @@ static void destroy_inodecache(void)kmem_cache_destroy (f2fs_inode_cachep); } +static void f2fs_create_debugfs (void ) +{ +#ifdef CONFIG_DEBUG_FS + f2fs_debugfs_root =debugfs_create_dir ("f2fs" ,NULL ); +#endif +} + +static void f2fs_destroy_debugfs (void ) +{ +#ifdef CONFIG_DEBUG_FS +debugfs_remove_recursive (f2fs_debugfs_root); + f2fs_debugfs_root =NULL ; +#endif +} +static int __init init_f2fs_fs (void ) {int err;
@@ -4615,6 +4632,7 @@ static int __init init_f2fs_fs(void) err =register_filesystem (&f2fs_fs_type);if (err) goto free_shrinker; +f2fs_create_debugfs ();f2fs_create_root_stats (); err =f2fs_init_post_read_processing ();if (err)
@@ -4651,7 +4669,7 @@ static int __init init_f2fs_fs(void) free_post_read:f2fs_destroy_post_read_processing (); free_root_stats: -f2fs_destroy_root_stats (); +f2fs_destroy_debugfs ();unregister_filesystem (&f2fs_fs_type); free_shrinker:unregister_shrinker (&f2fs_shrinker_info);
@@ -4684,7 +4702,7 @@ static void __exit exit_f2fs_fs(void)f2fs_destroy_bio_entry_cache ();f2fs_destroy_iostat_processing ();f2fs_destroy_post_read_processing (); -f2fs_destroy_root_stats (); +f2fs_destroy_debugfs ();unregister_filesystem (&f2fs_fs_type);unregister_shrinker (&f2fs_shrinker_info);f2fs_exit_sysfs ();
Signature · 1 line
2.31.1
PATCH 2/5 f2fs: use common fault injection frmework
In reply to Yufen YuFor now, f2fs use mount options 'fault_injection' and 'fault_type' to enable fault injection. We set inject_type and inject_rate in sysfs to control fault injection.
In fact, common fault injection framework have provided a systematic way to support error injection via debugfs, which has more richer and easier control means than the current one.
For example, we can set 'interval' to specify the interval between failures, and set 'times' to specify how many times failures may happen at most. More fault injection usage can be seen in (Documentation/ fault-injection/fault-injection.rst)
--- fs/f2fs/Kconfig | 2 +- fs/f2fs/Makefile | 1 + fs/f2fs/f2fs.h | 26 ++++++++++++++++ fs/f2fs/fault_inject.c | 67 ++++++++++++++++++++++++++++++++++++++++++ fs/f2fs/super.c | 3 ++ 5 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 fs/f2fs/fault_inject.c
fs/f2fs/Kconfig +1 -1
@@ -86,7 +86,7 @@ config F2FS_CHECK_FS config F2FS_FAULT_INJECTION bool "F2FS fault injection facility" - depends on F2FS_FS + depends on F2FS_FS && FAULT_INJECTION && DEBUG_FS help Test F2FS to inject faults such as ENOMEM, ENOSPC, and so on.
fs/f2fs/Makefile +1 -0
@@ -10,3 +10,4 @@ f2fs-$(CONFIG_F2FS_FS_POSIX_ACL) += acl.o f2fs-$(CONFIG_FS_VERITY) += verity.o f2fs-$(CONFIG_F2FS_FS_COMPRESSION) += compress.o f2fs-$(CONFIG_F2FS_IOSTAT) += iostat.o +f2fs-$(CONFIG_F2FS_FAULT_INJECTION) += fault_inject.o
fs/f2fs/f2fs.h +26 -0
@@ -27,6 +27,7 @@#include <linux/fscrypt.h> #include <linux/fsverity.h> +#include <linux/fault-inject.h> struct pagevec ;
@@ -1592,6 +1593,14 @@ struct decompress_io_ctx {struct work_struct verity_work;/* work to verify the decompressed pages */ }; +struct f2fs_fault_inject { +#ifdef CONFIG_F2FS_FAULT_INJECTION +struct fault_attr attr; +struct dentry *parent; +unsigned int inject_type; +#endif +}; +#define NULL_CLUSTER ((unsigned int)(~0))#define MIN_COMPRESS_LOG_SIZE 2#define MAX_COMPRESS_LOG_SIZE 8
@@ -1846,6 +1855,8 @@ struct f2fs_sb_info {spinlock_t iostat_lat_lock;struct iostat_lat_info *iostat_io_lat;#endif + +struct f2fs_fault_inject fault_inject; };#ifdef CONFIG_F2FS_FAULT_INJECTION
@@ -1879,6 +1890,21 @@ static inline bool time_to_inject(struct f2fs_sb_info *sbi, int type) }#endif +#ifdef CONFIG_F2FS_FAULT_INJECTION +bool f2fs_should_fail (struct f2fs_sb_info *sbi,unsigned int type); +void f2fs_fault_inject_init (struct f2fs_sb_info *sbi); +void f2fs_fault_inject_fini (struct f2fs_sb_info *sbi); +void f2fs_stop_fault_inject (struct f2fs_sb_info *sbi); +#else +static inline bool f2fs_should_fail (struct f2fs_sb_info *sbi,unsigned int type) +{ +return false; +}; +static inline void f2fs_fault_inject_init (struct f2fs_sb_info *sbi) {}; +static inline void f2fs_fault_inject_fini (struct f2fs_sb_info *sbi) {}; +static inline void f2fs_stop_fault_inject (struct f2fs_sb_info *sbi) {}; +#endif +/* * Test if the mounted volume is a multi-device volume. * - For a single regular disk volume, sbi->s_ndevs is 0.
fs/f2fs/fault_inject.c new file +67 -0
67 lines not on this page · raw message
fs/f2fs/super.c +3 -0
@@ -1600,6 +1600,8 @@ static void f2fs_put_super(struct super_block *sb)*/ f2fs_destroy_stats (sbi); +f2fs_fault_inject_fini (sbi); +/* destroy f2fs internal modules */ f2fs_destroy_node_manager (sbi);f2fs_destroy_segment_manager (sbi);
@@ -4418,6 +4420,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)f2fs_update_time (sbi,CP_TIME );f2fs_update_time (sbi,REQ_TIME );clear_sbi_flag (sbi,SBI_CP_DISABLED_QUICK ); +f2fs_fault_inject_init (sbi);return 0 ; sync_free_meta:
Signature · 1 line
2.31.1
PATCH 3/5 f2fs: replace function time_to_inject by f2fs_should_fail
In reply to Yufen YuReplace all time_to_inject by f2fs_should_fail to apply new fault inject.
--- fs/f2fs/checkpoint.c | 2 +- fs/f2fs/data.c | 4 ++-- fs/f2fs/dir.c | 2 +- fs/f2fs/f2fs.h | 16 ++++++++-------- fs/f2fs/file.c | 2 +- fs/f2fs/gc.c | 2 +- fs/f2fs/inode.c | 2 +- fs/f2fs/node.c | 2 +- fs/f2fs/segment.c | 4 ++-- fs/f2fs/super.c | 4 ++-- 10 files changed, 20 insertions(+), 20 deletions(-)
fs/f2fs/checkpoint.c +1 -1
@@ -611,7 +611,7 @@ int f2fs_acquire_orphan_inode(struct f2fs_sb_info *sbi)spin_lock (&im->ino_lock); -if (time_to_inject (sbi,FAULT_ORPHAN )) { +if (f2fs_should_fail (sbi,FAULT_ORPHAN )) {spin_unlock (&im->ino_lock);f2fs_show_injection_info (sbi,FAULT_ORPHAN );return -ENOSPC ;
fs/f2fs/data.c +2 -2
@@ -276,7 +276,7 @@ static void f2fs_read_end_io(struct bio *bio)iostat_update_and_unbind_ctx (bio,0 ); ctx = bio->bi_private; -if (time_to_inject (sbi,FAULT_READ_IO )) { +if (f2fs_should_fail (sbi,FAULT_READ_IO )) {f2fs_show_injection_info (sbi,FAULT_READ_IO ); bio->bi_status =BLK_STS_IOERR ; }
@@ -303,7 +303,7 @@ static void f2fs_write_end_io(struct bio *bio)iostat_update_and_unbind_ctx (bio,1 ); sbi = bio->bi_private; -if (time_to_inject (sbi,FAULT_WRITE_IO )) { +if (f2fs_should_fail (sbi,FAULT_WRITE_IO )) {f2fs_show_injection_info (sbi,FAULT_WRITE_IO ); bio->bi_status =BLK_STS_IOERR ; }
fs/f2fs/dir.c +1 -1
@@ -727,7 +727,7 @@ int f2fs_add_regular_entry(struct inode *dir, const struct f2fs_filename *fname, } start: -if (time_to_inject (F2FS_I_SB (dir),FAULT_DIR_DEPTH )) { +if (f2fs_should_fail (F2FS_I_SB (dir),FAULT_DIR_DEPTH )) {f2fs_show_injection_info (F2FS_I_SB (dir),FAULT_DIR_DEPTH );return -ENOSPC ; }
fs/f2fs/f2fs.h +8 -8
@@ -2231,7 +2231,7 @@ static inline void f2fs_lock_op(struct f2fs_sb_info *sbi)static inline int f2fs_trylock_op (struct f2fs_sb_info *sbi) { -if (time_to_inject (sbi,FAULT_LOCK_OP )) { +if (f2fs_should_fail (sbi,FAULT_LOCK_OP )) {f2fs_show_injection_info (sbi,FAULT_LOCK_OP );return 0 ; }
@@ -2321,7 +2321,7 @@ static inline int inc_valid_block_count(struct f2fs_sb_info *sbi,if (ret)return ret; -if (time_to_inject (sbi,FAULT_BLOCK )) { +if (f2fs_should_fail (sbi,FAULT_BLOCK )) {f2fs_show_injection_info (sbi,FAULT_BLOCK ); release = *count; goto release_quota;
@@ -2579,7 +2579,7 @@ static inline int inc_valid_node_count(struct f2fs_sb_info *sbi,return err; } -if (time_to_inject (sbi,FAULT_BLOCK )) { +if (f2fs_should_fail (sbi,FAULT_BLOCK )) {f2fs_show_injection_info (sbi,FAULT_BLOCK ); goto enospc; }
@@ -2699,7 +2699,7 @@ static inline struct page *f2fs_grab_cache_page(struct address_space *mapping,if (page)return page; -if (time_to_inject (F2FS_M_SB (mapping),FAULT_PAGE_ALLOC )) { +if (f2fs_should_fail (F2FS_M_SB (mapping),FAULT_PAGE_ALLOC )) {f2fs_show_injection_info (F2FS_M_SB (mapping),FAULT_PAGE_ALLOC );return NULL ;
@@ -2715,7 +2715,7 @@ static inline struct page *f2fs_pagecache_get_page( struct address_space *mapping, pgoff_t index, int fgp_flags, gfp_t gfp_mask) { - if (time_to_inject(F2FS_M_SB(mapping), FAULT_PAGE_GET)) { + if (f2fs_should_fail(F2FS_M_SB(mapping), FAULT_PAGE_GET)) {f2fs_show_injection_info (F2FS_M_SB (mapping ),FAULT_PAGE_GET );return NULL ; }
@@ -2778,7 +2778,7 @@ static inline void *f2fs_kmem_cache_alloc(struct kmem_cache *cachep,if (nofail)return f2fs_kmem_cache_alloc_nofail (cachep, flags); -if (time_to_inject (sbi,FAULT_SLAB_ALLOC )) { +if (f2fs_should_fail (sbi,FAULT_SLAB_ALLOC )) {f2fs_show_injection_info (sbi,FAULT_SLAB_ALLOC );return NULL ; }
@@ -3350,7 +3350,7 @@ static inline bool is_dot_dotdot(const u8 *name, size_t len)static inline void *f2fs_kmalloc (struct f2fs_sb_info *sbi,size_t size,gfp_t flags) { -if (time_to_inject (sbi,FAULT_KMALLOC )) { +if (f2fs_should_fail (sbi,FAULT_KMALLOC )) {f2fs_show_injection_info (sbi,FAULT_KMALLOC );return NULL ; }
@@ -3367,7 +3367,7 @@ static inline void *f2fs_kzalloc(struct f2fs_sb_info *sbi,static inline void *f2fs_kvmalloc (struct f2fs_sb_info *sbi,size_t size,gfp_t flags) { -if (time_to_inject (sbi,FAULT_KVMALLOC )) { +if (f2fs_should_fail (sbi,FAULT_KVMALLOC )) {f2fs_show_injection_info (sbi,FAULT_KVMALLOC );return NULL ; }
fs/f2fs/file.c +1 -1
@@ -782,7 +782,7 @@ int f2fs_truncate(struct inode *inode)trace_f2fs_truncate (inode); -if (time_to_inject (F2FS_I_SB (inode),FAULT_TRUNCATE )) { +if (f2fs_should_fail (F2FS_I_SB (inode),FAULT_TRUNCATE )) {f2fs_show_injection_info (F2FS_I_SB (inode),FAULT_TRUNCATE );return -EIO ; }
fs/f2fs/gc.c +1 -1
@@ -68,7 +68,7 @@ static int gc_thread_func(void *data)continue ; } -if (time_to_inject (sbi,FAULT_CHECKPOINT )) { +if (f2fs_should_fail (sbi,FAULT_CHECKPOINT )) {f2fs_show_injection_info (sbi,FAULT_CHECKPOINT );f2fs_stop_checkpoint (sbi, false); }
fs/f2fs/inode.c +1 -1
@@ -786,7 +786,7 @@ void f2fs_evict_inode(struct inode *inode)if (F2FS_HAS_BLOCKS (inode)) err =f2fs_truncate (inode); -if (time_to_inject (sbi,FAULT_EVICT_INODE )) { +if (f2fs_should_fail (sbi,FAULT_EVICT_INODE )) {f2fs_show_injection_info (sbi,FAULT_EVICT_INODE ); err = -EIO ; }
fs/f2fs/node.c +1 -1
@@ -2543,7 +2543,7 @@ bool f2fs_alloc_nid(struct f2fs_sb_info *sbi, nid_t *nid)struct f2fs_nm_info *nm_i =NM_I (sbi);struct free_nid *i =NULL ; retry: -if (time_to_inject (sbi,FAULT_ALLOC_NID )) { +if (f2fs_should_fail (sbi,FAULT_ALLOC_NID )) {f2fs_show_injection_info (sbi,FAULT_ALLOC_NID );return false; }
fs/f2fs/segment.c +2 -2
@@ -493,7 +493,7 @@ int f2fs_commit_inmem_pages(struct inode *inode)*/ void f2fs_balance_fs (struct f2fs_sb_info *sbi,bool need) { -if (time_to_inject (sbi,FAULT_CHECKPOINT )) { +if (f2fs_should_fail (sbi,FAULT_CHECKPOINT )) {f2fs_show_injection_info (sbi,FAULT_CHECKPOINT );f2fs_stop_checkpoint (sbi, false); }
@@ -1237,7 +1237,7 @@ static int __submit_discard_cmd(struct f2fs_sb_info *sbi, dc->len += len; -if (time_to_inject (sbi,FAULT_DISCARD )) { +if (f2fs_should_fail (sbi,FAULT_DISCARD )) {f2fs_show_injection_info (sbi,FAULT_DISCARD ); err = -EIO ; goto submit;
fs/f2fs/super.c +2 -2
@@ -1347,7 +1347,7 @@ static struct inode *f2fs_alloc_inode(struct super_block *sb) {struct f2fs_inode_info *fi; -if (time_to_inject (F2FS_SB (sb),FAULT_SLAB_ALLOC )) { +if (f2fs_should_fail (F2FS_SB (sb),FAULT_SLAB_ALLOC )) {f2fs_show_injection_info (F2FS_SB (sb),FAULT_SLAB_ALLOC );return NULL ; }
@@ -2551,7 +2551,7 @@ static ssize_t f2fs_quota_write(struct super_block *sb, int type,int f2fs_dquot_initialize (struct inode *inode) { -if (time_to_inject (F2FS_I_SB (inode),FAULT_DQUOT_INIT )) { +if (f2fs_should_fail (F2FS_I_SB (inode),FAULT_DQUOT_INIT )) {f2fs_show_injection_info (F2FS_I_SB (inode),FAULT_DQUOT_INIT );return -ESRCH ; }
Signature · 1 line
2.31.1
PATCH 4/5 f2fs: get rid of stale fault injection code
In reply to Yufen YuNowly, we can use new fault injection framework. Just delete the stale fault injection code.
--- fs/f2fs/checkpoint.c | 2 +- fs/f2fs/f2fs.h | 51 ++---------------------------------------- fs/f2fs/super.c | 53 -------------------------------------------- fs/f2fs/sysfs.c | 23 ------------------- 4 files changed, 3 insertions(+), 126 deletions(-)
fs/f2fs/checkpoint.c +1 -1
@@ -28,7 +28,7 @@ struct kmem_cache *f2fs_inode_entry_slab;void f2fs_stop_checkpoint (struct f2fs_sb_info *sbi,bool end_io) { -f2fs_build_fault_attr (sbi,0 ,0 ); +f2fs_stop_fault_inject (sbi);set_ckpt_flags (sbi,CP_ERROR_FLAG );if (!end_io)f2fs_flush_merged_writes (sbi);
fs/f2fs/f2fs.h +2 -49
85 lines not on this page · raw message
fs/f2fs/super.c +0 -53
89 lines not on this page · raw message
fs/f2fs/sysfs.c +0 -23
@@ -31,10 +31,6 @@ enum { F2FS_SBI, /* struct f2fs_sb_info */#ifdef CONFIG_F2FS_STAT_FS STAT_INFO ,/* struct f2fs_stat_info */ -#endif -#ifdef CONFIG_F2FS_FAULT_INJECTION -FAULT_INFO_RATE ,/* struct f2fs_fault_info */ -FAULT_INFO_TYPE ,/* struct f2fs_fault_info */ #endifRESERVED_BLOCKS ,/* struct f2fs_sb_info */ CPRC_INFO, /* struct ckpt_req_control */
@@ -76,11 +72,6 @@ static unsigned char *__struct_ptr(struct f2fs_sb_info *sbi, int struct_type)return (unsigned char *)NM_I (sbi); else if (struct_type == F2FS_SBI || struct_type == RESERVED_BLOCKS) return (unsigned char *)sbi; -#ifdef CONFIG_F2FS_FAULT_INJECTION - else if (struct_type == FAULT_INFO_RATE || - struct_type == FAULT_INFO_TYPE) - return (unsigned char *)&F2FS_OPTION(sbi).fault_info; -#endif #ifdef CONFIG_F2FS_STAT_FS else if (struct_type == STAT_INFO) return (unsigned char *)F2FS_STAT(sbi);
@@ -429,12 +420,6 @@ static ssize_t __sbi_store(struct f2fs_attr *a, ret =kstrtoul (skip_spaces (buf),0 , &t);if (ret <0 )return ret; -#ifdef CONFIG_F2FS_FAULT_INJECTION -if (a->struct_type ==FAULT_INFO_TYPE && t >= (1 <<FAULT_MAX )) -return -EINVAL ; -if (a->struct_type ==FAULT_INFO_RATE && t >=UINT_MAX ) -return -EINVAL ; -#endif if (a->struct_type ==RESERVED_BLOCKS ) {spin_lock (&sbi->stat_lock); if (t > (unsigned long)(sbi->user_block_count -
@@ -773,10 +758,6 @@ F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, readdir_ra, readdir_ra);F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info, max_io_bytes, max_io_bytes);F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info, gc_pin_file_thresh, gc_pin_file_threshold);F2FS_RW_ATTR (F2FS_SBI , f2fs_super_block, extension_list, extension_list); -#ifdef CONFIG_F2FS_FAULT_INJECTION -F2FS_RW_ATTR (FAULT_INFO_RATE , f2fs_fault_info, inject_rate, inject_rate); -F2FS_RW_ATTR (FAULT_INFO_TYPE , f2fs_fault_info, inject_type, inject_type); -#endif F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info, data_io_flag, data_io_flag);F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info, node_io_flag, node_io_flag);F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info, gc_urgent_high_remaining, gc_urgent_high_remaining);
@@ -892,10 +873,6 @@ static struct attribute *f2fs_attrs[] = {ATTR_LIST (max_io_bytes),ATTR_LIST (gc_pin_file_thresh),ATTR_LIST (extension_list), -#ifdef CONFIG_F2FS_FAULT_INJECTION -ATTR_LIST (inject_rate), -ATTR_LIST (inject_type), -#endifATTR_LIST (data_io_flag),ATTR_LIST (node_io_flag), ATTR_LIST(gc_urgent_high_remaining),
Signature · 8 lines
2.31.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Chao Yu
maintainerRe: [f2fs-dev] [PATCH 4/5] f2fs: get rid of stale fault injection code
Quoted 194 lines · On 2022/4/1 15:19, Yufen Yu via Linux-f2fs-devel wrote:
Nowly, we can use new fault injection framework. Just delete the stale fault injection code.
Signed-off-by Yufen Yu <[email protected]>--- fs/f2fs/checkpoint.c | 2 +- fs/f2fs/f2fs.h | 51 ++---------------------------------------- fs/f2fs/super.c | 53 -------------------------------------------- fs/f2fs/sysfs.c | 23 ------------------- 4 files changed, 3 insertions(+), 126 deletions(-)fs/f2fs/checkpoint.c +1
-1@@ -28,7 +28,7 @@ struct kmem_cache *f2fs_inode_entry_slab;void f2fs_stop_checkpoint (struct f2fs_sb_info *sbi,bool end_io) { -f2fs_build_fault_attr (sbi,0 ,0 ); +f2fs_stop_fault_inject (sbi);set_ckpt_flags (sbi,CP_ERROR_FLAG );if (!end_io)f2fs_flush_merged_writes (sbi);fs/f2fs/f2fs.h +2
-49@@ -65,19 +65,6 @@ enum {extern struct dentry *f2fs_debugfs_root; -#ifdef CONFIG_F2FS_FAULT_INJECTION -#define F2FS_ALL_FAULT_TYPE ((1 << FAULT_MAX) - 1) - -struct f2fs_fault_info { -atomic_t inject_ops; -unsigned int inject_rate; -unsigned int inject_type; -}; - -extern const char *f2fs_fault_name[FAULT_MAX ]; -#define IS_FAULT_SET (fi, type) ((fi)->inject_type & (1 << (type))) -#endif -/* * For mount options */ @@ -148,9 +135,6 @@ struct f2fs_mount_info {kgid_t s_resgid;/* reserved blocks for gid */ int active_logs;/* # of active logs */ int inline_xattr_size;/* inline xattr size */ -#ifdef CONFIG_F2FS_FAULT_INJECTION -struct f2fs_fault_info fault_info;/* For fault injection */ -#endif #ifdef CONFIG_QUOTA /* Names of quota files with journalled quota */ char *s_qf_names[MAXQUOTAS ];@@ -1860,42 +1844,18 @@ struct f2fs_sb_info { };#ifdef CONFIG_F2FS_FAULT_INJECTION +extern const char *f2fs_fault_name[FAULT_MAX ];#define f2fs_show_injection_info (sbi, type) \ printk_ratelimited("%sF2FS-fs (%s) : inject %s in %s of %pS\n", \ KERN_INFO, sbi->sb->s_id, \ f2fs_fault_name[type], \ __func__, __builtin_return_address(0)) -static inline bool time_to_inject (struct f2fs_sb_info *sbi,int type) -{ -struct f2fs_fault_info *ffi = &F2FS_OPTION (sbi).fault_info; - -if (!ffi->inject_rate) -return false; - -if (!IS_FAULT_SET (ffi, type)) -return false; - -atomic_inc (&ffi->inject_ops); -if (atomic_read (&ffi->inject_ops) >= ffi->inject_rate) { -atomic_set (&ffi->inject_ops,0 ); -return true; - } -return false; -} -#else -#define f2fs_show_injection_info (sbi, type) do { } while (0) -static inline bool time_to_inject (struct f2fs_sb_info *sbi,int type) -{ -return false; -} -#endif - -#ifdef CONFIG_F2FS_FAULT_INJECTION bool f2fs_should_fail (struct f2fs_sb_info *sbi,unsigned int type);void f2fs_fault_inject_init (struct f2fs_sb_info *sbi);void f2fs_fault_inject_fini (struct f2fs_sb_info *sbi);void f2fs_stop_fault_inject (struct f2fs_sb_info *sbi);#else +#define f2fs_show_injection_info (sbi, type) do { } while (0)static inline bool f2fs_should_fail (struct f2fs_sb_info *sbi,unsigned int type) {return false;@@ -4538,13 +4498,6 @@ static inline bool f2fs_need_verity(const struct inode *inode, pgoff_t idx) idx <DIV_ROUND_UP (inode->i_size,PAGE_SIZE ); } -#ifdef CONFIG_F2FS_FAULT_INJECTION -extern void f2fs_build_fault_attr (struct f2fs_sb_info *sbi,unsigned int rate, -unsigned int type); -#else -#define f2fs_build_fault_attr (sbi, rate, type) do { } while (0) -#endif -static inline bool is_journalled_quota (struct f2fs_sb_info *sbi) {#ifdef CONFIG_QUOTA fs/f2fs/super.c +0
-43@@ -64,22 +64,6 @@ const char *f2fs_fault_name[FAULT_MAX] = { [FAULT_LOCK_OP] = "lock_op", }; -void f2fs_build_fault_attr (struct f2fs_sb_info *sbi,unsigned int rate, -unsigned int type) -{ -struct f2fs_fault_info *ffi = &F2FS_OPTION (sbi).fault_info; - -if (rate) { -atomic_set (&ffi->inject_ops,0 ); - ffi->inject_rate = rate; - } - -if (type) - ffi->inject_type = type; - -if (!rate && !type) -memset (ffi,0 ,sizeof (struct f2fs_fault_info )); -}#endif /* f2fs-wide shrinker description */ @@ -122,8 +106,6 @@ enum { Opt_resuid, Opt_mode, Opt_io_size_bits, - Opt_fault_injection, - Opt_fault_type, Opt_lazytime, Opt_nolazytime, Opt_quota,@@ -198,8 +180,6 @@ static match_table_t f2fs_tokens = { {Opt_resuid, "resuid=%u"}, {Opt_mode, "mode=%s"}, {Opt_io_size_bits, "io_bits=%u"}, - {Opt_fault_injection, "fault_injection=%u"}, - {Opt_fault_type, "fault_type=%u"}, {Opt_lazytime, "lazytime"}, {Opt_nolazytime, "nolazytime"}, {Opt_quota, "quota"},@@ -874,29 +854,6 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount) }F2FS_OPTION (sbi).write_io_size_bits = arg;break ; -#ifdef CONFIG_F2FS_FAULT_INJECTION -case Opt_fault_injection: -if (args->from &&match_int (args, &arg)) -return -EINVAL ; -f2fs_build_fault_attr (sbi, arg,F2FS_ALL_FAULT_TYPE ); -set_opt (sbi,FAULT_INJECTION ); -break ; - -case Opt_fault_type: -if (args->from &&match_int (args, &arg)) -return -EINVAL ; -f2fs_build_fault_attr (sbi,0 , arg); -set_opt (sbi,FAULT_INJECTION ); -break ; -#else -case Opt_fault_injection: -f2fs_info (sbi,"fault_injection options not supported" ); -break ; - -case Opt_fault_type: -f2fs_info (sbi,"fault_type options not supported" ); -break ; -#endif case Opt_lazytime: sb->s_flags |=SB_LAZYTIME ;break ;@@ -1963,14 +1920,6 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)if (F2FS_IO_SIZE_BITS (sbi))
fs/f2fs/super.c static int f2fs_show_options(struct seq_file *seq, struct dentry *root) · line 1973
Quoted 10 lines
fs/f2fs/super.c +0
-8seq_printf (seq,",io_bits=%u" ,F2FS_OPTION (sbi).write_io_size_bits); -#ifdef CONFIG_F2FS_FAULT_INJECTION -if (test_opt (sbi,FAULT_INJECTION )) { -seq_printf (seq,",fault_injection=%u" , -F2FS_OPTION (sbi).fault_info.inject_rate); -seq_printf (seq,",fault_type=%u" , -F2FS_OPTION (sbi).fault_info.inject_type); - } -#endif
This will cause regression due to it breaks application usage w/ -o fault_* mountoption..., I don't think this is the right way.
Thanks,
Quoted 74 lines
fs/f2fs/super.c +0
-2#ifdef CONFIG_QUOTA if (test_opt (sbi,QUOTA ))seq_puts (seq,",quota" );@@ -2076,8 +2025,6 @@ static void default_options(struct f2fs_sb_info *sbi)#ifdef CONFIG_F2FS_FS_POSIX_ACL set_opt (sbi,POSIX_ACL );#endif - -f2fs_build_fault_attr (sbi,0 ,0 ); }#ifdef CONFIG_QUOTA fs/f2fs/sysfs.c +0
-23@@ -31,10 +31,6 @@ enum { F2FS_SBI, /* struct f2fs_sb_info */#ifdef CONFIG_F2FS_STAT_FS STAT_INFO ,/* struct f2fs_stat_info */ -#endif -#ifdef CONFIG_F2FS_FAULT_INJECTION -FAULT_INFO_RATE ,/* struct f2fs_fault_info */ -FAULT_INFO_TYPE ,/* struct f2fs_fault_info */ #endifRESERVED_BLOCKS ,/* struct f2fs_sb_info */ CPRC_INFO, /* struct ckpt_req_control */@@ -76,11 +72,6 @@ static unsigned char *__struct_ptr(struct f2fs_sb_info *sbi, int struct_type)return (unsigned char *)NM_I (sbi); else if (struct_type == F2FS_SBI || struct_type == RESERVED_BLOCKS) return (unsigned char *)sbi; -#ifdef CONFIG_F2FS_FAULT_INJECTION - else if (struct_type == FAULT_INFO_RATE || - struct_type == FAULT_INFO_TYPE) - return (unsigned char *)&F2FS_OPTION(sbi).fault_info; -#endif #ifdef CONFIG_F2FS_STAT_FS else if (struct_type == STAT_INFO) return (unsigned char *)F2FS_STAT(sbi);@@ -429,12 +420,6 @@ static ssize_t __sbi_store(struct f2fs_attr *a, ret =kstrtoul (skip_spaces (buf),0 , &t);if (ret <0 )return ret; -#ifdef CONFIG_F2FS_FAULT_INJECTION -if (a->struct_type ==FAULT_INFO_TYPE && t >= (1 <<FAULT_MAX )) -return -EINVAL ; -if (a->struct_type ==FAULT_INFO_RATE && t >=UINT_MAX ) -return -EINVAL ; -#endif if (a->struct_type ==RESERVED_BLOCKS ) {spin_lock (&sbi->stat_lock); if (t > (unsigned long)(sbi->user_block_count -@@ -773,10 +758,6 @@ F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, readdir_ra, readdir_ra);F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info, max_io_bytes, max_io_bytes);F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info, gc_pin_file_thresh, gc_pin_file_threshold);F2FS_RW_ATTR (F2FS_SBI , f2fs_super_block, extension_list, extension_list); -#ifdef CONFIG_F2FS_FAULT_INJECTION -F2FS_RW_ATTR (FAULT_INFO_RATE , f2fs_fault_info, inject_rate, inject_rate); -F2FS_RW_ATTR (FAULT_INFO_TYPE , f2fs_fault_info, inject_type, inject_type); -#endif F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info, data_io_flag, data_io_flag);F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info, node_io_flag, node_io_flag);F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info, gc_urgent_high_remaining, gc_urgent_high_remaining);@@ -892,10 +873,6 @@ static struct attribute *f2fs_attrs[] = {ATTR_LIST (max_io_bytes),ATTR_LIST (gc_pin_file_thresh),ATTR_LIST (extension_list), -#ifdef CONFIG_F2FS_FAULT_INJECTION -ATTR_LIST (inject_rate), -ATTR_LIST (inject_type), -#endifATTR_LIST (data_io_flag),ATTR_LIST (node_io_flag), ATTR_LIST(gc_urgent_high_remaining),
Re: [f2fs-dev] [PATCH 4/5] f2fs: get rid of stale fault injection code
Hi,
Quoted 12 lines · Chao Yu
Quoted 11 lines · On 2022/4/1 15:19, Yufen Yu via Linux-f2fs-devel wrote:
Nowly, we can use new fault injection framework. Just delete the stale fault injection code.
Signed-off-by Yufen Yu <[email protected]>---
fs/f2fs/checkpoint.c| 2 +-
fs/f2fs/f2fs.h | 51 ++---------------------------------------- fs/f2fs/super.c | 53 -------------------------------------------- fs/f2fs/sysfs.c | 23 -------------------4 files changed, 3 insertions(+), 126 deletions(-)
...
Quoted 8 lines
Quoted 8 lines
break;
fs/f2fs/super.c +0
-3@@ -1963,14 +1920,6 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root) if (F2FS_IO_SIZE_BITS(sbi)) seq_printf(seq, ",io_bits=%u", F2FS_OPTION(sbi).write_io_size_bits); -#ifdef CONFIG_F2FS_FAULT_INJECTION - if (test_opt(sbi, FAULT_INJECTION)) { - seq_printf(seq, ",fault_injection=%u",
Quoted 8 lines
fs/f2fs/super.c static int f2fs_show_options(struct seq_file *seq, struct dentry *root) · line 1973
Quoted 5 lines
fs/f2fs/super.c +0
-5- F2FS_OPTION(sbi).fault_info.inject_rate); - seq_printf(seq, ",fault_type=%u", - F2FS_OPTION(sbi).fault_info.inject_type); - } -#endif This will cause regression due to it breaks application usage w/ -o fault_* mountoption..., I don't think this is the right way.
Thanks for catching this. I admit it's a problem. But, IMO fault_* mount option are mostly been used in test, not in actual product. So, I think it may just affect some test applications. With the common fault injection framework, it can be more easy and flexible to do fault injection test. Therefore, I want to remove the two mount options directly.
If you really worried about compatibility, how about just reserving the two inject_* options but without doing any thing for them. We actually configure fault injections by debugfs in this patch.
Or do you have more better suggestion?
Thanks,
Yufen
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Chao Yu
maintainerRe: [f2fs-dev] [PATCH 4/5] f2fs: get rid of stale fault injection code
Quoted 42 lines · On 2022/4/6 11:01, Yufen Yu via Linux-f2fs-devel wrote:
Hi,
Quoted 12 lines · Chao Yu
Quoted 11 lines · On 2022/4/1 15:19, Yufen Yu via Linux-f2fs-devel wrote:
Nowly, we can use new fault injection framework. Just delete the stale fault injection code.
Signed-off-by Yufen Yu <[email protected]>---
fs/f2fs/checkpoint.c| 2 +-
fs/f2fs/f2fs.h | 51 ++---------------------------------------- fs/f2fs/super.c | 53 -------------------------------------------- fs/f2fs/sysfs.c | 23 -------------------4 files changed, 3 insertions(+), 126 deletions(-)...
Quoted 8 lines
Quoted 8 lines
break;
fs/f2fs/super.c +0
-3@@ -1963,14 +1920,6 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root) if (F2FS_IO_SIZE_BITS(sbi)) seq_printf(seq, ",io_bits=%u", F2FS_OPTION(sbi).write_io_size_bits); -#ifdef CONFIG_F2FS_FAULT_INJECTION - if (test_opt(sbi, FAULT_INJECTION)) { - seq_printf(seq, ",fault_injection=%u",Quoted 8 lines
fs/f2fs/super.c static int f2fs_show_options(struct seq_file *seq, struct dentry *root) · line 1973
Quoted 5 lines
fs/f2fs/super.c +0
-5- F2FS_OPTION(sbi).fault_info.inject_rate); - seq_printf(seq, ",fault_type=%u", - F2FS_OPTION(sbi).fault_info.inject_type); - } -#endif This will cause regression due to it breaks application usage w/ -o fault_* mountoption..., I don't think this is the right way.
Thanks for catching this. I admit it's a problem. But, IMO fault_* mount option are mostly been used in test, not in actual product. So, I think it may just affect some test applications. With the common fault injection framework, it can be more easy and flexible to do fault injection test. Therefore, I want to remove the two mount options directly.
Quoted 5 lines
If you really worried about compatibility, how about just reserving the two inject_* options but without doing any thing for them. We actually configure fault injections by debugfs in this patch.
Or do you have more better suggestion?
Could you please consider to keep original logic of f2fs fault injection if user use inject_* options, otherwise following common fault injection framework?
Thoughts?
Thanks,
Quoted 11 lines
Thanks,
Yufen
Quoted 4 lines
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Jaegeuk Kim
maintainerRe: [f2fs-dev] [PATCH 4/5] f2fs: get rid of stale fault injection code
Quoted 47 lines · Chao Yu
Quoted 46 lines · On 2022/4/6 11:01, Yufen Yu via Linux-f2fs-devel wrote:
Hi,
Quoted 12 lines · Chao Yu
Quoted 11 lines · On 2022/4/1 15:19, Yufen Yu via Linux-f2fs-devel wrote:
Nowly, we can use new fault injection framework. Just delete the stale fault injection code.
Signed-off-by Yufen Yu <[email protected]>---
fs/f2fs/checkpoint.c| 2 +-
fs/f2fs/f2fs.h | 51 ++---------------------------------------- fs/f2fs/super.c | 53 -------------------------------------------- fs/f2fs/sysfs.c | 23 -------------------4 files changed, 3 insertions(+), 126 deletions(-)...
Quoted 8 lines
Quoted 8 lines
break;
fs/f2fs/super.c +0
-3@@ -1963,14 +1920,6 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root) if (F2FS_IO_SIZE_BITS(sbi)) seq_printf(seq, ",io_bits=%u", F2FS_OPTION(sbi).write_io_size_bits); -#ifdef CONFIG_F2FS_FAULT_INJECTION - if (test_opt(sbi, FAULT_INJECTION)) { - seq_printf(seq, ",fault_injection=%u",Quoted 8 lines
fs/f2fs/super.c static int f2fs_show_options(struct seq_file *seq, struct dentry *root) · line 1973
Quoted 5 lines
fs/f2fs/super.c +0
-5- F2FS_OPTION(sbi).fault_info.inject_rate); - seq_printf(seq, ",fault_type=%u", - F2FS_OPTION(sbi).fault_info.inject_type); - } -#endif This will cause regression due to it breaks application usage w/ -o fault_* mountoption..., I don't think this is the right way.
Thanks for catching this. I admit it's a problem. But, IMO fault_* mount option are mostly been used in test, not in actual product. So, I think it may just affect some test applications. With the common fault injection framework, it can be more easy and flexible to do fault injection test. Therefore, I want to remove the two mount options directly.
If you really worried about compatibility, how about just reserving the two inject_* options but without doing any thing for them. We actually configure fault injections by debugfs in this patch.
Quoted 7 lines
Quoted 1 line
Or do you have more better suggestion?
Could you please consider to keep original logic of f2fs fault injection if user use inject_* options, otherwise following common fault injection framework?
Thoughts?
I think it'd be useful to test roll-forward recovery flow by using those mount options, since runtime fault injection cannot enable it during mount.
BTW, what is the real benefit to use the fault injection framework?
Quoted 18 lines
Thanks,
Quoted 15 lines
Thanks,
Yufen_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH 4/5] f2fs: get rid of stale fault injection code
Quoted 50 lines · Jaegeuk Kim
Quoted 49 lines · Chao Yu
Quoted 47 lines · On 2022/4/6 11:01, Yufen Yu via Linux-f2fs-devel wrote:
Hi,
Quoted 12 lines · Chao Yu
Quoted 11 lines · On 2022/4/1 15:19, Yufen Yu via Linux-f2fs-devel wrote:
Nowly, we can use new fault injection framework. Just delete the stale fault injection code.
Signed-off-by Yufen Yu <[email protected]>--- fs/f2fs/checkpoint.c | 2 +- fs/f2fs/f2fs.h | 51 ++---------------------------------------- fs/f2fs/super.c | 53 -------------------------------------------- fs/f2fs/sysfs.c | 23 ------------------- 4 files changed, 3 insertions(+), 126 deletions(-)...
Quoted 8 lines
Quoted 8 lines
break;
fs/f2fs/super.c +0
-3@@ -1963,14 +1920,6 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root) if (F2FS_IO_SIZE_BITS(sbi)) seq_printf(seq, ",io_bits=%u", F2FS_OPTION(sbi).write_io_size_bits); -#ifdef CONFIG_F2FS_FAULT_INJECTION - if (test_opt(sbi, FAULT_INJECTION)) { - seq_printf(seq, ",fault_injection=%u",Quoted 8 lines
fs/f2fs/super.c static int f2fs_show_options(struct seq_file *seq, struct dentry *root) · line 1973
Quoted 5 lines
fs/f2fs/super.c +0
-5- F2FS_OPTION(sbi).fault_info.inject_rate); - seq_printf(seq, ",fault_type=%u", - F2FS_OPTION(sbi).fault_info.inject_type); - } -#endif This will cause regression due to it breaks application usage w/ -o fault_* mountoption..., I don't think this is the right way.
Thanks for catching this. I admit it's a problem. But, IMO fault_* mount option are mostly been used in test, not in actual product. So, I think it may just affect some test applications. With the common fault injection framework, it can be more easy and flexible to do fault injection test. Therefore, I want to remove the two mount options directly.
If you really worried about compatibility, how about just reserving the two inject_* options but without doing any thing for them. We actually configure fault injections by debugfs in this patch.
Or do you have more better suggestion?
Quoted 9 lines
Quoted 5 lines
Could you please consider to keep original logic of f2fs fault injection if user use inject_* options, otherwise following common fault injection framework?
Thoughts?
I think it'd be useful to test roll-forward recovery flow by using those mount options, since runtime fault injection cannot enable it during mount.
Yeah, I have not catch this point before.
Quoted 2 lines
BTW, what is the real benefit to use the fault injection framework?
I think fault injection framework can provide more easier and flexible function than the current one. Furthermore, we can just following it and don't need to maintain f2fs own fault injection cold.
Thanks,
Yufen
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Chao Yu
maintainerRe: [f2fs-dev] [PATCH 4/5] f2fs: get rid of stale fault injection code
Quoted 63 lines · On 2022/4/12 19:04, Yufen Yu via Linux-f2fs-devel wrote:
Quoted 50 lines · Jaegeuk Kim
Quoted 49 lines · Chao Yu
Quoted 47 lines · On 2022/4/6 11:01, Yufen Yu via Linux-f2fs-devel wrote:
Hi,
Quoted 12 lines · Chao Yu
Quoted 11 lines · On 2022/4/1 15:19, Yufen Yu via Linux-f2fs-devel wrote:
Nowly, we can use new fault injection framework. Just delete the stale fault injection code.
Signed-off-by Yufen Yu <[email protected]>---
fs/f2fs/checkpoint.c| 2 +-
fs/f2fs/f2fs.h | 51 ++---------------------------------------- fs/f2fs/super.c | 53 -------------------------------------------- fs/f2fs/sysfs.c | 23 -------------------4 files changed, 3 insertions(+), 126 deletions(-)...
Quoted 8 lines
Quoted 8 lines
break;
fs/f2fs/super.c +0
-3@@ -1963,14 +1920,6 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root) if (F2FS_IO_SIZE_BITS(sbi)) seq_printf(seq, ",io_bits=%u", F2FS_OPTION(sbi).write_io_size_bits); -#ifdef CONFIG_F2FS_FAULT_INJECTION - if (test_opt(sbi, FAULT_INJECTION)) { - seq_printf(seq, ",fault_injection=%u",Quoted 8 lines
fs/f2fs/super.c static int f2fs_show_options(struct seq_file *seq, struct dentry *root) · line 1973
Quoted 5 lines
fs/f2fs/super.c +0
-5- F2FS_OPTION(sbi).fault_info.inject_rate); - seq_printf(seq, ",fault_type=%u", - F2FS_OPTION(sbi).fault_info.inject_type); - } -#endif This will cause regression due to it breaks application usage w/ -o fault_* mountoption..., I don't think this is the right way.
Thanks for catching this. I admit it's a problem. But, IMO fault_* mount option are mostly been used in test, not in actual product. So, I think it may just affect some test applications. With the common fault injection framework, it can be more easy and flexible to do fault injection test. Therefore, I want to remove the two mount options directly.
If you really worried about compatibility, how about just reserving the two inject_* options but without doing any thing for them. We actually configure fault injections by debugfs in this patch.
Or do you have more better suggestion?
Quoted 9 lines
Quoted 5 lines
Could you please consider to keep original logic of f2fs fault injection if user use inject_* options, otherwise following common fault injection framework?
Thoughts?
I think it'd be useful to test roll-forward recovery flow by using those mount options, since runtime fault injection cannot enable it during mount.
Quoted 8 lines
Yeah, I have not catch this point before.
Quoted 2 lines
BTW, what is the real benefit to use the fault injection framework?
I think fault injection framework can provide more easier and flexible function than the current one. Furthermore, we can just following it and don't need to maintain f2fs own fault injection cold.
Yufen,
As Jaegeuk mentioned, it needs to keep original f2fs fault injection framework code in order to cover test during mount(). IIUC.
IMO, one way to add this framework is making those two framework compatible, but before that, could you please explain the details of benefit for adapting the common framework?
Thanks,
Quoted 9 lines
Thanks,
Yufen_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
PATCH 5/5 f2fs: update doc for f2fs fault injection
In reply to Yufen YuJust update doc for fault injection.
--- Documentation/filesystems/f2fs.rst | 118 ++++++++++++++++++++++------- 1 file changed, 90 insertions(+), 28 deletions(-)
Documentation/filesystems/f2fs.rst +90 -28
@@ -172,34 +172,6 @@ reserve_root=%d Support configuring reserved space which is used for gid, unit: 4KB, the default limit is 0.2% of user blocks. resuid=%d The user ID which may use the reserved blocks. resgid=%d The group ID which may use the reserved blocks. -fault_injection=%d Enable fault injection in all supported types with - specified injection rate. -fault_type=%d Support configuring fault injection type, should be - enabled with fault_injection option, fault type value - is shown below, it supports single or combined type. - - =================== =========== - Type_Name Type_Value - =================== =========== - FAULT_KMALLOC 0x000000001 - FAULT_KVMALLOC 0x000000002 - FAULT_PAGE_ALLOC 0x000000004 - FAULT_PAGE_GET 0x000000008 - FAULT_ALLOC_BIO 0x000000010 (obsolete) - FAULT_ALLOC_NID 0x000000020 - FAULT_ORPHAN 0x000000040 - FAULT_BLOCK 0x000000080 - FAULT_DIR_DEPTH 0x000000100 - FAULT_EVICT_INODE 0x000000200 - FAULT_TRUNCATE 0x000000400 - FAULT_READ_IO 0x000000800 - FAULT_CHECKPOINT 0x000001000 - FAULT_DISCARD 0x000002000 - FAULT_WRITE_IO 0x000004000 - FAULT_SLAB_ALLOC 0x000008000 - FAULT_DQUOT_INIT 0x000010000 - FAULT_LOCK_OP 0x000020000 - =================== =========== mode=%s Control block allocation mode which supports "adaptive" and "lfs". In "lfs" mode, there should be no random writes towards main area.
@@ -367,6 +339,96 @@ The files in each per-device directory are shown in table below. Files in /sys/fs/f2fs/<devname> (see also Documentation/ABI/testing/sysfs-fs-f2fs) +Fault Injection +============= +/sys/kernel/debug/f2fs/<devname>/fault_inject contains fault_inject control. + +Support configuring fault injection type by writing value to +/sys/kernel/debug/f2fs/<devname>/fault_inject/inject_type. +The values are shown below. They support single or combined type. + + =================== =========== + Type_Name Type_Value + =================== =========== + FAULT_KMALLOC 0x000000001 + FAULT_KVMALLOC 0x000000002 + FAULT_PAGE_ALLOC 0x000000004 + FAULT_PAGE_GET 0x000000008 + FAULT_ALLOC_BIO 0x000000010 (obsolete) + FAULT_ALLOC_NID 0x000000020 + FAULT_ORPHAN 0x000000040 + FAULT_BLOCK 0x000000080 + FAULT_DIR_DEPTH 0x000000100 + FAULT_EVICT_INODE 0x000000200 + FAULT_TRUNCATE 0x000000400 + FAULT_READ_IO 0x000000800 + FAULT_CHECKPOINT 0x000001000 + FAULT_DISCARD 0x000002000 + FAULT_WRITE_IO 0x000004000 + FAULT_SLAB_ALLOC 0x000008000 + FAULT_DQUOT_INIT 0x000010000 + FAULT_LOCK_OP 0x000020000 + =================== =========== + +Example: Inject write io fail +--------------------------------------------------- + +:: + + mount /dev/sda /mnt + echo 0x000000800 > /sys/kernel/debug/f2fs/sda/fault_inject/inject_type + echo 1 > /sys/kernel/debug/f2fs/sda/fault_inject/times + echo 100 > /sys/kernel/debug/f2fs/sda/fault_inject/probability + cp /mnt/file . + +Expected Result:: + + cat: /mnt/file: Input/output error + +Message from dmesg:: + + FAULT_INJECTION: forcing a failure. + name fault_inject, interval 1, probability 100, space 0, times 1 + CPU: 30 PID: 0 Comm: swapper/30 Not tainted 5.17.0-rc8 #6 + Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS ?-20190727_073836-build + Call Trace: + <IRQ> + ? dump_stack_lvl+0x73/0x9f + ? dump_stack+0x13/0x1b + ? should_fail.cold+0x4a/0x57 + ? f2fs_should_fail+0x3e/0x60 + ? f2fs_read_end_io+0x94/0x230 + ? bio_endio+0x15d/0x2d0 + ? blk_update_request+0x188/0x5b0 + ? kfree+0x138/0x4a0 + ? scsi_end_request+0x2f/0x230 + ? scsi_io_completion+0x86/0x9a0 + ? scsi_dec_host_busy+0xc6/0xe0 + ? scsi_finish_command+0xf0/0x160 + ? scsi_complete+0x9f/0x160 + ? blk_complete_reqs+0x5a/0x70 + ? blk_done_softirq+0x34/0x40 + ? __do_softirq+0x14f/0x4ef + ? irq_exit_rcu+0x1a7/0x210 + ? common_interrupt+0xa4/0xc0 + </IRQ> + <TASK> + ? asm_common_interrupt+0x1e/0x40 + ? default_idle+0x38/0x50 + ? arch_cpu_idle+0x13/0x20 + ? default_idle_call+0x82/0x270 + ? do_idle+0x37c/0x4a0 + ? swake_up_locked+0x38/0x80 + ? _raw_spin_unlock_irqrestore+0x4b/0x90 + ? cpu_startup_entry+0x31/0x40 + ? start_secondary+0x222/0x280 + ? secondary_startup_64_no_verify+0xc3/0xcb + </TASK> + F2FS-fs (sda) : inject read IO error in f2fs_read_end_io of bio_endio+0x15d/0x2d0 + +Files in /sys/kernel/debug/f2fs/<devname>/fault_inject +(see also Documentation/fault-injection/fault-injection.rst) + Usage =====
Signature · 8 lines
2.31.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel