|
@@ -188,29 +188,6 @@ static void *posix_acl_to_disk(const struct posix_acl *acl, size_t * size)
|
|
return ERR_PTR(-EINVAL);
|
|
return ERR_PTR(-EINVAL);
|
|
}
|
|
}
|
|
|
|
|
|
-static inline void iset_acl(struct inode *inode, struct posix_acl **i_acl,
|
|
|
|
- struct posix_acl *acl)
|
|
|
|
-{
|
|
|
|
- spin_lock(&inode->i_lock);
|
|
|
|
- if (*i_acl != ACL_NOT_CACHED)
|
|
|
|
- posix_acl_release(*i_acl);
|
|
|
|
- *i_acl = posix_acl_dup(acl);
|
|
|
|
- spin_unlock(&inode->i_lock);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-static inline struct posix_acl *iget_acl(struct inode *inode,
|
|
|
|
- struct posix_acl **i_acl)
|
|
|
|
-{
|
|
|
|
- struct posix_acl *acl = ACL_NOT_CACHED;
|
|
|
|
-
|
|
|
|
- spin_lock(&inode->i_lock);
|
|
|
|
- if (*i_acl != ACL_NOT_CACHED)
|
|
|
|
- acl = posix_acl_dup(*i_acl);
|
|
|
|
- spin_unlock(&inode->i_lock);
|
|
|
|
-
|
|
|
|
- return acl;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
/*
|
|
/*
|
|
* Inode operation get_posix_acl().
|
|
* Inode operation get_posix_acl().
|
|
*
|
|
*
|
|
@@ -220,31 +197,29 @@ static inline struct posix_acl *iget_acl(struct inode *inode,
|
|
struct posix_acl *reiserfs_get_acl(struct inode *inode, int type)
|
|
struct posix_acl *reiserfs_get_acl(struct inode *inode, int type)
|
|
{
|
|
{
|
|
char *name, *value;
|
|
char *name, *value;
|
|
- struct posix_acl *acl, **p_acl;
|
|
|
|
|
|
+ struct posix_acl *acl;
|
|
int size;
|
|
int size;
|
|
int retval;
|
|
int retval;
|
|
|
|
|
|
|
|
+ acl = get_cached_acl(inode, type);
|
|
|
|
+ if (acl != ACL_NOT_CACHED)
|
|
|
|
+ return acl;
|
|
|
|
+
|
|
switch (type) {
|
|
switch (type) {
|
|
case ACL_TYPE_ACCESS:
|
|
case ACL_TYPE_ACCESS:
|
|
name = POSIX_ACL_XATTR_ACCESS;
|
|
name = POSIX_ACL_XATTR_ACCESS;
|
|
- p_acl = &inode->i_acl;
|
|
|
|
break;
|
|
break;
|
|
case ACL_TYPE_DEFAULT:
|
|
case ACL_TYPE_DEFAULT:
|
|
name = POSIX_ACL_XATTR_DEFAULT;
|
|
name = POSIX_ACL_XATTR_DEFAULT;
|
|
- p_acl = &inode->i_default_acl;
|
|
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
- return ERR_PTR(-EINVAL);
|
|
|
|
|
|
+ BUG();
|
|
}
|
|
}
|
|
|
|
|
|
- acl = iget_acl(inode, p_acl);
|
|
|
|
- if (acl != ACL_NOT_CACHED)
|
|
|
|
- return acl;
|
|
|
|
-
|
|
|
|
size = reiserfs_xattr_get(inode, name, NULL, 0);
|
|
size = reiserfs_xattr_get(inode, name, NULL, 0);
|
|
if (size < 0) {
|
|
if (size < 0) {
|
|
if (size == -ENODATA || size == -ENOSYS) {
|
|
if (size == -ENODATA || size == -ENOSYS) {
|
|
- *p_acl = NULL;
|
|
|
|
|
|
+ set_cached_acl(inode, type, NULL);
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
return ERR_PTR(size);
|
|
return ERR_PTR(size);
|
|
@@ -259,14 +234,13 @@ struct posix_acl *reiserfs_get_acl(struct inode *inode, int type)
|
|
/* This shouldn't actually happen as it should have
|
|
/* This shouldn't actually happen as it should have
|
|
been caught above.. but just in case */
|
|
been caught above.. but just in case */
|
|
acl = NULL;
|
|
acl = NULL;
|
|
- *p_acl = acl;
|
|
|
|
} else if (retval < 0) {
|
|
} else if (retval < 0) {
|
|
acl = ERR_PTR(retval);
|
|
acl = ERR_PTR(retval);
|
|
} else {
|
|
} else {
|
|
acl = posix_acl_from_disk(value, retval);
|
|
acl = posix_acl_from_disk(value, retval);
|
|
- if (!IS_ERR(acl))
|
|
|
|
- iset_acl(inode, p_acl, acl);
|
|
|
|
}
|
|
}
|
|
|
|
+ if (!IS_ERR(acl))
|
|
|
|
+ set_cached_acl(inode, type, acl);
|
|
|
|
|
|
kfree(value);
|
|
kfree(value);
|
|
return acl;
|
|
return acl;
|
|
@@ -284,7 +258,6 @@ reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode,
|
|
{
|
|
{
|
|
char *name;
|
|
char *name;
|
|
void *value = NULL;
|
|
void *value = NULL;
|
|
- struct posix_acl **p_acl;
|
|
|
|
size_t size = 0;
|
|
size_t size = 0;
|
|
int error;
|
|
int error;
|
|
|
|
|
|
@@ -294,7 +267,6 @@ reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode,
|
|
switch (type) {
|
|
switch (type) {
|
|
case ACL_TYPE_ACCESS:
|
|
case ACL_TYPE_ACCESS:
|
|
name = POSIX_ACL_XATTR_ACCESS;
|
|
name = POSIX_ACL_XATTR_ACCESS;
|
|
- p_acl = &inode->i_acl;
|
|
|
|
if (acl) {
|
|
if (acl) {
|
|
mode_t mode = inode->i_mode;
|
|
mode_t mode = inode->i_mode;
|
|
error = posix_acl_equiv_mode(acl, &mode);
|
|
error = posix_acl_equiv_mode(acl, &mode);
|
|
@@ -309,7 +281,6 @@ reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode,
|
|
break;
|
|
break;
|
|
case ACL_TYPE_DEFAULT:
|
|
case ACL_TYPE_DEFAULT:
|
|
name = POSIX_ACL_XATTR_DEFAULT;
|
|
name = POSIX_ACL_XATTR_DEFAULT;
|
|
- p_acl = &inode->i_default_acl;
|
|
|
|
if (!S_ISDIR(inode->i_mode))
|
|
if (!S_ISDIR(inode->i_mode))
|
|
return acl ? -EACCES : 0;
|
|
return acl ? -EACCES : 0;
|
|
break;
|
|
break;
|
|
@@ -342,7 +313,7 @@ reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode,
|
|
kfree(value);
|
|
kfree(value);
|
|
|
|
|
|
if (!error)
|
|
if (!error)
|
|
- iset_acl(inode, p_acl, acl);
|
|
|
|
|
|
+ set_cached_acl(inode, type, acl);
|
|
|
|
|
|
return error;
|
|
return error;
|
|
}
|
|
}
|