aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2009-09-29 11:26:23 -0400
committerSteven Whitehouse <swhiteho@redhat.com>2009-12-03 06:47:51 -0500
commit106381bfba997b83b64f68f2210e154162fc38e6 (patch)
tree1968f519563faaa1c27e3162e007646bbaaaedc8 /fs/gfs2
parent479c427dd60fe1aadbbf2e6cbf2f84942baeb210 (diff)
GFS2: Add cached ACLs support
The other patches in this series have been building towards being able to support cached ACLs like other filesystems. The only real difference with GFS2 is that we have to invalidate the cache when we drop a glock, but that is dealt with in earlier patches. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2')
-rw-r--r--fs/gfs2/acl.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/fs/gfs2/acl.c b/fs/gfs2/acl.c
index bd0fce964c41..3eb1ea846173 100644
--- a/fs/gfs2/acl.c
+++ b/fs/gfs2/acl.c
@@ -48,6 +48,10 @@ static struct posix_acl *gfs2_acl_get(struct gfs2_inode *ip, int type)
48 if (!ip->i_eattr) 48 if (!ip->i_eattr)
49 return NULL; 49 return NULL;
50 50
51 acl = get_cached_acl(&ip->i_inode, type);
52 if (acl != ACL_NOT_CACHED)
53 return acl;
54
51 name = gfs2_acl_name(type); 55 name = gfs2_acl_name(type);
52 if (name == NULL) 56 if (name == NULL)
53 return ERR_PTR(-EINVAL); 57 return ERR_PTR(-EINVAL);
@@ -123,6 +127,8 @@ static int gfs2_acl_set(struct inode *inode, int type, struct posix_acl *acl)
123 if (error < 0) 127 if (error < 0)
124 goto out; 128 goto out;
125 error = gfs2_xattr_set(inode, GFS2_EATYPE_SYS, name, data, len, 0); 129 error = gfs2_xattr_set(inode, GFS2_EATYPE_SYS, name, data, len, 0);
130 if (!error)
131 set_cached_acl(inode, type, acl);
126out: 132out:
127 kfree(data); 133 kfree(data);
128 return error; 134 return error;
@@ -209,6 +215,7 @@ int gfs2_acl_chmod(struct gfs2_inode *ip, struct iattr *attr)
209 posix_acl_to_xattr(acl, data, len); 215 posix_acl_to_xattr(acl, data, len);
210 error = gfs2_xattr_acl_chmod(ip, attr, data); 216 error = gfs2_xattr_acl_chmod(ip, attr, data);
211 kfree(data); 217 kfree(data);
218 set_cached_acl(&ip->i_inode, ACL_TYPE_ACCESS, acl);
212 } 219 }
213 220
214out: 221out:
@@ -228,15 +235,25 @@ static int gfs2_acl_type(const char *name)
228static int gfs2_xattr_system_get(struct inode *inode, const char *name, 235static int gfs2_xattr_system_get(struct inode *inode, const char *name,
229 void *buffer, size_t size) 236 void *buffer, size_t size)
230{ 237{
238 struct posix_acl *acl;
231 int type; 239 int type;
240 int error;
232 241
233 type = gfs2_acl_type(name); 242 type = gfs2_acl_type(name);
234 if (type < 0) 243 if (type < 0)
235 return type; 244 return type;
236 245
237 return gfs2_xattr_get(inode, GFS2_EATYPE_SYS, name, buffer, size); 246 acl = gfs2_acl_get(GFS2_I(inode), type);
238} 247 if (IS_ERR(acl))
248 return PTR_ERR(acl);
249 if (acl == NULL)
250 return -ENODATA;
239 251
252 error = posix_acl_to_xattr(acl, buffer, size);
253 posix_acl_release(acl);
254
255 return error;
256}
240 257
241static int gfs2_xattr_system_set(struct inode *inode, const char *name, 258static int gfs2_xattr_system_set(struct inode *inode, const char *name,
242 const void *value, size_t size, int flags) 259 const void *value, size_t size, int flags)
@@ -303,6 +320,12 @@ static int gfs2_xattr_system_set(struct inode *inode, const char *name,
303 320
304set_acl: 321set_acl:
305 error = gfs2_xattr_set(inode, GFS2_EATYPE_SYS, name, value, size, 0); 322 error = gfs2_xattr_set(inode, GFS2_EATYPE_SYS, name, value, size, 0);
323 if (!error) {
324 if (acl)
325 set_cached_acl(inode, type, acl);
326 else
327 forget_cached_acl(inode, type);
328 }
306out_release: 329out_release:
307 posix_acl_release(acl); 330 posix_acl_release(acl);
308out: 331out: