aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/acl.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2009-06-08 15:22:25 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2009-06-17 00:36:35 -0400
commit210ad6aedb332e73167ece5af9bd47f0da8c2aca (patch)
tree29e463655148987f3bce2510d94e36da7dd07176 /fs/ext4/acl.c
parent9c64daff9d5afb102dfe64a26829e26725538e58 (diff)
ext4: avoid unnecessary spinlock in critical POSIX ACL path
If a filesystem supports POSIX ACL's, the VFS layer expects the filesystem to do POSIX ACL checks on any files not owned by the caller, and it does this for every single pathname component that it looks up. That obviously can be pretty expensive if the filesystem isn't careful about it, especially with locking. That's doubly sad, since the common case tends to be that there are no ACL's associated with the files in question. ext4 already caches the ACL data so that it doesn't have to look it up over and over again, but it does so by taking the inode->i_lock spinlock on every lookup. Which is a noticeable overhead even if it's a private lock, especially on CPU's where the serialization is expensive (eg Intel Netburst aka 'P4'). For the special case of not actually having any ACL's, all that locking is unnecessary. Even if somebody else were to be changing the ACL's on another CPU, we simply don't care - if we've seen a NULL ACL, we might as well use it. So just load the ACL speculatively without any locking, and if it was NULL, just use it. If it's non-NULL (either because we had a cached entry, or because the cache hasn't been filled in at all), it means that we'll need to get the lock and re-load it properly. (This commit was ported from a patch originally authored by Linus for ext3.) Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/ext4/acl.c')
-rw-r--r--fs/ext4/acl.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c
index 647e0d65a284..605aeed96d68 100644
--- a/fs/ext4/acl.c
+++ b/fs/ext4/acl.c
@@ -129,12 +129,15 @@ fail:
129static inline struct posix_acl * 129static inline struct posix_acl *
130ext4_iget_acl(struct inode *inode, struct posix_acl **i_acl) 130ext4_iget_acl(struct inode *inode, struct posix_acl **i_acl)
131{ 131{
132 struct posix_acl *acl = EXT4_ACL_NOT_CACHED; 132 struct posix_acl *acl = ACCESS_ONCE(*i_acl);
133 133
134 spin_lock(&inode->i_lock); 134 if (acl) {
135 if (*i_acl != EXT4_ACL_NOT_CACHED) 135 spin_lock(&inode->i_lock);
136 acl = posix_acl_dup(*i_acl); 136 acl = *i_acl;
137 spin_unlock(&inode->i_lock); 137 if (acl != EXT4_ACL_NOT_CACHED)
138 acl = posix_acl_dup(acl);
139 spin_unlock(&inode->i_lock);
140 }
138 141
139 return acl; 142 return acl;
140} 143}