resize.f2fs: fix wrong nat_bits migration

When wring the last nat_bits in new checkpoint, we call write_nat_bits()
to recover the nat_bits. But, we didn't update nm_i->nat_bitmap which we can
get the up-to-date nat blocks. After sit migration, old checkpoint has no
longer valid nat blocks, resulting in wrong free nid allocation at the following
mount time.

Let's indicate new nat_blocks by adjusting nat_bitmap in nat migration.

Reported-by: Lianjun Huang <huanglianjun@vivo.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
Jaegeuk Kim 2018-06-16 17:09:23 -07:00
parent 154bf70972
commit 1c15c8d551

View File

@ -339,8 +339,11 @@ static void migrate_nat(struct f2fs_sb_info *sbi,
(seg_off << sbi->log_blocks_per_seg << 1) +
(block_off & ((1 << sbi->log_blocks_per_seg) - 1)));
if (f2fs_test_bit(block_off, nm_i->nat_bitmap))
/* move to set #0 */
if (f2fs_test_bit(block_off, nm_i->nat_bitmap)) {
block_addr += sbi->blocks_per_seg;
f2fs_clear_bit(block_off, nm_i->nat_bitmap);
}
ret = dev_read_block(nat_block, block_addr);
ASSERT(ret >= 0);