From 1dc432094af8212842e513ff7360f25b5d3ee1da Mon Sep 17 00:00:00 2001 From: Nick Piggin Date: Fri, 7 Jan 2011 17:49:59 +1100 Subject: [PATCH] --- yaml --- r: 226731 b: refs/heads/master c: 1e1743ebe35ec7e3c1fa732408358fbc614cbbe5 h: refs/heads/master i: 226729: 9322819a85492ec5f24d4e70041a0851c9c8ad64 226727: ab777f0dc4d967e1c1852cf53cd2aa3e9d22a5a4 v: v3 --- [refs] | 2 +- trunk/fs/generic_acl.c | 22 ++++++++++++---------- trunk/include/linux/posix_acl.h | 19 +++++++++++++++++++ 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/[refs] b/[refs] index 222100d67923..be0439a78d9d 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: b74c79e99389cd79b31fcc08f82c24e492e63c7e +refs/heads/master: 1e1743ebe35ec7e3c1fa732408358fbc614cbbe5 diff --git a/trunk/fs/generic_acl.c b/trunk/fs/generic_acl.c index 628004282130..06c48a891832 100644 --- a/trunk/fs/generic_acl.c +++ b/trunk/fs/generic_acl.c @@ -192,16 +192,18 @@ generic_acl_chmod(struct inode *inode) int generic_check_acl(struct inode *inode, int mask, unsigned int flags) { - struct posix_acl *acl; - - if (flags & IPERM_FLAG_RCU) - return -ECHILD; - - acl = get_cached_acl(inode, ACL_TYPE_ACCESS); - if (acl) { - int error = posix_acl_permission(inode, acl, mask); - posix_acl_release(acl); - return error; + if (flags & IPERM_FLAG_RCU) { + if (!negative_cached_acl(inode, ACL_TYPE_ACCESS)) + return -ECHILD; + } else { + struct posix_acl *acl; + + acl = get_cached_acl(inode, ACL_TYPE_ACCESS); + if (acl) { + int error = posix_acl_permission(inode, acl, mask); + posix_acl_release(acl); + return error; + } } return -EAGAIN; } diff --git a/trunk/include/linux/posix_acl.h b/trunk/include/linux/posix_acl.h index 67608161df6b..d68283a898bb 100644 --- a/trunk/include/linux/posix_acl.h +++ b/trunk/include/linux/posix_acl.h @@ -108,6 +108,25 @@ static inline struct posix_acl *get_cached_acl(struct inode *inode, int type) 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, int type, struct posix_acl *acl)