diff options
| author | Al Viro <viro@zeniv.linux.org.uk> | 2009-06-09 12:11:54 -0400 |
|---|---|---|
| committer | Al Viro <viro@zeniv.linux.org.uk> | 2009-06-24 08:17:07 -0400 |
| commit | 073aaa1b142461d91f83da66db1184d7c1b1edea (patch) | |
| tree | 2b54d185d78f1229418fca521a93e6b55c57248b /include/linux | |
| parent | 06b16e9f68edaa1e71aee943d3c030bcf7380af1 (diff) | |
helpers for acl caching + switch to those
helpers: get_cached_acl(inode, type), set_cached_acl(inode, type, acl),
forget_cached_acl(inode, type).
ubifs/xattr.c needed includes reordered, the rest is a plain switchover.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/posix_acl.h | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/include/linux/posix_acl.h b/include/linux/posix_acl.h index 4bc241290c24..0cdba01b7756 100644 --- a/include/linux/posix_acl.h +++ b/include/linux/posix_acl.h | |||
| @@ -83,4 +83,68 @@ extern int posix_acl_chmod_masq(struct posix_acl *, mode_t); | |||
| 83 | extern struct posix_acl *get_posix_acl(struct inode *, int); | 83 | extern struct posix_acl *get_posix_acl(struct inode *, int); |
| 84 | extern int set_posix_acl(struct inode *, int, struct posix_acl *); | 84 | extern int set_posix_acl(struct inode *, int, struct posix_acl *); |
| 85 | 85 | ||
| 86 | static inline struct posix_acl *get_cached_acl(struct inode *inode, int type) | ||
| 87 | { | ||
| 88 | struct posix_acl **p, *acl; | ||
| 89 | switch (type) { | ||
| 90 | case ACL_TYPE_ACCESS: | ||
| 91 | p = &inode->i_acl; | ||
| 92 | break; | ||
| 93 | case ACL_TYPE_DEFAULT: | ||
| 94 | p = &inode->i_default_acl; | ||
| 95 | break; | ||
| 96 | default: | ||
| 97 | return ERR_PTR(-EINVAL); | ||
| 98 | } | ||
| 99 | acl = ACCESS_ONCE(*p); | ||
| 100 | if (acl) { | ||
| 101 | spin_lock(&inode->i_lock); | ||
| 102 | acl = *p; | ||
| 103 | if (acl != ACL_NOT_CACHED) | ||
| 104 | acl = posix_acl_dup(acl); | ||
| 105 | spin_unlock(&inode->i_lock); | ||
| 106 | } | ||
| 107 | return acl; | ||
| 108 | } | ||
| 109 | |||
| 110 | static inline void set_cached_acl(struct inode *inode, | ||
| 111 | int type, | ||
| 112 | struct posix_acl *acl) | ||
| 113 | { | ||
| 114 | struct posix_acl *old = NULL; | ||
| 115 | spin_lock(&inode->i_lock); | ||
| 116 | switch (type) { | ||
| 117 | case ACL_TYPE_ACCESS: | ||
| 118 | old = inode->i_acl; | ||
| 119 | inode->i_acl = posix_acl_dup(acl); | ||
| 120 | break; | ||
| 121 | case ACL_TYPE_DEFAULT: | ||
| 122 | old = inode->i_default_acl; | ||
| 123 | inode->i_default_acl = posix_acl_dup(acl); | ||
| 124 | break; | ||
| 125 | } | ||
| 126 | spin_unlock(&inode->i_lock); | ||
| 127 | if (old != ACL_NOT_CACHED) | ||
| 128 | posix_acl_release(old); | ||
| 129 | } | ||
| 130 | |||
| 131 | static inline void forget_cached_acl(struct inode *inode, int type) | ||
| 132 | { | ||
| 133 | struct posix_acl *old = NULL; | ||
| 134 | spin_lock(&inode->i_lock); | ||
| 135 | switch (type) { | ||
| 136 | case ACL_TYPE_ACCESS: | ||
| 137 | old = inode->i_acl; | ||
| 138 | inode->i_acl = ACL_NOT_CACHED; | ||
| 139 | break; | ||
| 140 | case ACL_TYPE_DEFAULT: | ||
| 141 | old = inode->i_default_acl; | ||
| 142 | inode->i_default_acl = ACL_NOT_CACHED; | ||
| 143 | break; | ||
| 144 | } | ||
| 145 | spin_unlock(&inode->i_lock); | ||
| 146 | if (old != ACL_NOT_CACHED) | ||
| 147 | posix_acl_release(old); | ||
| 148 | } | ||
| 149 | |||
| 86 | #endif /* __LINUX_POSIX_ACL_H */ | 150 | #endif /* __LINUX_POSIX_ACL_H */ |
