]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
f2fs: fix wrong alloc_type in f2fs_do_replace_block
authorWang Xiaojun <wangxiaojun11@huawei.com>
Thu, 25 Mar 2021 14:19:20 +0000 (10:19 -0400)
committerJaegeuk Kim <jaegeuk@kernel.org>
Fri, 26 Mar 2021 17:27:45 +0000 (10:27 -0700)
If the alloc_type of the original curseg is LFS,
when we change_curseg and then do recover curseg,
the alloc_type becomes SSR.

Signed-off-by: Wang Xiaojun <wangxiaojun11@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/segment.c

index ad48f1f16387735bf1921c2ffe1bb7035e2e93ff..c19114be554ca7325efbf0fe9a961ac4b7db19c9 100644 (file)
@@ -3572,6 +3572,7 @@ void f2fs_do_replace_block(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
        struct seg_entry *se;
        int type;
        unsigned short old_blkoff;
+       unsigned char old_alloc_type;
 
        segno = GET_SEGNO(sbi, new_blkaddr);
        se = get_seg_entry(sbi, segno);
@@ -3605,6 +3606,7 @@ void f2fs_do_replace_block(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
 
        old_cursegno = curseg->segno;
        old_blkoff = curseg->next_blkoff;
+       old_alloc_type = curseg->alloc_type;
 
        /* change the current segment */
        if (segno != curseg->segno) {
@@ -3639,6 +3641,7 @@ void f2fs_do_replace_block(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
                        change_curseg(sbi, type, true);
                }
                curseg->next_blkoff = old_blkoff;
+               curseg->alloc_type = old_alloc_type;
        }
 
        up_write(&sit_i->sentry_lock);