[BUG] NTFS rename fails with "Failed to add AT_INDEX_ALLOCATION" on Linux 7.1 new ntfs driver
"亓梦舰" <[email protected]> Sun, 9 Aug 2026 16:16:09 +0800
| Newsgroups | gmane.linux.file-systems |
|---|---|
| Message-ID | <[email protected]> |
Subject: [BUG] NTFS rename fails with "Failed to add AT_INDEX_ALLOCATION" on Linux 7.1 new ntfs driver Summary: ======== On Linux 7.1 with the new in-kernel NTFS driver (NTFSPlus/NTFS_FS), rename() operations fail when the target directory's index inode MFT record is full. This manifests as "Disk write failure" in applications like Steam. Reproduction: ============= 1. Mount an NTFS volume using the new "ntfs" driver (not ntfs3) 2. Create a directory with many files (or use a pre-existing Steam library) 3. Attempt to rename or create a new file in that directory 4. The operation fails with EIO, dmesg shows attribute add failures Expected behavior: ================== Rename succeeds, or at minimum returns a clear ENOSPC error if the filesystem is actually full. Actual behavior: ================ dmesg shows cascading failures: ntfs: (device sdc1): ntfs_attr_add(): Failed to add resident attribute ntfs: (device sdc1): ntfs_ia_add(): Failed to add AT_INDEX_ALLOCATION ntfs: (device sdc1): ntfs_ir_make_space(): Failed to modify INDEX_ROOT The application receives "Disk write failure" (EIO). Root Cause Analysis: ==================== From code review of v7.1 fs/ntfs/index.c and fs/ntfs/attrib.c: 1. When a directory's INDEX_ROOT needs to grow beyond its current MFT record space, ntfs_ir_make_space() (index.c:1309) is called. 2. If ntfs_ir_truncate() returns -ENOSPC, it calls ntfs_ir_reparent() (index.c:1169) to move the index root into an index block. 3. ntfs_ir_reparent() calls ntfs_ia_add() (index.c:1143) to create the AT_INDEX_ALLOCATION attribute. 4. ntfs_ia_add() calls ntfs_ibm_add() (index.c:919) to create the AT_BITMAP attribute first. 5. ntfs_ibm_add() calls ntfs_attr_add() (attrib.c:2614) which tries to add the AT_BITMAP as a resident attribute in the index inode's MFT record. 6. If the MFT record doesn't have enough free space (bytes_allocated - bytes_in_use < attr_rec_size), ntfs_attr_add() fails with ENOSPC. 7. Unlike ntfs3, the new driver doesn't attempt to allocate an extent MFT record for the index inode before adding these attributes. It only tries extent allocation for the base data inode, not for index inodes. System Information: =================== - Kernel: Linux 7.1.0-070100-generic - Driver: ntfs (new NTFSPlus driver, CONFIG_NTFS_FS) - Application: Steam (Left 4 Dead 2 update) - Filesystem: NTFS 3.1, 4KB cluster size - The same volume works correctly with ntfs3 driver Workaround: =========== Using "ntfs3" (CONFIG_NTFS3_FS) instead of "ntfs" works correctly. Relevant dmesg output: ===================== [1061.290832] ntfs: (device sdc1): ntfs_attr_add(): Failed to add non resident attribute [1061.290837] ntfs: (device sdc1): ntfs_ia_add(): Failed to add AT_INDEX_ALLOCATION [1061.290841] ntfs: (device sdc1): ntfs_ir_make_space(): Failed to modify INDEX_ROOT Suggested Fix: ============== In ntfs_ibm_add() or ntfs_ia_add(), if ntfs_attr_add() returns -ENOSPC, the driver should attempt to allocate an extent MFT record for the index inode (icx->idx_ni) and add an attribute list before retrying the attribute addition. This is similar to how ntfs_attr_add() handles -ENOSPC for regular inodes via ntfs_inode_add_attrlist() + ntfs_mft_record_alloc(). Reporter: yi Email: [email protected] 亓梦舰 [email protected]