]> git.ipfire.org Git - thirdparty/linux.git/commit
ntfs3: fix mount failure on volumes with fragmented MFT bitmap
authorKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
Tue, 31 Mar 2026 18:20:04 +0000 (20:20 +0200)
committerKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
Tue, 7 Apr 2026 16:43:37 +0000 (18:43 +0200)
commit6d979b64287fb051642fe0101f28c839be8ca837
tree0d3d5a2f99cd4ff81de34f36b17f714e43afd5b1
parentbb82fe0872de867f87fd4f64c9cb157903ac78db
ntfs3: fix mount failure on volumes with fragmented MFT bitmap

When the $MFT's $BITMAP attribute is fragmented across multiple MFT
records (base record + extent records), ntfs_fill_super() fails with
-ENOENT during wnd_init() because the MFT bitmap's run list only
contains runs from the base MFT record.

The issue is that wnd_init() (which calls wnd_rescan()) is invoked
before ni_load_all_mi(), so the extent MFT records containing
additional $BITMAP runs have not been loaded yet. When wnd_rescan()
tries to look up a VCN beyond the base record's runs, run_lookup_entry()
fails and returns -ENOENT.

This affects NTFS volumes with a large or heavily fragmented MFT, which
is common on long-used Windows systems where the MFT bitmap's run list
doesn't fit in the base MFT record and spills into extent records.

Fix this by:
1. Moving ni_load_all_mi() before wnd_init() so all extent records
   are available.
2. After ni_load_all_mi(), iterating through the attribute list to
   find any $BITMAP extent attributes and unpacking their runs into
   sbi->mft.bitmap.run before wnd_init() is called.

Tested on a 664GB NTFS volume with 86 MFT bitmap runs spanning
records 0 (VCN 0-105) and 17 (VCN 106-165). Before the fix, mount
fails with -ENOENT. After the fix, mount succeeds and all read/write
operations work correctly. Stress-tested with 8 test categories
(large file integrity, 10K small files, copy, move, delete/recreate
cycles, concurrent writes, deep directories, overwrite persistence).

Signed-off-by: Ruslan Elishev <relishev@gmail.com>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
fs/ntfs3/super.c