From 0c0eb9b8111596bf3d9a887e4af6d1e5c22f26bd Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Tue, 14 May 2013 15:47:43 +0900 Subject: [PATCH] f2fs: fix inconsistency of block count during recovery Currently f2fs recovers the dentry of fsynced files. When power-off-recovery is conducted, this newly recovered inode should increase node block count as well as inode block count. This patch resolves this inconsistency that results in: 1. create a file 2. write data 3. fsync 4. reboot without sync 5. mount and recover the file 6. node block count is 1 and inode block count is 2 : fall into the inconsistent state 7. unlink the file : trigger the following BUG_ON ------------[ cut here ]------------ kernel BUG at /home/zeus/f2fs_test/src/fs/f2fs/f2fs.h:716! Call Trace: [] ? get_node_page+0x50/0x1a0 [f2fs] [] remove_inode_page+0x8c/0x100 [f2fs] [] ? f2fs_evict_inode+0x180/0x2d0 [f2fs] [] f2fs_evict_inode+0x1be/0x2d0 [f2fs] [] evict+0xa7/0x1a0 [] iput+0x105/0x190 [] d_kill+0xe0/0x120 [] dput+0xe7/0x1e0 [] __fput+0x19d/0x2d0 [] ____fput+0xe/0x10 [] task_work_run+0xb5/0xe0 [] do_notify_resume+0x71/0xb0 [] int_signal+0x12/0x17 Reported-and-Tested-by: Chris Fries Signed-off-by: Jaegeuk Kim --- fs/f2fs/node.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index 3df43b4efd89..96415345a428 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -1492,6 +1492,8 @@ int recover_inode_page(struct f2fs_sb_info *sbi, struct page *page) new_ni = old_ni; new_ni.ino = ino; + if (!inc_valid_node_count(sbi, NULL, 1)) + WARN_ON(1); set_node_addr(sbi, &new_ni, NEW_ADDR); inc_valid_inode_count(sbi); -- 2.39.5