btrfs: provide simple rcu-walk ACL implementation
authorNick Piggin <npiggin@kernel.dk>
Fri, 7 Jan 2011 06:50:01 +0000 (17:50 +1100)
committerNick Piggin <npiggin@kernel.dk>
Fri, 7 Jan 2011 06:50:30 +0000 (17:50 +1100)
This simple implementation just checks for no ACLs on the inode, and
if so, then the rcu-walk may proceed, otherwise fail it.

Signed-off-by: Nick Piggin <npiggin@kernel.dk>
fs/btrfs/acl.c
fs/btrfs/inode.c

index cb518a4b917c8ce078d89e6261f62bdeb42a4c95..6ae2c8cac9d568ee754f6913c29302555ee44593 100644 (file)
@@ -187,18 +187,21 @@ static int btrfs_xattr_acl_set(struct dentry *dentry, const char *name,
 
 int btrfs_check_acl(struct inode *inode, int mask, unsigned int flags)
 {
-       struct posix_acl *acl;
        int error = -EAGAIN;
 
-       if (flags & IPERM_FLAG_RCU)
-               return -ECHILD;
+       if (flags & IPERM_FLAG_RCU) {
+               if (!negative_cached_acl(inode, ACL_TYPE_ACCESS))
+                       error = -ECHILD;
 
-       acl = btrfs_get_acl(inode, ACL_TYPE_ACCESS);
-       if (IS_ERR(acl))
-               return PTR_ERR(acl);
-       if (acl) {
-               error = posix_acl_permission(inode, acl, mask);
-               posix_acl_release(acl);
+       } else {
+               struct posix_acl *acl;
+               acl = btrfs_get_acl(inode, ACL_TYPE_ACCESS);
+               if (IS_ERR(acl))
+                       return PTR_ERR(acl);
+               if (acl) {
+                       error = posix_acl_permission(inode, acl, mask);
+                       posix_acl_release(acl);
+               }
        }
 
        return error;
index 5cf0db0081f9f0da661451a6b7fe958dd042557e..a0ff46a478953fa118e342e9684e5e869c3d3615 100644 (file)
@@ -7213,9 +7213,6 @@ static int btrfs_set_page_dirty(struct page *page)
 
 static int btrfs_permission(struct inode *inode, int mask, unsigned int flags)
 {
-       if (flags & IPERM_FLAG_RCU)
-               return -ECHILD;
-
        if ((BTRFS_I(inode)->flags & BTRFS_INODE_READONLY) && (mask & MAY_WRITE))
                return -EACCES;
        return generic_permission(inode, mask, flags, btrfs_check_acl);