[PATCH v1 0/5] ntfs: support O_TMPFILE
From: Baolin Liu
Date: Tue Oct 27 2026 - 05:39:41 EST
From: Baolin Liu <liubaolin@xxxxxxxxxx>
Hi all,
This series adds O_TMPFILE support to fs/ntfs. Applications can prepare a
regular file's contents and metadata without exposing a directory entry,
then publish the file with linkat(). Unpublished files are reclaimed when
their last reference is released. O_EXCL prevents publication.
O_TMPFILE reuses the existing inode creation, EA update and hard-link
paths. The first four patches fix existing bugs in those paths, so that
anonymous files can inherit ACLs, prepare metadata and be published
correctly:
1. ACLs must be initialized after allocating the MFT record. Otherwise,
an inherited ACL can appear correct in memory but disappear after
inode eviction. Anonymous creation uses the same initialization
path as ordinary file creation.
2. Publication through linkat() must preserve the file's atime and
mtime. The existing hard-link path resets both; the fix updates only
the required timestamps and marks the affected inodes dirty.
3. Files may already have ACLs or other EAs before publication. The
hard-link path currently leaves the new FILE_NAME's packed EA size
at zero. Initialize it from EA_INFORMATION when adding the link.
4. Attribute inodes initialized while the base file has zero links
also have zero links. They are evicted at the final iput(), discarding
dirty pages from nonresident EA writes. Synchronous nonresident
writes keep a successful EA update readable after that cache is dropped.
These bugs also affect ordinary creation, hard links and open-unlinked
files. Keeping the fixes separate allows independent review and use
without O_TMPFILE. Patch 5 builds on them to add anonymous creation,
VFS-controlled publication and documentation.
Named-stream ioctls can create or open streams after publication, but
not while the temporary file remains unpublished.
Tested this five-patch series in QEMU with four CPUs, NTFS debug and
lockdep. Tests cover creation, publication, permissions, idmapped mounts,
direct I/O, mmap, allocation, concurrent publication and ENOSPC. Checks
after cache eviction/remount/reboot covered file contents, EA values,
access ACL readability, mode and explicitly set atime/mtime. Injected
ENOSPC at five creation/publication/open sites and checked failure
behavior and release of the recorded base MFT records. Ordinary file
operations were also exercised. Individual patch notes describe the tests.
Based on ntfs-next commit e845077350df3862c733ed10a950d49ef4d64b0c.
Thanks,
Baolin
Baolin Liu (2):
ntfs: initialize inherited ACLs after allocating the MFT record
ntfs: support O_TMPFILE
Xuewen Wang (3):
ntfs: preserve timestamps when creating hard links
ntfs: initialize packed EA size when creating hard links
ntfs: write unlinked file attributes before dropping their cache
Documentation/filesystems/ntfs.rst | 15 ++++
fs/ntfs/inode.c | 8 ++
fs/ntfs/namei.c | 123 ++++++++++++++++++++++++-----
3 files changed, 126 insertions(+), 20 deletions(-)
base-commit: e845077350df3862c733ed10a950d49ef4d64b0c