]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
f2fs: fix to detect looped node chain correctly
authorChao Yu <yuchao0@huawei.com>
Thu, 5 Jul 2018 11:37:00 +0000 (19:37 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Wed, 1 Aug 2018 18:52:36 +0000 (11:52 -0700)
Below dmesg was printed when testing generic/388 of fstest:

F2FS-fs (zram1): find_fsync_dnodes: detect looped node chain, blkaddr:526615, next:526616
F2FS-fs (zram1): Cannot recover all fsync data errno=-22
F2FS-fs (zram1): Mounted with checkpoint version = 22300d0e
F2FS-fs (zram1): find_fsync_dnodes: detect looped node chain, blkaddr:526615, next:526616
F2FS-fs (zram1): Cannot recover all fsync data errno=-22

The reason is that we initialize free_blocks with free blocks of
filesystem, so if filesystem is full, free_blocks can be zero,
below condition will be true, so that, it will fail recovery.

if (++loop_cnt >= free_blocks ||
blkaddr == next_blkaddr_of_node(page))

To fix this issue, initialize free_blocks with correct value which
includes over-privision blocks.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/recovery.c

index 3051a5e5dfc704a4f368e0e7d1102a408bc810e2..0d927ae26c48e15d5d953ba98246bf1600760248 100644 (file)
@@ -241,8 +241,8 @@ static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head,
        struct page *page = NULL;
        block_t blkaddr;
        unsigned int loop_cnt = 0;
-       unsigned int free_blocks = sbi->user_block_count -
-                                       valid_user_blocks(sbi);
+       unsigned int free_blocks = MAIN_SEGS(sbi) * sbi->blocks_per_seg -
+                                               valid_user_blocks(sbi);
        int err = 0;
 
        /* get node pages in the current segment */