]> git.baikalelectronics.ru Git - kernel.git/commit
f2fs: fix indefinite loop scanning for free nid
authorSahitya Tummala <stummala@codeaurora.org>
Tue, 18 Aug 2020 10:10:14 +0000 (15:40 +0530)
committerJaegeuk Kim <jaegeuk@kernel.org>
Wed, 9 Sep 2020 03:31:33 +0000 (20:31 -0700)
commitac3369e7161590a6d43493bdb6cf1a3617b1d920
treefe0bdc148ab4b48033f13d636d16596a84797f46
parent1aa579de235d0a4c60fd8a0e9b2ed8c1f74c41bc
f2fs: fix indefinite loop scanning for free nid

If the sbi->ckpt->next_free_nid is not NAT block aligned and if there
are free nids in that NAT block between the start of the block and
next_free_nid, then those free nids will not be scanned in scan_nat_page().
This results into mismatch between nm_i->available_nids and the sum of
nm_i->free_nid_count of all NAT blocks scanned. And nm_i->available_nids
will always be greater than the sum of free nids in all the blocks.
Under this condition, if we use all the currently scanned free nids,
then it will loop forever in f2fs_alloc_nid() as nm_i->available_nids
is still not zero but nm_i->free_nid_count of that partially scanned
NAT block is zero.

Fix this to align the nm_i->next_scan_nid to the first nid of the
corresponding NAT block.

Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/node.c