From: David Howells Subject: [PATCH 08/30] NFS: Add a lookupfh NFS RPC op [try #11] Date: Thu, 27 Jul 2006 21:52:44 +0100 Message-ID: <20060727205244.8443.66251.stgit@warthog.cambridge.redhat.com> References: <20060727205222.8443.29381.stgit@warthog.cambridge.redhat.com> Reply-To: Linux filesystem caching discussion list Content-Type: text/plain; charset=utf-8; format=fixed Content-Transfer-Encoding: quoted-printable Cc: linux-fsdevel@vger.kernel.org, linux-cachefs@redhat.com, nfsv4@linux-nfs.org, linux-kernel@vger.kernel.org Return-path: To: torvalds@osdl.org, akpm@osdl.org, steved@redhat.com, trond.myklebust@fys.uio.no In-Reply-To: <20060727205222.8443.29381.stgit@warthog.cambridge.redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-cachefs-bounces@redhat.com Errors-To: linux-cachefs-bounces@redhat.com List-Id: linux-fsdevel.vger.kernel.org Add a lookup filehandle NFS RPC op so that a file handle can be looked up without requiring dentries and inodes and other VFS stuff when doing an N= FS4 pathwalk during mounting. Signed-Off-By: David Howells Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 47 +++++++++++++++++++++++++++++++++++++++++= ++++++ include/linux/nfs_xdr.h | 3 +++ 2 files changed, 50 insertions(+), 0 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index eff6043..7fa2938 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -1583,6 +1583,52 @@ nfs4_proc_setattr(struct dentry *dentry, return status; } =20 +static int _nfs4_proc_lookupfh(struct nfs_server *server, struct nfs_fh = *dirfh, + struct qstr *name, struct nfs_fh *fhandle, + struct nfs_fattr *fattr) +{ + int status; + struct nfs4_lookup_arg args =3D { + .bitmask =3D server->attr_bitmask, + .dir_fh =3D dirfh, + .name =3D name, + }; + struct nfs4_lookup_res res =3D { + .server =3D server, + .fattr =3D fattr, + .fh =3D fhandle, + }; + struct rpc_message msg =3D { + .rpc_proc =3D &nfs4_procedures[NFSPROC4_CLNT_LOOKUP], + .rpc_argp =3D &args, + .rpc_resp =3D &res, + }; + + nfs_fattr_init(fattr); + + dprintk("NFS call lookupfh %s\n", name->name); + status =3D rpc_call_sync(server->client, &msg, 0); + dprintk("NFS reply lookupfh: %d\n", status); + if (status =3D=3D -NFS4ERR_MOVED) + status =3D -EREMOTE; + return status; +} + +static int nfs4_proc_lookupfh(struct nfs_server *server, struct nfs_fh *= dirfh, + struct qstr *name, struct nfs_fh *fhandle, + struct nfs_fattr *fattr) +{ + struct nfs4_exception exception =3D { }; + int err; + do { + err =3D nfs4_handle_exception(server, + _nfs4_proc_lookupfh(server, dirfh, name, + fhandle, fattr), + &exception); + } while (exception.retry); + return err; +} + static int _nfs4_proc_lookup(struct inode *dir, struct qstr *name, struct nfs_fh *fhandle, struct nfs_fattr *fattr) { @@ -3698,6 +3744,7 @@ struct nfs_rpc_ops nfs_v4_clientops =3D { .getroot =3D nfs4_proc_get_root, .getattr =3D nfs4_proc_getattr, .setattr =3D nfs4_proc_setattr, + .lookupfh =3D nfs4_proc_lookupfh, .lookup =3D nfs4_proc_lookup, .access =3D nfs4_proc_access, .readlink =3D nfs4_proc_readlink, diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index 2d3fb64..be80310 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -770,6 +770,9 @@ struct nfs_rpc_ops { =20 int (*getroot) (struct nfs_server *, struct nfs_fh *, struct nfs_fsinfo *); + int (*lookupfh)(struct nfs_server *, struct nfs_fh *, + struct qstr *, struct nfs_fh *, + struct nfs_fattr *); int (*getattr) (struct nfs_server *, struct nfs_fh *, struct nfs_fattr *); int (*setattr) (struct dentry *, struct nfs_fattr *,