summaryrefslogtreecommitdiff
path: root/fs/ext4/inode.c
diff options
context:
space:
mode:
authorZhang Yi <yi.zhang@huawei.com>2025-05-12 14:33:19 +0800
committerTheodore Ts'o <tytso@mit.edu>2025-05-20 10:31:12 -0400
commit7ac67301e82f02b77a5c8e7377a1f414ef108b84 (patch)
treee5bbdd26379445770b2f6caa6b4d902293f30ba9 /fs/ext4/inode.c
parent01e807e18fd87937f515926b79152dfa4f13b735 (diff)
downloadlinux-next-7ac67301e82f02b77a5c8e7377a1f414ef108b84.tar.gz
linux-next-7ac67301e82f02b77a5c8e7377a1f414ef108b84.zip
ext4: enable large folio for regular file
Besides fsverity, fscrypt, and the data=journal mode, ext4 now supports large folios for regular files. Enable this feature by default. However, since we cannot change the folio order limitation of mappings on active inodes, setting the journal=data mode via ioctl on an active inode will not take immediate effect in non-delalloc mode. Signed-off-by: Zhang Yi <yi.zhang@huawei.com> Link: https://patch.msgid.link/20250512063319.3539411-9-yi.zhang@huaweicloud.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/inode.c')
-rw-r--r--fs/ext4/inode.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index ed88e5844f46..01e42cce572e 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -4829,6 +4829,23 @@ error:
return -EFSCORRUPTED;
}
+bool ext4_should_enable_large_folio(struct inode *inode)
+{
+ struct super_block *sb = inode->i_sb;
+
+ if (!S_ISREG(inode->i_mode))
+ return false;
+ if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA ||
+ ext4_test_inode_flag(inode, EXT4_INODE_JOURNAL_DATA))
+ return false;
+ if (ext4_has_feature_verity(sb))
+ return false;
+ if (ext4_has_feature_encrypt(sb))
+ return false;
+
+ return true;
+}
+
struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
ext4_iget_flags flags, const char *function,
unsigned int line)
@@ -5147,6 +5164,9 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
ret = -EFSCORRUPTED;
goto bad_inode;
}
+ if (ext4_should_enable_large_folio(inode))
+ mapping_set_large_folios(inode->i_mapping);
+
ret = check_igot_inode(inode, flags, function, line);
/*
* -ESTALE here means there is nothing inherently wrong with the inode,