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>
(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);