Skip to contentSkip to conversation

ext4: Mark inodes without acls in __ext4_iget()

PATCH Applied Jan Kara 4 participants 4 messages Nov 25, 2025 – Dec 1, 2025 ext4 file system

lore
Share & tools
lore

Jan Kara

author reviewer
#0 lore raw

PATCH 1/1 ext4: Mark inodes without acls in __ext4_iget()

Mark inodes without acls with cache_no_acl() in __ext4_iget() so that path lookup can run in RCU mode from the start. This is interesting in particular for the case where the file owner does the lookup because in that case end up constantly hitting the slow path otherwise. We drop out from the fast path (because ACL state is unknown) but never end up calling check_acl() to cache ACL state.

The problem was originally analyzed by Linus and fix tested by Matheusz, I'm just putting it into mergeable form :).

---
 fs/ext4/inode.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/ext4/inode.c +3 -1
index e99306a8f47c..2b68d0651652 100644
@@ -5521,7 +5521,9 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
 	if (ret)
 		goto bad_inode;
 	brelse(iloc.bh);
-
+	/* Initialize the "no ACL's" state for the simple cases */
+	if (!ext4_test_inode_state(inode, EXT4_STATE_XATTR) && !ei->i_file_acl)
+		cache_no_acl(inode);
 	unlock_new_inode(inode);
 	return inode;
 
Signature · 1 line
2.51.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Jan Kara

Mark inodes without acls with cache_no_acl() in __ext4_iget() so that path lookup can run in RCU mode from the start. This is interesting in particular for the case where the file owner does the lookup because in that case end up constantly hitting the slow path otherwise. We drop out from the fast path (because ACL state is unknown) but never end up calling check_acl() to cache ACL state.

Quoted 7 lines

The problem was originally analyzed by Linus and fix tested by Matheusz, I'm just putting it into mergeable form :).

Looks good! Feel free to add:

Quoted 19 lines
---
 fs/ext4/inode.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/ext4/inode.c +3 -1
index e99306a8f47c..2b68d0651652 100644
@@ -5521,7 +5521,9 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
 	if (ret)
 		goto bad_inode;
 	brelse(iloc.bh);
-
+	/* Initialize the "no ACL's" state for the simple cases */
+	if (!ext4_test_inode_state(inode, EXT4_STATE_XATTR) && !ei->i_file_acl)
+		cache_no_acl(inode);
 	unlock_new_inode(inode);
 	return inode;
 
Reviewed-by on v1 1/1
#2 lore raw
In reply to Jan Kara
Quoted 7 lines · Jan Kara

Mark inodes without acls with cache_no_acl() in __ext4_iget() so that path lookup can run in RCU mode from the start. This is interesting in particular for the case where the file owner does the lookup because in that case end up constantly hitting the slow path otherwise. We drop out from the fast path (because ACL state is unknown) but never end up calling check_acl() to cache ACL state.

Quoted 7 lines

The problem was originally analyzed by Linus and fix tested by Matheusz, I'm just putting it into mergeable form :).

This makes sense to me.

Quoted 19 lines
---
 fs/ext4/inode.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/ext4/inode.c +3 -1
index e99306a8f47c..2b68d0651652 100644
@@ -5521,7 +5521,9 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
 	if (ret)
 		goto bad_inode;
 	brelse(iloc.bh);
-
+	/* Initialize the "no ACL's" state for the simple cases */
+	if (!ext4_test_inode_state(inode, EXT4_STATE_XATTR) && !ei->i_file_acl)
+		cache_no_acl(inode);
 	unlock_new_inode(inode);
 	return inode;
 
maintainer Applied
#3 lore raw
In reply to Jan Kara
Quoted 8 lines · Jan Kara

Mark inodes without acls with cache_no_acl() in __ext4_iget() so that path lookup can run in RCU mode from the start. This is interesting in particular for the case where the file owner does the lookup because in that case end up constantly hitting the slow path otherwise. We drop out from the fast path (because ACL state is unknown) but never end up calling check_acl() to cache ACL state.

[...]

Applied, thanks!

[1/1] ext4: Mark inodes without acls in __ext4_iget()

      commit: 91ef18b567dae84c0cea9b996d933c856e366f52

Best regards,

Signature · 1 line
Theodore Ts'o <[email protected]>