]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/nfs/nfs3acl.c
Merge branch 'linus' into core/urgent
[linux-2.6-omap-h63xx.git] / fs / nfs / nfs3acl.c
index 33287879bd23547e33c953e19efdf4603cf059e1..cef62557c87daeadab3f33fa7bd468b979ae59f6 100644 (file)
@@ -5,6 +5,8 @@
 #include <linux/posix_acl_xattr.h>
 #include <linux/nfsacl.h>
 
+#include "internal.h"
+
 #define NFSDBG_FACILITY        NFSDBG_PROC
 
 ssize_t nfs3_listxattr(struct dentry *dentry, char *buffer, size_t size)
@@ -172,8 +174,10 @@ static void nfs3_cache_acls(struct inode *inode, struct posix_acl *acl,
                inode->i_ino, acl, dfacl);
        spin_lock(&inode->i_lock);
        __nfs3_forget_cached_acls(NFS_I(inode));
-       nfsi->acl_access = posix_acl_dup(acl);
-       nfsi->acl_default = posix_acl_dup(dfacl);
+       if (!IS_ERR(acl))
+               nfsi->acl_access = posix_acl_dup(acl);
+       if (!IS_ERR(dfacl))
+               nfsi->acl_default = posix_acl_dup(dfacl);
        spin_unlock(&inode->i_lock);
 }
 
@@ -203,6 +207,8 @@ struct posix_acl *nfs3_proc_getacl(struct inode *inode, int type)
        status = nfs_revalidate_inode(server, inode);
        if (status < 0)
                return ERR_PTR(status);
+       if (NFS_I(inode)->cache_validity & NFS_INO_INVALID_ACL)
+               nfs_zap_acl_cache(inode);
        acl = nfs3_get_cached_acl(inode, type);
        if (acl != ERR_PTR(-EAGAIN))
                return acl;
@@ -223,6 +229,7 @@ struct posix_acl *nfs3_proc_getacl(struct inode *inode, int type)
 
        dprintk("NFS call getacl\n");
        msg.rpc_proc = &server->client_acl->cl_procinfo[ACLPROC3_GETACL];
+       nfs_fattr_init(&fattr);
        status = rpc_call_sync(server->client_acl, &msg, 0);
        dprintk("NFS reply getacl: %d\n", status);
 
@@ -254,7 +261,9 @@ struct posix_acl *nfs3_proc_getacl(struct inode *inode, int type)
                        res.acl_access = NULL;
                }
        }
-       nfs3_cache_acls(inode, res.acl_access, res.acl_default);
+       nfs3_cache_acls(inode,
+               (res.mask & NFS_ACL)   ? res.acl_access  : ERR_PTR(-EINVAL),
+               (res.mask & NFS_DFACL) ? res.acl_default : ERR_PTR(-EINVAL));
 
        switch(type) {
                case ACL_TYPE_ACCESS:
@@ -313,13 +322,11 @@ static int nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl,
        }
 
        dprintk("NFS call setacl\n");
-       nfs_begin_data_update(inode);
        msg.rpc_proc = &server->client_acl->cl_procinfo[ACLPROC3_SETACL];
+       nfs_fattr_init(&fattr);
        status = rpc_call_sync(server->client_acl, &msg, 0);
-       spin_lock(&inode->i_lock);
-       NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS;
-       spin_unlock(&inode->i_lock);
-       nfs_end_data_update(inode);
+       nfs_access_zap_cache(inode);
+       nfs_zap_acl_cache(inode);
        dprintk("NFS reply setacl: %d\n", status);
 
        /* pages may have been allocated at the xdr layer. */
@@ -329,6 +336,7 @@ static int nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl,
        switch (status) {
                case 0:
                        status = nfs_refresh_inode(inode, &fattr);
+                       nfs3_cache_acls(inode, acl, dfacl);
                        break;
                case -EPFNOSUPPORT:
                case -EPROTONOSUPPORT: