Patches Proposed for Incorrect Free Space and Data Loss in the NTFS Driver Introduced in Linux 7.1
A proposed patch series addresses incorrect free-space accounting and write failures in the NTFS driver introduced in Linux 7.1. It also tackles cases where stale data can be read or newly written data can be lost.
Writes can fail with space still available
An NTFS volume can still have free space when the driver reports that it is full and fails to write a file. On November 30, a Linux kernel developer posted version three of a patch series to address this and related issues. It targets the NTFS driver introduced in Linux 7.1, ntfs, which is separate from ntfs3 and the user-space NTFS-3G driver.
Under a stress test on a 128 MiB NTFS volume, the developer saw reported free space drop from 79 MB to zero within 80 seconds. Some writes returned ENOSPC, indicating a lack of space, or wrote less data than requested.
NTFS kept correct cluster usage information in $Bitmap during the test. The discrepancy was in the driver's accounting for reservations.
The new driver uses deferred allocation to improve write performance. Reserving space first and allocating it later lets the driver allocate several clusters together.
Normally, the driver allocates clusters and releases their reservations when it writes data back from memory to storage. The bug could discard data before writeback while leaving its reservation in place. The patch returns reservations that are no longer needed when a file is truncated.
Losing reservations can also cause problems
The developer also found cases where the driver consumed reservations that were still needed.
NTFS driver introduced in Linux 7.1: Proposed allocation fixes
| Cause | Impact | Proposed fix |
|---|---|---|
| Before writeback, truncating a file can leave a reservation | Free space undercounted Write fails | Release unused reservations |
| Allocation made without a reservation can consume a reservation for another file | At writeback, the disk may appear full | When allocating already reserved space, release the reservation |
| After a failed write, unused reservations can be misclassified as allocated storage | Allocation metadata Corrupted $Bitmap | Fix reservation cleanup Release unused space |
| 128 MiB NTFS stress test | ||
| OS-reported free space: 79 MB → 0 within 80 seconds Failed or partial writes Allocation metadata ($Bitmap) remained correct | ||
Some operations allocate clusters within a file without making a deferred-allocation reservation first. The old code could reduce space reserved for another file's write when carrying out such an allocation.
That can leave too little space at writeback even for writes that passed an earlier capacity check. The proposed change releases reservations only when allocating space that was actually reserved.
Other changes cover failed allocations and file metadata being evicted from memory. The series would also fix a bug in reservation cleanup after a failed write, where the driver could confuse reserved space with allocated clusters and corrupt the on-disk $Bitmap.
Correcting the free-space estimate means keeping space promised to future writes available and releasing reservations that are no longer needed.
Stale data can appear and new data can be lost
The patches also address bugs involving the data itself.
Incomplete writes could leave parts of reused storage uninitialized, potentially exposing stale data. The developer proposed ensuring that unwritten portions are cleared while preserving data already written.
A separate concurrency issue could let the driver act on outdated allocation information and overwrite valid data with zeros. Concurrent access through a shared memory mapping was among the cases discussed.
The proposed fix rechecks whether allocation state has changed before a write continues with an outdated mapping.
NTFS driver introduced in Linux 7.1: Proposed data protection fixes
| Cause | Impact | Proposed fix |
|---|---|---|
| Unwritten storage in a reused cluster after an incomplete write | File data may include stale contents | Keep the data written and clear the unwritten portion |
| Concurrent writes through shared memory mappings Allocation can change | Using stale allocation information can overwrite saved data with zeros | Check allocation state again before continuing to prevent data loss |
Clearing too little can expose older contents. Clearing too much can erase new data. Protecting files depends on knowing exactly which regions need to be zeroed.
Validation and remaining issues
The developer published test materials. Validation covered Ubuntu 26.04 and Arch Linux in QEMU, six cluster sizes from 512 bytes to 64 KiB, and filesystem consistency checks after each test.
The developer reported that eight targeted regression tests passed on a patched development kernel except for part of the checking of reported file block counts. The public CI runs for Ubuntu 26.04 and Arch Linux both failed overall. The developer's claim covers the targeted tests, while those results cover the full runs.
Two of the 11 patches touch iomap, an I/O layer shared by multiple filesystems. The developer tested XFS and ext4 as well and reported no change in which tests passed or failed.
All the patches were marked as candidates for stable kernel backports. The November 30 post also previewed follow-up fixes for block accounting and remaining stale-data issues.
On December 1, a reviewer pointed out that fsync(), which commits a file's changes to storage, could report success without surfacing an error if initialization after a partial write failed. The reviewer asked for that failure to be retained and reported by fsync().
For an application saving a file, knowing that the write failed is itself an important result. The December 1 review also addresses how that failure gets back to the user.
KioskNews shows a cleaned-up reading view extracted from the publisher’s page — the original always lives on their site, not ours.
