[PATCH v1 13/13] ntfs: enable large folios for ordinary files
From: Baolin Liu
Date: Wed Dec 02 2026 - 23:07:47 EST
From: Baolin Liu <liubaolin@xxxxxxxxxx>
Enable large page-cache folios for ordinary, unnamed regular-file data
streams. The iomap read, readahead, buffered-write and writeback paths
already support them. Keep the minimum order at zero for base-page
fallback.
At inode initialization, exclude metadata, SYSTEM-marked files,
directories, named/internal streams, MST-protected data, encrypted files,
and files already using native or WOF compression. Newly created files,
O_TMPFILE files and resident files that grow nonresident use the same
initialization path. The preceding compression changes handle empty
files that change compression state without changing their folio policy.
Document the CONFIG_TRANSPARENT_HUGEPAGE dependency and retained-VMA
restrictions. No mount option or on-disk format change is needed.
Signed-off-by: Baolin Liu <liubaolin@xxxxxxxxxx>
---
Documentation/filesystems/ntfs.rst | 19 +++++++++++++++++++
fs/ntfs/inode.c | 10 ++++++++++
2 files changed, 29 insertions(+)
diff --git a/Documentation/filesystems/ntfs.rst b/Documentation/filesystems/ntfs.rst
index f4c1a281f76d..31f91589bc74 100644
--- a/Documentation/filesystems/ntfs.rst
+++ b/Documentation/filesystems/ntfs.rst
@@ -12,6 +12,7 @@ The Linux NTFS filesystem driver
- Linux file attributes
- Temporary files
- Space accounting
+ - Large folios
- Supported mount options
@@ -93,6 +94,24 @@ an allocation policy, not an on-disk allocation; it is independent of the
placement preference controlled by ``mft_zone_multiplier``.
+Large folios
+============
+
+With ``CONFIG_TRANSPARENT_HUGEPAGE`` enabled, ordinary regular files support
+large page-cache folios through iomap. This includes newly created files,
+``O_TMPFILE`` files and resident files that grow into non-resident data.
+The minimum folio order remains zero; allocation may fall back to base pages.
+No mount option or on-disk format change is needed.
+
+System metadata, directories, named streams, encrypted files and files loaded
+with native or WOF compression retain their existing folio policy. Empty files
+can still switch native compression on or off through ``system.ntfs_attrib``
+or ``system.ntfs_attrib_be``. The mapping keeps its original folio order limits;
+the native compression paths also handle large folios encountered after a
+switch. Shared writable mappings created before enabling compression cannot
+write compressed data; such writes fault with ``SIGBUS``.
+
+
Supported mount options
=======================
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
index 4fbdcd459652..05733cda433c 100644
--- a/fs/ntfs/inode.c
+++ b/fs/ntfs/inode.c
@@ -684,6 +684,8 @@ static struct lock_class_key ntfs_dir_inval_lock_key;
void ntfs_set_vfs_operations(struct inode *inode, mode_t mode, dev_t dev)
{
+ struct ntfs_inode *ni = NTFS_I(inode);
+
if (S_ISDIR(mode)) {
if (!NInoAttr(NTFS_I(inode))) {
inode->i_op = &ntfs_dir_inode_ops;
@@ -708,6 +710,14 @@ void ntfs_set_vfs_operations(struct inode *inode, mode_t mode, dev_t dev)
else
inode->i_mapping->a_ops = &ntfs_aops;
}
+
+ /* Enable large folios only for ordinary, uncompressed data streams. */
+ if (S_ISREG(mode) && ni->type == AT_DATA && !ni->name_len &&
+ !NInoAttr(ni) && ni->mft_no >= FILE_first_user &&
+ !(ni->flags & FILE_ATTR_SYSTEM) && !NInoMstProtected(ni) &&
+ !NInoCompressed(ni) && !NInoWofCompressed(ni) &&
+ !NInoEncrypted(ni))
+ mapping_set_large_folios(inode->i_mapping);
}
static bool ntfs_non_resident_sizes_inconsistent(struct inode *vi,