ntfs: wait for the bitmap scan before MFT bitmap extension

If MFT bitmap extension fails before the initial $Bitmap scan completes,
rollback calls ntfs_bitmap_clear_bit(), which holds a folio lock while
ntfs_set_lcn_empty_bits() waits for the scan. The scanner deadlocks if it
still needs that folio.

Wait for the initial scan before taking the runlist or bitmap folio locks
and attempting allocation.

Fixes: 11ccc9107d ("ntfs: update runlist handling and cluster allocator")
Reviewed-by: Baolin Liu <liubaolin@kylinos.cn>
Signed-off-by: Xuewen Wang <wangxuewen@kylinos.cn>
Reviewed-by: Baolin Liu <liubaolin@kylinos.cn>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
This commit is contained in:
Xuewen Wang 2026-09-24 09:45:13 +08:00 committed by Namjae Jeon
parent 4d179eeb91
commit 0c3f2944e9

View File

@ -1352,6 +1352,10 @@ static int ntfs_mft_bitmap_extend_allocation_nolock(struct ntfs_volume *vol)
size_t new_rl_count;
ntfs_debug("Extending mft bitmap allocation.");
/* The initial bitmap scan must finish before we lock or change a folio. */
if (!NVolFreeClusterKnown(vol))
wait_event(vol->free_waitq, NVolFreeClusterKnown(vol));
mft_ni = NTFS_I(vol->mft_ino);
mftbmp_ni = NTFS_I(vol->mftbmp_ino);
/*