Skip to content

Commit f19d4a8

Browse files
author
Al Viro
committed
add caching of ACLs in struct inode
No helpers, no conversions yet. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 3e63cbb commit f19d4a8

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

‎fs/inode.c‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <linux/fsnotify.h>
2626
#include <linux/mount.h>
2727
#include <linux/async.h>
28+
#include <linux/posix_acl.h>
2829

2930
/*
3031
* This is needed for the following functions:
@@ -189,6 +190,9 @@ struct inode *inode_init_always(struct super_block *sb, struct inode *inode)
189190
}
190191
inode->i_private = NULL;
191192
inode->i_mapping = mapping;
193+
#ifdef CONFIG_FS_POSIX_ACL
194+
inode->i_acl = inode->i_default_acl = ACL_NOT_CACHED;
195+
#endif
192196

193197
#ifdef CONFIG_FSNOTIFY
194198
inode->i_fsnotify_mask = 0;
@@ -227,6 +231,12 @@ void destroy_inode(struct inode *inode)
227231
ima_inode_free(inode);
228232
security_inode_free(inode);
229233
fsnotify_inode_delete(inode);
234+
#ifdef CONFIG_FS_POSIX_ACL
235+
if (inode->i_acl && inode->i_acl != ACL_NOT_CACHED)
236+
posix_acl_release(inode->i_acl);
237+
if (inode->i_default_acl && inode->i_default_acl != ACL_NOT_CACHED)
238+
posix_acl_release(inode->i_default_acl);
239+
#endif
230240
if (inode->i_sb->s_op->destroy_inode)
231241
inode->i_sb->s_op->destroy_inode(inode);
232242
else

‎include/linux/fs.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,9 @@ static inline int mapping_writably_mapped(struct address_space *mapping)
710710
#define i_size_ordered_init(inode) do { } while (0)
711711
#endif
712712

713+
struct posix_acl;
714+
#define ACL_NOT_CACHED ((void *)(-1))
715+
713716
struct inode {
714717
struct hlist_node i_hash;
715718
struct list_head i_list;
@@ -772,6 +775,10 @@ struct inode {
772775
atomic_t i_writecount;
773776
#ifdef CONFIG_SECURITY
774777
void *i_security;
778+
#endif
779+
#ifdef CONFIG_FS_POSIX_ACL
780+
struct posix_acl *i_acl;
781+
struct posix_acl *i_default_acl;
775782
#endif
776783
void *i_private; /* fs or device private pointer */
777784
};

0 commit comments

Comments
 (0)