aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2014-01-30 08:56:36 -0800
committerSage Weil <sage@inktank.com>2014-01-30 19:26:17 -0800
commit758582361976e9640a1cb9516c0af10cdf8e4753 (patch)
tree28f1492a90891db65fbf1bd85daa69035052cbc0
parent32d35d44d03c502a2fe2cd9ba9b70d5e220da439 (diff)
downloadlinux-linaro-stable-758582361976e9640a1cb9516c0af10cdf8e4753.tar.gz
ceph: simplify ceph_{get,init}_acl
- ->get_acl only gets called after we checked for a cached ACL, so no need to call get_cached_acl again. - no need to check IS_POSIXACL in ->get_acl, without that it should never get set as all the callers that set it already have the check. - you should be able to use the full posix_acl_create in CEPH Signed-off-by: Christoph Hellwig <hch@infradead.org> Signed-off-by: Sage Weil <sage@inktank.com>
-rw-r--r--fs/ceph/acl.c56
1 files changed, 16 insertions, 40 deletions
diff --git a/fs/ceph/acl.c b/fs/ceph/acl.c
index 66d377a12f7c..9ab312e49637 100644
--- a/fs/ceph/acl.c
+++ b/fs/ceph/acl.c
@@ -66,13 +66,6 @@ struct posix_acl *ceph_get_acl(struct inode *inode, int type)
char *value = NULL;
struct posix_acl *acl;
- if (!IS_POSIXACL(inode))
- return NULL;
-
- acl = ceph_get_cached_acl(inode, type);
- if (acl != ACL_NOT_CACHED)
- return acl;
-
switch (type) {
case ACL_TYPE_ACCESS:
name = POSIX_ACL_XATTR_ACCESS;
@@ -190,41 +183,24 @@ out:
int ceph_init_acl(struct dentry *dentry, struct inode *inode, struct inode *dir)
{
- struct posix_acl *acl = NULL;
- int ret = 0;
-
- if (!S_ISLNK(inode->i_mode)) {
- if (IS_POSIXACL(dir)) {
- acl = ceph_get_acl(dir, ACL_TYPE_DEFAULT);
- if (IS_ERR(acl)) {
- ret = PTR_ERR(acl);
- goto out;
- }
- }
+ struct posix_acl *default_acl, *acl;
+ int error;
- if (!acl)
- inode->i_mode &= ~current_umask();
- }
+ error = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl);
+ if (error)
+ return error;
- if (IS_POSIXACL(dir) && acl) {
- if (S_ISDIR(inode->i_mode)) {
- ret = ceph_set_acl(inode, acl, ACL_TYPE_DEFAULT);
- if (ret)
- goto out_release;
- }
- ret = __posix_acl_create(&acl, GFP_NOFS, &inode->i_mode);
- if (ret < 0)
- goto out;
- else if (ret > 0)
- ret = ceph_set_acl(inode, acl, ACL_TYPE_ACCESS);
- else
- cache_no_acl(inode);
- } else {
+ if (!default_acl && !acl)
cache_no_acl(inode);
- }
-out_release:
- posix_acl_release(acl);
-out:
- return ret;
+ if (default_acl) {
+ error = ceph_set_acl(inode, default_acl, ACL_TYPE_DEFAULT);
+ posix_acl_release(default_acl);
+ }
+ if (acl) {
+ if (!error)
+ error = ceph_set_acl(inode, acl, ACL_TYPE_ACCESS);
+ posix_acl_release(acl);
+ }
+ return error;
}