From 0c3f2944e9060c31a221f32906267b827659b0c7 Mon Sep 17 00:00:00 2001 From: Xuewen Wang Date: Thu, 24 Sep 2026 09:45:13 +0800 Subject: [PATCH] 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: 11ccc9107dc4 ("ntfs: update runlist handling and cluster allocator") Reviewed-by: Baolin Liu Signed-off-by: Xuewen Wang Reviewed-by: Baolin Liu Signed-off-by: Namjae Jeon --- fs/ntfs/mft.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/ntfs/mft.c b/fs/ntfs/mft.c index 12666668a80e..489a5935202c 100644 --- a/fs/ntfs/mft.c +++ b/fs/ntfs/mft.c @@ -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); /*