aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext3/acl.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext3/acl.c')
-rw-r--r--fs/ext3/acl.c85
1 files changed, 19 insertions, 66 deletions
diff --git a/fs/ext3/acl.c b/fs/ext3/acl.c
index e0c745451715..e167bae37ef0 100644
--- a/fs/ext3/acl.c
+++ b/fs/ext3/acl.c
@@ -126,33 +126,6 @@ fail:
126 return ERR_PTR(-EINVAL); 126 return ERR_PTR(-EINVAL);
127} 127}
128 128
129static inline struct posix_acl *
130ext3_iget_acl(struct inode *inode, struct posix_acl **i_acl)
131{
132 struct posix_acl *acl = ACCESS_ONCE(*i_acl);
133
134 if (acl) {
135 spin_lock(&inode->i_lock);
136 acl = *i_acl;
137 if (acl != EXT3_ACL_NOT_CACHED)
138 acl = posix_acl_dup(acl);
139 spin_unlock(&inode->i_lock);
140 }
141
142 return acl;
143}
144
145static inline void
146ext3_iset_acl(struct inode *inode, struct posix_acl **i_acl,
147 struct posix_acl *acl)
148{
149 spin_lock(&inode->i_lock);
150 if (*i_acl != EXT3_ACL_NOT_CACHED)
151 posix_acl_release(*i_acl);
152 *i_acl = posix_acl_dup(acl);
153 spin_unlock(&inode->i_lock);
154}
155
156/* 129/*
157 * Inode operation get_posix_acl(). 130 * Inode operation get_posix_acl().
158 * 131 *
@@ -161,7 +134,6 @@ ext3_iset_acl(struct inode *inode, struct posix_acl **i_acl,
161static struct posix_acl * 134static struct posix_acl *
162ext3_get_acl(struct inode *inode, int type) 135ext3_get_acl(struct inode *inode, int type)
163{ 136{
164 struct ext3_inode_info *ei = EXT3_I(inode);
165 int name_index; 137 int name_index;
166 char *value = NULL; 138 char *value = NULL;
167 struct posix_acl *acl; 139 struct posix_acl *acl;
@@ -170,24 +142,21 @@ ext3_get_acl(struct inode *inode, int type)
170 if (!test_opt(inode->i_sb, POSIX_ACL)) 142 if (!test_opt(inode->i_sb, POSIX_ACL))
171 return NULL; 143 return NULL;
172 144
173 switch(type) { 145 acl = get_cached_acl(inode, type);
174 case ACL_TYPE_ACCESS: 146 if (acl != ACL_NOT_CACHED)
175 acl = ext3_iget_acl(inode, &ei->i_acl); 147 return acl;
176 if (acl != EXT3_ACL_NOT_CACHED) 148
177 return acl; 149 switch (type) {
178 name_index = EXT3_XATTR_INDEX_POSIX_ACL_ACCESS; 150 case ACL_TYPE_ACCESS:
179 break; 151 name_index = EXT3_XATTR_INDEX_POSIX_ACL_ACCESS;
180 152 break;
181 case ACL_TYPE_DEFAULT: 153 case ACL_TYPE_DEFAULT:
182 acl = ext3_iget_acl(inode, &ei->i_default_acl); 154 name_index = EXT3_XATTR_INDEX_POSIX_ACL_DEFAULT;
183 if (acl != EXT3_ACL_NOT_CACHED) 155 break;
184 return acl; 156 default:
185 name_index = EXT3_XATTR_INDEX_POSIX_ACL_DEFAULT; 157 BUG();
186 break;
187
188 default:
189 return ERR_PTR(-EINVAL);
190 } 158 }
159
191 retval = ext3_xattr_get(inode, name_index, "", NULL, 0); 160 retval = ext3_xattr_get(inode, name_index, "", NULL, 0);
192 if (retval > 0) { 161 if (retval > 0) {
193 value = kmalloc(retval, GFP_NOFS); 162 value = kmalloc(retval, GFP_NOFS);
@@ -203,17 +172,9 @@ ext3_get_acl(struct inode *inode, int type)
203 acl = ERR_PTR(retval); 172 acl = ERR_PTR(retval);
204 kfree(value); 173 kfree(value);
205 174
206 if (!IS_ERR(acl)) { 175 if (!IS_ERR(acl))
207 switch(type) { 176 set_cached_acl(inode, type, acl);
208 case ACL_TYPE_ACCESS:
209 ext3_iset_acl(inode, &ei->i_acl, acl);
210 break;
211 177
212 case ACL_TYPE_DEFAULT:
213 ext3_iset_acl(inode, &ei->i_default_acl, acl);
214 break;
215 }
216 }
217 return acl; 178 return acl;
218} 179}
219 180
@@ -226,7 +187,6 @@ static int
226ext3_set_acl(handle_t *handle, struct inode *inode, int type, 187ext3_set_acl(handle_t *handle, struct inode *inode, int type,
227 struct posix_acl *acl) 188 struct posix_acl *acl)
228{ 189{
229 struct ext3_inode_info *ei = EXT3_I(inode);
230 int name_index; 190 int name_index;
231 void *value = NULL; 191 void *value = NULL;
232 size_t size = 0; 192 size_t size = 0;
@@ -271,17 +231,10 @@ ext3_set_acl(handle_t *handle, struct inode *inode, int type,
271 value, size, 0); 231 value, size, 0);
272 232
273 kfree(value); 233 kfree(value);
274 if (!error) {
275 switch(type) {
276 case ACL_TYPE_ACCESS:
277 ext3_iset_acl(inode, &ei->i_acl, acl);
278 break;
279 234
280 case ACL_TYPE_DEFAULT: 235 if (!error)
281 ext3_iset_acl(inode, &ei->i_default_acl, acl); 236 set_cached_acl(inode, type, acl);
282 break; 237
283 }
284 }
285 return error; 238 return error;
286} 239}
287 240