浏览代码

add caching of ACLs in struct inode

No helpers, no conversions yet.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Al Viro 16 年之前
父节点
当前提交
f19d4a8fa6
共有 2 个文件被更改,包括 17 次插入0 次删除
  1. 10 0
      fs/inode.c
  2. 7 0
      include/linux/fs.h

+ 10 - 0
fs/inode.c

@@ -25,6 +25,7 @@
 #include <linux/fsnotify.h>
 #include <linux/fsnotify.h>
 #include <linux/mount.h>
 #include <linux/mount.h>
 #include <linux/async.h>
 #include <linux/async.h>
+#include <linux/posix_acl.h>
 
 
 /*
 /*
  * This is needed for the following functions:
  * This is needed for the following functions:
@@ -189,6 +190,9 @@ struct inode *inode_init_always(struct super_block *sb, struct inode *inode)
 	}
 	}
 	inode->i_private = NULL;
 	inode->i_private = NULL;
 	inode->i_mapping = mapping;
 	inode->i_mapping = mapping;
+#ifdef CONFIG_FS_POSIX_ACL
+	inode->i_acl = inode->i_default_acl = ACL_NOT_CACHED;
+#endif
 
 
 #ifdef CONFIG_FSNOTIFY
 #ifdef CONFIG_FSNOTIFY
 	inode->i_fsnotify_mask = 0;
 	inode->i_fsnotify_mask = 0;
@@ -227,6 +231,12 @@ void destroy_inode(struct inode *inode)
 	ima_inode_free(inode);
 	ima_inode_free(inode);
 	security_inode_free(inode);
 	security_inode_free(inode);
 	fsnotify_inode_delete(inode);
 	fsnotify_inode_delete(inode);
+#ifdef CONFIG_FS_POSIX_ACL
+	if (inode->i_acl && inode->i_acl != ACL_NOT_CACHED)
+		posix_acl_release(inode->i_acl);
+	if (inode->i_default_acl && inode->i_default_acl != ACL_NOT_CACHED)
+		posix_acl_release(inode->i_default_acl);
+#endif
 	if (inode->i_sb->s_op->destroy_inode)
 	if (inode->i_sb->s_op->destroy_inode)
 		inode->i_sb->s_op->destroy_inode(inode);
 		inode->i_sb->s_op->destroy_inode(inode);
 	else
 	else

+ 7 - 0
include/linux/fs.h

@@ -710,6 +710,9 @@ static inline int mapping_writably_mapped(struct address_space *mapping)
 #define i_size_ordered_init(inode) do { } while (0)
 #define i_size_ordered_init(inode) do { } while (0)
 #endif
 #endif
 
 
+struct posix_acl;
+#define ACL_NOT_CACHED ((void *)(-1))
+
 struct inode {
 struct inode {
 	struct hlist_node	i_hash;
 	struct hlist_node	i_hash;
 	struct list_head	i_list;
 	struct list_head	i_list;
@@ -772,6 +775,10 @@ struct inode {
 	atomic_t		i_writecount;
 	atomic_t		i_writecount;
 #ifdef CONFIG_SECURITY
 #ifdef CONFIG_SECURITY
 	void			*i_security;
 	void			*i_security;
+#endif
+#ifdef CONFIG_FS_POSIX_ACL
+	struct posix_acl	*i_acl;
+	struct posix_acl	*i_default_acl;
 #endif
 #endif
 	void			*i_private; /* fs or device private pointer */
 	void			*i_private; /* fs or device private pointer */
 };
 };