提交 1e1743eb 编写于 作者: N Nick Piggin

fs: provide simple rcu-walk generic_check_acl implementation

This simple implementation just checks for no ACLs on the inode, and
if so, then the rcu-walk may proceed, otherwise fail it.

This could easily be extended to put acls under RCU and check them
under seqlock, if need be. But this implementation is enough to show
the rcu-walk aware permissions code for path lookups is working, and
will handle cases where there are no ACLs or ACLs in just the final
element.

This patch implicity converts tmpfs to rcu-aware permission check.
Subsequent patches onvert ext*, xfs, and, btrfs. Each of these uses
acl/permission code in a different way, so convert them all to provide
templates and proof of concept.
Signed-off-by: NNick Piggin <npiggin@kernel.dk>
上级 b74c79e9
...@@ -192,16 +192,18 @@ generic_acl_chmod(struct inode *inode) ...@@ -192,16 +192,18 @@ generic_acl_chmod(struct inode *inode)
int int
generic_check_acl(struct inode *inode, int mask, unsigned int flags) generic_check_acl(struct inode *inode, int mask, unsigned int flags)
{ {
struct posix_acl *acl; if (flags & IPERM_FLAG_RCU) {
if (!negative_cached_acl(inode, ACL_TYPE_ACCESS))
if (flags & IPERM_FLAG_RCU) return -ECHILD;
return -ECHILD; } else {
struct posix_acl *acl;
acl = get_cached_acl(inode, ACL_TYPE_ACCESS);
if (acl) { acl = get_cached_acl(inode, ACL_TYPE_ACCESS);
int error = posix_acl_permission(inode, acl, mask); if (acl) {
posix_acl_release(acl); int error = posix_acl_permission(inode, acl, mask);
return error; posix_acl_release(acl);
return error;
}
} }
return -EAGAIN; return -EAGAIN;
} }
......
...@@ -108,6 +108,25 @@ static inline struct posix_acl *get_cached_acl(struct inode *inode, int type) ...@@ -108,6 +108,25 @@ static inline struct posix_acl *get_cached_acl(struct inode *inode, int type)
return acl; return acl;
} }
static inline int negative_cached_acl(struct inode *inode, int type)
{
struct posix_acl **p, *acl;
switch (type) {
case ACL_TYPE_ACCESS:
p = &inode->i_acl;
break;
case ACL_TYPE_DEFAULT:
p = &inode->i_default_acl;
break;
default:
BUG();
}
acl = ACCESS_ONCE(*p);
if (acl)
return 0;
return 1;
}
static inline void set_cached_acl(struct inode *inode, static inline void set_cached_acl(struct inode *inode,
int type, int type,
struct posix_acl *acl) struct posix_acl *acl)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册