From: Trond Myklebust Date: Fri, 10 Aug 2007 17:45:12 -0400 Subject: NFS: Make rpc_ops->access return attributes to the caller Now that both NFSv3 and NFSv4 return attributes as part of the ACCESS call, we can move the common code into nfs_do_access(). Signed-off-by: Trond Myklebust --- fs/nfs/dir.c | 7 ++++++- fs/nfs/nfs3proc.c | 8 +++----- fs/nfs/nfs4proc.c | 12 +++++------- include/linux/nfs_xdr.h | 3 ++- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 476cb0f..4cb6e36 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -1890,6 +1890,7 @@ static void nfs_access_add_cache(struct inode *inode, struct nfs_access_entry *s static int nfs_do_access(struct inode *inode, struct rpc_cred *cred, int mask) { struct nfs_access_entry cache; + struct nfs_fattr fattr; int status; status = nfs_access_get_cached(inode, cred, &cache); @@ -1900,9 +1901,13 @@ static int nfs_do_access(struct inode *inode, struct rpc_cred *cred, int mask) cache.mask = MAY_EXEC | MAY_WRITE | MAY_READ; cache.cred = cred; cache.jiffies = jiffies; - status = NFS_PROTO(inode)->access(inode, &cache); + status = NFS_PROTO(inode)->access(inode, &cache, &fattr); if (status != 0) return status; + if ((fattr.valid & NFS_ATTR_FATTR)) + nfs_refresh_inode(inode, &fattr); + else + nfs_mark_for_revalidate(inode); nfs_access_add_cache(inode, &cache); out: if ((cache.mask & mask) == mask) diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c index 549dbce..e98ac83 100644 --- a/fs/nfs/nfs3proc.c +++ b/fs/nfs/nfs3proc.c @@ -174,14 +174,13 @@ nfs3_proc_lookup(struct inode *dir, struct qstr *name, return status; } -static int nfs3_proc_access(struct inode *inode, struct nfs_access_entry *entry) +static int nfs3_proc_access(struct inode *inode, struct nfs_access_entry *entry, struct nfs_fattr *fattr) { - struct nfs_fattr fattr; struct nfs3_accessargs arg = { .fh = NFS_FH(inode), }; struct nfs3_accessres res = { - .fattr = &fattr, + .fattr = fattr, }; struct rpc_message msg = { .rpc_proc = &nfs3_procedures[NFS3PROC_ACCESS], @@ -207,9 +206,8 @@ static int nfs3_proc_access(struct inode *inode, struct nfs_access_entry *entry) if (mode & MAY_EXEC) arg.access |= NFS3_ACCESS_EXECUTE; } - nfs_fattr_init(&fattr); + nfs_fattr_init(fattr); status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); - nfs_refresh_inode(inode, &fattr); if (status == 0) { entry->mask = 0; if (res.access & NFS3_ACCESS_READ) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 027e109..a20f960 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -1746,17 +1746,16 @@ static int nfs4_proc_lookup(struct inode *dir, struct qstr *name, struct nfs_fh return err; } -static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry) +static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry, struct nfs_fattr *fattr) { struct nfs_server *server = NFS_SERVER(inode); - struct nfs_fattr fattr; struct nfs4_accessargs args = { .fh = NFS_FH(inode), .bitmask = server->attr_bitmask, }; struct nfs4_accessres res = { .server = server, - .fattr = &fattr, + .fattr = fattr, }; struct rpc_message msg = { .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_ACCESS], @@ -1783,7 +1782,7 @@ static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry if (mode & MAY_EXEC) args.access |= NFS4_ACCESS_EXECUTE; } - nfs_fattr_init(&fattr); + nfs_fattr_init(fattr); status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); if (!status) { entry->mask = 0; @@ -1793,18 +1792,17 @@ static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry entry->mask |= MAY_WRITE; if (res.access & (NFS4_ACCESS_LOOKUP|NFS4_ACCESS_EXECUTE)) entry->mask |= MAY_EXEC; - nfs_refresh_inode(inode, &fattr); } return status; } -static int nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry) +static int nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry, struct nfs_fattr *fattr) { struct nfs4_exception exception = { }; int err; do { err = nfs4_handle_exception(NFS_SERVER(inode), - _nfs4_proc_access(inode, entry), + _nfs4_proc_access(inode, entry, fattr), &exception); } while (exception.retry); return err; diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index f301d0b..383b84f 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -790,7 +790,8 @@ struct nfs_rpc_ops { struct iattr *); int (*lookup) (struct inode *, struct qstr *, struct nfs_fh *, struct nfs_fattr *); - int (*access) (struct inode *, struct nfs_access_entry *); + int (*access) (struct inode *, struct nfs_access_entry *, + struct nfs_fattr *); int (*readlink)(struct inode *, struct page *, unsigned int, unsigned int); int (*create) (struct inode *, struct dentry *,