f2fs: fix wrong error injection for evict_inode
Subsystems (2)
Jaegeuk Kim
maintainerPATCH 1/4 f2fs: fix wrong error injection for evict_inode
The previous one was not a proper location to inject an error, since there is no point to get errors. Instead, we can emulate EIO during truncation, and the below logic should handle it correctly.
--- fs/f2fs/inode.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
fs/f2fs/inode.c +6 -7
@@ -372,13 +372,6 @@ void f2fs_evict_inode(struct inode *inode)if (inode->i_nlink ||is_bad_inode (inode)) goto no_delete; -#ifdef CONFIG_F2FS_FAULT_INJECTION -if (time_to_inject (sbi,FAULT_EVICT_INODE )) { -f2fs_show_injection_info (FAULT_EVICT_INODE ); - goto no_delete; - } -#endif -remove_ino_entry (sbi, inode->i_ino,APPEND_INO );remove_ino_entry (sbi, inode->i_ino,UPDATE_INO );
@@ -389,6 +382,12 @@ void f2fs_evict_inode(struct inode *inode)if (F2FS_HAS_BLOCKS (inode)) err =f2fs_truncate (inode); +#ifdef CONFIG_F2FS_FAULT_INJECTION +if (time_to_inject (sbi,FAULT_EVICT_INODE )) { +f2fs_show_injection_info (FAULT_EVICT_INODE ); + err = -EIO ; + } +#endif if (!err) {f2fs_lock_op (sbi); err =remove_inode_page (inode);
Signature · 9 lines
2.11.0 ------------------------------------------------------------------------------ Announcing the Oxford Dictionaries API! The API offers world-renowned dictionary content that is easy and intuitive to access. Sign up for an account today to start using our lexical data to power your apps and projects. Get started today and enter our developer competition. http://sdm.link/oxford
Jaegeuk Kim
maintainerPATCH 2/4 f2fs: build stat_info before orphan inode recovery
f2fs_sync_fs() -> write_checkpoint() calls stat_inc_cp_count(sbi->stat_info), which needs stat_info allocation.
Otherwise, we can hit:
[254042.598623] ? count_shadow_nodes+0xa0/0xa0 [254042.598633] f2fs_sync_fs+0x65/0xd0 [f2fs] [254042.598645] f2fs_balance_fs_bg+0xe4/0x1c0 [f2fs] [254042.598657] f2fs_write_node_pages+0x34/0x1a0 [f2fs] [254042.598664] ? pagevec_lookup_entries+0x1e/0x30 [254042.598673] do_writepages+0x1e/0x30 [254042.598682] __writeback_single_inode+0x45/0x330 [254042.598688] writeback_single_inode+0xd7/0x190 [254042.598694] write_inode_now+0x86/0xa0 [254042.598699] iput+0x122/0x200 [254042.598709] f2fs_fill_super+0xd4a/0x14d0 [f2fs] [254042.598717] mount_bdev+0x184/0x1c0 [254042.598934] ? f2fs_commit_super+0x100/0x100 [f2fs] [254042.599142] f2fs_mount+0x15/0x20 [f2fs] [254042.599349] mount_fs+0x39/0x160 [254042.599554] ? __alloc_percpu+0x15/0x20 [254042.599759] vfs_kern_mount+0x67/0x110 [254042.599972] do_mount+0x1bb/0xc80 [254042.600175] ? memdup_user+0x42/0x60 [254042.600380] SyS_mount+0x83/0xd0 [254042.600583] entry_SYSCALL_64_fastpath+0x1e/0xad
--- fs/f2fs/super.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
fs/f2fs/super.c +5 -5
@@ -2022,6 +2022,10 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)f2fs_join_shrinker (sbi); + err =f2fs_build_stats (sbi); +if (err) + goto free_nm; +/* if there are nt orphan nodes free them */ err =recover_orphan_inodes (sbi);if (err)
@@ -2046,10 +2050,6 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) goto free_root_inode; } - err =f2fs_build_stats (sbi); -if (err) - goto free_root_inode; -if (f2fs_proc_root) sbi->s_proc =proc_mkdir (sb->s_id, f2fs_proc_root);
@@ -2143,7 +2143,6 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)remove_proc_entry ("segment_bits" , sbi->s_proc);remove_proc_entry (sb->s_id, f2fs_proc_root); } -f2fs_destroy_stats (sbi); free_root_inode:dput (sb->s_root); sb->s_root =NULL ;
@@ -2161,6 +2160,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)truncate_inode_pages_final (META_MAPPING (sbi));iput (sbi->node_inode);mutex_unlock (&sbi->umount_mutex); +f2fs_destroy_stats (sbi); free_nm:destroy_node_manager (sbi); free_sm:
Signature · 9 lines
2.11.0 ------------------------------------------------------------------------------ Announcing the Oxford Dictionaries API! The API offers world-renowned dictionary content that is easy and intuitive to access. Sign up for an account today to start using our lexical data to power your apps and projects. Get started today and enter our developer competition. http://sdm.link/oxford
Re: [f2fs-dev] [PATCH 2/4] f2fs: build stat_info before orphan inode recovery
Quoted 36 lines · Jaegeuk Kim
f2fs_sync_fs()->write_checkpoint()callsstat_inc_cp_count(sbi->stat_info), which needsstat_infoallocation.
Otherwise, we can hit:[254042.598623] ? count_shadow_nodes+0xa0/0xa0 [254042.598633] f2fs_sync_fs+0x65/0xd0 [f2fs] [254042.598645] f2fs_balance_fs_bg+0xe4/0x1c0 [f2fs] [254042.598657] f2fs_write_node_pages+0x34/0x1a0 [f2fs] [254042.598664] ? pagevec_lookup_entries+0x1e/0x30 [254042.598673] do_writepages+0x1e/0x30 [254042.598682] __writeback_single_inode+0x45/0x330 [254042.598688] writeback_single_inode+0xd7/0x190 [254042.598694] write_inode_now+0x86/0xa0 [254042.598699] iput+0x122/0x200 [254042.598709] f2fs_fill_super+0xd4a/0x14d0 [f2fs] [254042.598717] mount_bdev+0x184/0x1c0 [254042.598934] ? f2fs_commit_super+0x100/0x100 [f2fs] [254042.599142] f2fs_mount+0x15/0x20 [f2fs] [254042.599349] mount_fs+0x39/0x160 [254042.599554] ? __alloc_percpu+0x15/0x20 [254042.599759] vfs_kern_mount+0x67/0x110 [254042.599972] do_mount+0x1bb/0xc80 [254042.600175] ? memdup_user+0x42/0x60 [254042.600380] SyS_mount+0x83/0xd0 [254042.600583] entry_SYSCALL_64_fastpath+0x1e/0xadSigned-off-by Jaegeuk Kim <[email protected]>--- fs/f2fs/super.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)fs/f2fs/super.c +0
-0
fs/f2fs/super.c static int f2fs_fill_super(struct super_block *sb, void *data, int silent) · line 2027
Quoted 6 lines
fs/f2fs/super.c +3
-0@@ -2022,6 +2022,10 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)f2fs_join_shrinker (sbi); + err =f2fs_build_stats (sbi); +if (err) + goto free_nm;
Both node_inode and shrinker need to be released and detached.
How about relocate f2fs_build_stats in front of build_segment_manager?
Thanks,
Quoted 32 lines
fs/f2fs/super.c +2
-5+/* if there are nt orphan nodes free them */ err =recover_orphan_inodes (sbi);if (err)@@ -2046,10 +2050,6 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) goto free_root_inode; } - err =f2fs_build_stats (sbi); -if (err) - goto free_root_inode; -if (f2fs_proc_root) sbi->s_proc =proc_mkdir (sb->s_id, f2fs_proc_root);@@ -2143,7 +2143,6 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)remove_proc_entry ("segment_bits" , sbi->s_proc);remove_proc_entry (sb->s_id, f2fs_proc_root); } -f2fs_destroy_stats (sbi); free_root_inode:dput (sb->s_root); sb->s_root =NULL ;@@ -2161,6 +2160,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)truncate_inode_pages_final (META_MAPPING (sbi));iput (sbi->node_inode);mutex_unlock (&sbi->umount_mutex); +f2fs_destroy_stats (sbi); free_nm:destroy_node_manager (sbi); free_sm:
Jaegeuk Kim
maintainerRe: [f2fs-dev] [PATCH 2/4] f2fs: build stat_info before orphan inode recovery
Quoted 40 lines · Chao Yu
Quoted 39 lines · Jaegeuk Kim
f2fs_sync_fs()->write_checkpoint()callsstat_inc_cp_count(sbi->stat_info), which needsstat_infoallocation.
Otherwise, we can hit:[254042.598623] ? count_shadow_nodes+0xa0/0xa0 [254042.598633] f2fs_sync_fs+0x65/0xd0 [f2fs] [254042.598645] f2fs_balance_fs_bg+0xe4/0x1c0 [f2fs] [254042.598657] f2fs_write_node_pages+0x34/0x1a0 [f2fs] [254042.598664] ? pagevec_lookup_entries+0x1e/0x30 [254042.598673] do_writepages+0x1e/0x30 [254042.598682] __writeback_single_inode+0x45/0x330 [254042.598688] writeback_single_inode+0xd7/0x190 [254042.598694] write_inode_now+0x86/0xa0 [254042.598699] iput+0x122/0x200 [254042.598709] f2fs_fill_super+0xd4a/0x14d0 [f2fs] [254042.598717] mount_bdev+0x184/0x1c0 [254042.598934] ? f2fs_commit_super+0x100/0x100 [f2fs] [254042.599142] f2fs_mount+0x15/0x20 [f2fs] [254042.599349] mount_fs+0x39/0x160 [254042.599554] ? __alloc_percpu+0x15/0x20 [254042.599759] vfs_kern_mount+0x67/0x110 [254042.599972] do_mount+0x1bb/0xc80 [254042.600175] ? memdup_user+0x42/0x60 [254042.600380] SyS_mount+0x83/0xd0 [254042.600583] entry_SYSCALL_64_fastpath+0x1e/0xadSigned-off-by Jaegeuk Kim <[email protected]>--- fs/f2fs/super.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)fs/f2fs/super.c +0
-0@@ -2022,6 +2022,10 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)f2fs_join_shrinker (sbi);
Quoted 7 lines
fs/f2fs/super.c static int f2fs_fill_super(struct super_block *sb, void *data, int silent) · line 2027
Quoted 3 lines
fs/f2fs/super.c +3
-0+ err =f2fs_build_stats (sbi); +if (err) + goto free_nm;Both
node_inodeand shrinker need to be released and detached.How about relocate
f2fs_build_statsin front ofbuild_segment_manager?
I just got another panic to try this, since sys/../f2fs/status needs them.
Thanks,
Quoted 35 lines
Thanks,
Quoted 32 lines
fs/f2fs/super.c +2
-5+/* if there are nt orphan nodes free them */ err =recover_orphan_inodes (sbi);if (err)@@ -2046,10 +2050,6 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) goto free_root_inode; } - err =f2fs_build_stats (sbi); -if (err) - goto free_root_inode; -if (f2fs_proc_root) sbi->s_proc =proc_mkdir (sb->s_id, f2fs_proc_root);@@ -2143,7 +2143,6 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)remove_proc_entry ("segment_bits" , sbi->s_proc);remove_proc_entry (sb->s_id, f2fs_proc_root); } -f2fs_destroy_stats (sbi); free_root_inode:dput (sb->s_root); sb->s_root =NULL ;@@ -2161,6 +2160,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)truncate_inode_pages_final (META_MAPPING (sbi));iput (sbi->node_inode);mutex_unlock (&sbi->umount_mutex); +f2fs_destroy_stats (sbi); free_nm:destroy_node_manager (sbi); free_sm:
Jaegeuk Kim
maintainerRe: [PATCH 2/4 v2] f2fs: build stat_info before orphan inode recovery
In reply to Jaegeuk KimChange log from v1:
o move its location up more
Quoted 1 line
From
e993253fef6c4a07a65e6038c2c0cae684844047Mon Sep 17 00:00:00 2001
From: Jaegeuk Kim <[email protected]>
Date: Tue, 7 Mar 2017 13:41:22 -0800
Subject: [PATCH] f2fs: build stat_info before orphan inode recovery
f2fs_sync_fs() -> write_checkpoint() calls stat_inc_cp_count(sbi->stat_info), which needs stat_info allocation.
Otherwise, we can hit:
[254042.598623] ? count_shadow_nodes+0xa0/0xa0 [254042.598633] f2fs_sync_fs+0x65/0xd0 [f2fs] [254042.598645] f2fs_balance_fs_bg+0xe4/0x1c0 [f2fs] [254042.598657] f2fs_write_node_pages+0x34/0x1a0 [f2fs] [254042.598664] ? pagevec_lookup_entries+0x1e/0x30 [254042.598673] do_writepages+0x1e/0x30 [254042.598682] __writeback_single_inode+0x45/0x330 [254042.598688] writeback_single_inode+0xd7/0x190 [254042.598694] write_inode_now+0x86/0xa0 [254042.598699] iput+0x122/0x200 [254042.598709] f2fs_fill_super+0xd4a/0x14d0 [f2fs] [254042.598717] mount_bdev+0x184/0x1c0 [254042.598934] ? f2fs_commit_super+0x100/0x100 [f2fs] [254042.599142] f2fs_mount+0x15/0x20 [f2fs] [254042.599349] mount_fs+0x39/0x160 [254042.599554] ? __alloc_percpu+0x15/0x20 [254042.599759] vfs_kern_mount+0x67/0x110 [254042.599972] do_mount+0x1bb/0xc80 [254042.600175] ? memdup_user+0x42/0x60 [254042.600380] SyS_mount+0x83/0xd0 [254042.600583] entry_SYSCALL_64_fastpath+0x1e/0xad
--- fs/f2fs/super.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
fs/f2fs/super.c +8 -8
@@ -789,9 +789,6 @@ static void f2fs_put_super(struct super_block *sb)/* be sure to wait for any on-going discard commands */ f2fs_wait_discard_bio (sbi,NULL_ADDR ); -/* write_checkpoint can update stat informaion */ -f2fs_destroy_stats (sbi); -/* * normally superblock is clean, so we need to release this. * In addition, EIO will skip do checkpoint, we need this as well.
@@ -811,6 +808,9 @@ static void f2fs_put_super(struct super_block *sb)destroy_node_manager (sbi);destroy_segment_manager (sbi); +/* write_checkpoint can update stat informaion */ +f2fs_destroy_stats (sbi); +kfree (sbi->ckpt);kobject_put (&sbi->s_kobj);wait_for_completion (&sbi->s_kobj_unregister);
@@ -1985,6 +1985,10 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)init_ino_entry_info (sbi); + err =f2fs_build_stats (sbi); +if (err) + goto free_devices; +/* setup f2fs internal modules */ err =build_segment_manager (sbi);if (err) {
@@ -2046,10 +2050,6 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) goto free_root_inode; } - err =f2fs_build_stats (sbi); -if (err) - goto free_root_inode; -if (f2fs_proc_root) sbi->s_proc =proc_mkdir (sb->s_id, f2fs_proc_root);
@@ -2143,7 +2143,6 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)remove_proc_entry ("segment_bits" , sbi->s_proc);remove_proc_entry (sb->s_id, f2fs_proc_root); } -f2fs_destroy_stats (sbi); free_root_inode:dput (sb->s_root); sb->s_root =NULL ;
@@ -2165,6 +2164,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)destroy_node_manager (sbi); free_sm:destroy_segment_manager (sbi); +f2fs_destroy_stats (sbi); free_devices:destroy_device_list (sbi);kfree (sbi->ckpt);
Signature · 1 line
2.11.0
Jaegeuk Kim
maintainerPATCH 3/4 f2fs: show more precise message on orphan recovery failure
In reply to Jaegeuk KimThis case is not caused by fsck.f2fs. User needs to retry mount.
--- fs/f2fs/checkpoint.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/checkpoint.c +1 -1
@@ -568,7 +568,7 @@ static int recover_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino)if (ni.blk_addr !=NULL_ADDR ) {set_sbi_flag (sbi,SBI_NEED_FSCK );f2fs_msg (sbi->sb,KERN_WARNING , -"%s: orphan failed (ino=%x), run fsck to fix." , +"%s: orphan failed (ino=%x) by kernel, retry mount." , __func__, ino);return -EIO ; }
Signature · 9 lines
2.11.0 ------------------------------------------------------------------------------ Announcing the Oxford Dictionaries API! The API offers world-renowned dictionary content that is easy and intuitive to access. Sign up for an account today to start using our lexical data to power your apps and projects. Get started today and enter our developer competition. http://sdm.link/oxford
Jaegeuk Kim
maintainerPATCH 4/4 f2fs: use __set{__claer}_bit_le
In reply to Jaegeuk KimThis patch uses __set{__clear}_bit_le for highter speed.
--- fs/f2fs/dir.c | 2 +- fs/f2fs/node.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-)
fs/f2fs/dir.c +1 -1
@@ -750,7 +750,7 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page, dentry_blk =page_address (page); bit_pos = dentry - dentry_blk->dentry;for (i =0 ; i < slots; i++) -clear_bit_le (bit_pos + i, &dentry_blk->dentry_bitmap); +__clear_bit_le (bit_pos + i, &dentry_blk->dentry_bitmap);/* Let's check and deallocate this dentry page */ bit_pos = find_next_bit_le(&dentry_blk->dentry_bitmap,
fs/f2fs/node.c +8 -8
@@ -1825,9 +1825,9 @@ void update_free_nid_bitmap(struct f2fs_sb_info *sbi, nid_t nid,return ;if (set) -set_bit_le (nid_ofs, nm_i->free_nid_bitmap[nat_ofs]); +__set_bit_le (nid_ofs, nm_i->free_nid_bitmap[nat_ofs]);else -clear_bit_le (nid_ofs, nm_i->free_nid_bitmap[nat_ofs]); +__clear_bit_le (nid_ofs, nm_i->free_nid_bitmap[nat_ofs]);spin_lock (&nm_i->free_nid_lock);if (set)
@@ -1849,7 +1849,7 @@ static void scan_nat_page(struct f2fs_sb_info *sbi,if (test_bit_le (nat_ofs, nm_i->nat_block_bitmap))return ; -set_bit_le (nat_ofs, nm_i->nat_block_bitmap); +__set_bit_le (nat_ofs, nm_i->nat_block_bitmap); i = start_nid %NAT_ENTRY_PER_BLOCK ;
@@ -2339,16 +2339,16 @@ void __update_nat_bits(struct f2fs_sb_info *sbi, nid_t start_nid, valid++; }if (valid ==0 ) { -set_bit_le (nat_index, nm_i->empty_nat_bits); -clear_bit_le (nat_index, nm_i->full_nat_bits); +__set_bit_le (nat_index, nm_i->empty_nat_bits); +__clear_bit_le (nat_index, nm_i->full_nat_bits);return ; } -clear_bit_le (nat_index, nm_i->empty_nat_bits); +__clear_bit_le (nat_index, nm_i->empty_nat_bits);if (valid ==NAT_ENTRY_PER_BLOCK ) -set_bit_le (nat_index, nm_i->full_nat_bits); +__set_bit_le (nat_index, nm_i->full_nat_bits);else -clear_bit_le (nat_index, nm_i->full_nat_bits); +__clear_bit_le (nat_index, nm_i->full_nat_bits); } static void __flush_nat_entry_set(struct f2fs_sb_info *sbi,
Signature · 9 lines
2.11.0 ------------------------------------------------------------------------------ Announcing the Oxford Dictionaries API! The API offers world-renowned dictionary content that is easy and intuitive to access. Sign up for an account today to start using our lexical data to power your apps and projects. Get started today and enter our developer competition. http://sdm.link/oxford
Re: [PATCH 4/4] f2fs: use __set{__claer}_bit_le
Quoted 3 lines · Jaegeuk Kim
This patch uses __set{__clear}_bit_le for highter speed.
Signed-off-by Jaegeuk Kim <[email protected]>
------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned dictionary content that is easy and intuitive to access. Sign up for an account today to start using our lexical data to power your apps and projects. Get started today and enter our developer competition.
http://sdm.link/oxford
Hi Jaegeuk,
Quoted 28 lines · Jaegeuk Kim
The previous one was not a proper location to inject an error, since there is no point to get errors. Instead, we can emulate EIO during truncation, and the below logic should handle it correctly.
Signed-off-by Jaegeuk Kim <[email protected]>--- fs/f2fs/inode.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)fs/f2fs/inode.c +0
-7@@ -372,13 +372,6 @@ void f2fs_evict_inode(struct inode *inode)if (inode->i_nlink ||is_bad_inode (inode)) goto no_delete; -#ifdef CONFIG_F2FS_FAULT_INJECTION -if (time_to_inject (sbi,FAULT_EVICT_INODE )) { -f2fs_show_injection_info (FAULT_EVICT_INODE ); - goto no_delete; - } -#endif -remove_ino_entry (sbi, inode->i_ino,APPEND_INO );remove_ino_entry (sbi, inode->i_ino,UPDATE_INO );
fs/f2fs/inode.c void f2fs_evict_inode(struct inode *inode) · line 382
Quoted 1 line
fs/f2fs/inode.c +0
-0@@ -389,6 +382,12 @@ void f2fs_evict_inode(struct inode *inode)if (F2FS_HAS_BLOCKS (inode))
In addition, how about add below code to emulate error came from f2fs_truncate?
if (F2FS_HAS_BLOCKS(inode)) {
#ifdef CONFIG_F2FS_FAULT_INJECTION
if (time_to_inject(sbi, FAULT_EVICT_INODE)) {
f2fs_show_injection_info(FAULT_EVICT_INODE);
err = -EIO;
}
#endif
if (!err)
err = f2fs_truncate(inode);
}Thanks,
Quoted 12 lines
fs/f2fs/inode.c +6
-0err =f2fs_truncate (inode); +#ifdef CONFIG_F2FS_FAULT_INJECTION +if (time_to_inject (sbi,FAULT_EVICT_INODE )) { +f2fs_show_injection_info (FAULT_EVICT_INODE ); + err = -EIO ; + } +#endif if (!err) {f2fs_lock_op (sbi); err =remove_inode_page (inode);