Skip to content

Commit ef2a007

Browse files
chaseyuJaegeuk Kim
authored andcommitted
f2fs: fix to recover cold bit of inode block during POR
Testcase to reproduce this bug: 1. mkfs.f2fs /dev/sdd 2. mount -t f2fs /dev/sdd /mnt/f2fs 3. touch /mnt/f2fs/file 4. sync 5. chattr +A /mnt/f2fs/file 6. xfs_io -f /mnt/f2fs/file -c "fsync" 7. godown /mnt/f2fs 8. umount /mnt/f2fs 9. mount -t f2fs /dev/sdd /mnt/f2fs 10. chattr -A /mnt/f2fs/file 11. xfs_io -f /mnt/f2fs/file -c "fsync" 12. umount /mnt/f2fs 13. mount -t f2fs /dev/sdd /mnt/f2fs 14. lsattr /mnt/f2fs/file -----------------N- /mnt/f2fs/file But actually, we expect the corrct result is: -------A---------N- /mnt/f2fs/file The reason is in step 9) we missed to recover cold bit flag in inode block, so later, in fsync, we will skip write inode block due to below condition check, result in lossing data in another SPOR. f2fs_fsync_node_pages() if (!IS_DNODE(page) || !is_cold_node(page)) continue; Note that, I guess that some non-dir inode has already lost cold bit during POR, so in order to reenable recovery for those inode, let's try to recover cold bit in f2fs_iget() to save more fsynced data. Fixes: c566757 ("f2fs: remove unneeded set_cold_node()") Cc: <stable@vger.kernel.org> 4.17+ Signed-off-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent 48018b4 commit ef2a007

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

‎fs/f2fs/inode.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,12 @@ static int do_read_inode(struct inode *inode)
365365
if (f2fs_has_inline_data(inode) && !f2fs_exist_data(inode))
366366
__recover_inline_status(inode, node_page);
367367

368+
/* try to recover cold bit for non-dir inode */
369+
if (!S_ISDIR(inode->i_mode) && !is_cold_node(node_page)) {
370+
set_cold_node(node_page, false);
371+
set_page_dirty(node_page);
372+
}
373+
368374
/* get rdev by using inline_info */
369375
__get_inode_rdev(inode, ri);
370376

‎fs/f2fs/node.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2549,7 +2549,7 @@ int f2fs_recover_inode_page(struct f2fs_sb_info *sbi, struct page *page)
25492549
if (!PageUptodate(ipage))
25502550
SetPageUptodate(ipage);
25512551
fill_node_footer(ipage, ino, ino, 0, true);
2552-
set_cold_node(page, false);
2552+
set_cold_node(ipage, false);
25532553

25542554
src = F2FS_INODE(page);
25552555
dst = F2FS_INODE(ipage);

0 commit comments

Comments
 (0)