From d77942ccd46b9d83e6034e871a4c714b3ab64614 Mon Sep 17 00:00:00 2001 From: rmacklem Date: Sat, 16 Apr 2011 23:20:21 +0000 Subject: Add a lktype flags argument to nfscl_nget() and ncl_nget() in the experimental NFS client so that its nfs_lookup() function can use cn_lkflags in a manner analagous to the regular NFS client. MFC after: 2 weeks --- sys/fs/nfs/nfs_var.h | 2 +- sys/fs/nfsclient/nfs_clnode.c | 7 ++++--- sys/fs/nfsclient/nfs_clport.c | 6 +++--- sys/fs/nfsclient/nfs_clrpcops.c | 2 +- sys/fs/nfsclient/nfs_clvfsops.c | 7 ++++--- sys/fs/nfsclient/nfs_clvnops.c | 19 +++++++++++-------- sys/fs/nfsclient/nfsnode.h | 2 +- 7 files changed, 25 insertions(+), 20 deletions(-) diff --git a/sys/fs/nfs/nfs_var.h b/sys/fs/nfs/nfs_var.h index 0f8186c..153a454 100644 --- a/sys/fs/nfs/nfs_var.h +++ b/sys/fs/nfs/nfs_var.h @@ -487,7 +487,7 @@ void nfscl_cleanup(NFSPROC_T *); /* nfs_clport.c */ int nfscl_nget(mount_t, vnode_t, struct nfsfh *, - struct componentname *, NFSPROC_T *, struct nfsnode **, void *); + struct componentname *, NFSPROC_T *, struct nfsnode **, void *, int); NFSPROC_T *nfscl_getparent(NFSPROC_T *); void nfscl_start_renewthread(struct nfsclclient *); void nfscl_loadsbinfo(struct nfsmount *, struct nfsstatfs *, void *); diff --git a/sys/fs/nfsclient/nfs_clnode.c b/sys/fs/nfsclient/nfs_clnode.c index c6b212a..d4d652e 100644 --- a/sys/fs/nfsclient/nfs_clnode.c +++ b/sys/fs/nfsclient/nfs_clnode.c @@ -86,7 +86,8 @@ ncl_nhuninit(void) * nfsnode structure is returned. */ int -ncl_nget(struct mount *mntp, u_int8_t *fhp, int fhsize, struct nfsnode **npp) +ncl_nget(struct mount *mntp, u_int8_t *fhp, int fhsize, struct nfsnode **npp, + int lkflags) { struct thread *td = curthread; /* XXX */ struct nfsnode *np; @@ -106,7 +107,7 @@ ncl_nget(struct mount *mntp, u_int8_t *fhp, int fhsize, struct nfsnode **npp) M_NFSFH, M_WAITOK); bcopy(fhp, &nfhp->nfh_fh[0], fhsize); nfhp->nfh_len = fhsize; - error = vfs_hash_get(mntp, hash, LK_EXCLUSIVE, + error = vfs_hash_get(mntp, hash, lkflags, td, &nvp, newnfs_vncmpf, nfhp); FREE(nfhp, M_NFSFH); if (error) @@ -168,7 +169,7 @@ ncl_nget(struct mount *mntp, u_int8_t *fhp, int fhsize, struct nfsnode **npp) uma_zfree(newnfsnode_zone, np); return (error); } - error = vfs_hash_insert(vp, hash, LK_EXCLUSIVE, + error = vfs_hash_insert(vp, hash, lkflags, td, &nvp, newnfs_vncmpf, np->n_fhp); if (error) return (error); diff --git a/sys/fs/nfsclient/nfs_clport.c b/sys/fs/nfsclient/nfs_clport.c index f28515c..2470a8c 100644 --- a/sys/fs/nfsclient/nfs_clport.c +++ b/sys/fs/nfsclient/nfs_clport.c @@ -85,7 +85,7 @@ newnfs_vncmpf(struct vnode *vp, void *arg) int nfscl_nget(struct mount *mntp, struct vnode *dvp, struct nfsfh *nfhp, struct componentname *cnp, struct thread *td, struct nfsnode **npp, - void *stuff) + void *stuff, int lkflags) { struct nfsnode *np, *dnp; struct vnode *vp, *nvp; @@ -100,7 +100,7 @@ nfscl_nget(struct mount *mntp, struct vnode *dvp, struct nfsfh *nfhp, hash = fnv_32_buf(nfhp->nfh_fh, nfhp->nfh_len, FNV1_32_INIT); - error = vfs_hash_get(mntp, hash, LK_EXCLUSIVE, + error = vfs_hash_get(mntp, hash, lkflags, td, &nvp, newnfs_vncmpf, nfhp); if (error == 0 && nvp != NULL) { /* @@ -244,7 +244,7 @@ nfscl_nget(struct mount *mntp, struct vnode *dvp, struct nfsfh *nfhp, uma_zfree(newnfsnode_zone, np); return (error); } - error = vfs_hash_insert(vp, hash, LK_EXCLUSIVE, + error = vfs_hash_insert(vp, hash, lkflags, td, &nvp, newnfs_vncmpf, nfhp); if (error) return (error); diff --git a/sys/fs/nfsclient/nfs_clrpcops.c b/sys/fs/nfsclient/nfs_clrpcops.c index 2c75732..bb4f4ba 100644 --- a/sys/fs/nfsclient/nfs_clrpcops.c +++ b/sys/fs/nfsclient/nfs_clrpcops.c @@ -3271,7 +3271,7 @@ nfsrpc_readdirplus(vnode_t vp, struct uio *uiop, nfsuint64 *cookiep, np = dnp; } else { error = nfscl_nget(vnode_mount(vp), vp, - nfhp, cnp, p, &np, NULL); + nfhp, cnp, p, &np, NULL, LK_EXCLUSIVE); if (!error) { newvp = NFSTOV(np); unlocknewvp = 1; diff --git a/sys/fs/nfsclient/nfs_clvfsops.c b/sys/fs/nfsclient/nfs_clvfsops.c index d819527..f9c5d9e 100644 --- a/sys/fs/nfsclient/nfs_clvfsops.c +++ b/sys/fs/nfsclient/nfs_clvfsops.c @@ -273,7 +273,7 @@ nfs_statfs(struct mount *mp, struct statfs *sbp) error = vfs_busy(mp, MBF_NOWAIT); if (error) return (error); - error = ncl_nget(mp, nmp->nm_fh, nmp->nm_fhsize, &np); + error = ncl_nget(mp, nmp->nm_fh, nmp->nm_fhsize, &np, LK_EXCLUSIVE); if (error) { vfs_unbusy(mp); return (error); @@ -1221,7 +1221,8 @@ mountnfs(struct nfs_args *argp, struct mount *mp, struct sockaddr *nam, * by nfs_statfs() before any I/O occurs. */ mp->mnt_stat.f_iosize = NFS_DIRBLKSIZ; - error = ncl_nget(mp, nmp->nm_fh, nmp->nm_fhsize, &np); + error = ncl_nget(mp, nmp->nm_fh, nmp->nm_fhsize, &np, + LK_EXCLUSIVE); if (error) goto bad; *vpp = NFSTOV(np); @@ -1336,7 +1337,7 @@ nfs_root(struct mount *mp, int flags, struct vnode **vpp) int error; nmp = VFSTONFS(mp); - error = ncl_nget(mp, nmp->nm_fh, nmp->nm_fhsize, &np); + error = ncl_nget(mp, nmp->nm_fh, nmp->nm_fhsize, &np, flags); if (error) return error; vp = NFSTOV(np); diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c index 0308c7f..0260d51 100644 --- a/sys/fs/nfsclient/nfs_clvnops.c +++ b/sys/fs/nfsclient/nfs_clvnops.c @@ -1156,7 +1156,8 @@ nfs_lookup(struct vop_lookup_args *ap) FREE((caddr_t)nfhp, M_NFSFH); return (EISDIR); } - error = nfscl_nget(mp, dvp, nfhp, cnp, td, &np, NULL); + error = nfscl_nget(mp, dvp, nfhp, cnp, td, &np, NULL, + LK_EXCLUSIVE); if (error) return (error); newvp = NFSTOV(np); @@ -1185,7 +1186,8 @@ nfs_lookup(struct vop_lookup_args *ap) return (error); } VOP_UNLOCK(dvp, 0); - error = nfscl_nget(mp, dvp, nfhp, cnp, td, &np, NULL); + error = nfscl_nget(mp, dvp, nfhp, cnp, td, &np, NULL, + cnp->cn_lkflags); if (error == 0) newvp = NFSTOV(np); vfs_unbusy(mp); @@ -1213,7 +1215,8 @@ nfs_lookup(struct vop_lookup_args *ap) (void) nfscl_loadattrcache(&newvp, &nfsva, NULL, NULL, 0, 1); } else { - error = nfscl_nget(mp, dvp, nfhp, cnp, td, &np, NULL); + error = nfscl_nget(mp, dvp, nfhp, cnp, td, &np, NULL, + cnp->cn_lkflags); if (error) return (error); newvp = NFSTOV(np); @@ -1395,7 +1398,7 @@ nfs_mknodrpc(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp, NULL); if (nfhp) error = nfscl_nget(dvp->v_mount, dvp, nfhp, cnp, - cnp->cn_thread, &np, NULL); + cnp->cn_thread, &np, NULL, LK_EXCLUSIVE); } if (dattrflag) (void) nfscl_loadattrcache(&dvp, &dnfsva, NULL, NULL, 0, 1); @@ -1508,7 +1511,7 @@ again: NULL); if (nfhp != NULL) error = nfscl_nget(dvp->v_mount, dvp, nfhp, cnp, - cnp->cn_thread, &np, NULL); + cnp->cn_thread, &np, NULL, LK_EXCLUSIVE); } if (dattrflag) (void) nfscl_loadattrcache(&dvp, &dnfsva, NULL, NULL, 0, 1); @@ -1931,7 +1934,7 @@ nfs_symlink(struct vop_symlink_args *ap) &nfsva, &nfhp, &attrflag, &dattrflag, NULL); if (nfhp) { ret = nfscl_nget(dvp->v_mount, dvp, nfhp, cnp, cnp->cn_thread, - &np, NULL); + &np, NULL, LK_EXCLUSIVE); if (!ret) newvp = NFSTOV(np); else if (!error) @@ -2014,7 +2017,7 @@ nfs_mkdir(struct vop_mkdir_args *ap) dnp->n_attrstamp = 0; if (nfhp) { ret = nfscl_nget(dvp->v_mount, dvp, nfhp, cnp, cnp->cn_thread, - &np, NULL); + &np, NULL, LK_EXCLUSIVE); if (!ret) { newvp = NFSTOV(np); if (attrflag) @@ -2389,7 +2392,7 @@ printf("replace=%s\n",nnn); cn.cn_nameptr = name; cn.cn_namelen = len; error = nfscl_nget(dvp->v_mount, dvp, nfhp, &cn, td, - &np, NULL); + &np, NULL, LK_EXCLUSIVE); if (error) return (error); newvp = NFSTOV(np); diff --git a/sys/fs/nfsclient/nfsnode.h b/sys/fs/nfsclient/nfsnode.h index 204b20c..1d1c89c 100644 --- a/sys/fs/nfsclient/nfsnode.h +++ b/sys/fs/nfsclient/nfsnode.h @@ -176,7 +176,7 @@ int ncl_reclaim(struct vop_reclaim_args *); /* other stuff */ int ncl_removeit(struct sillyrename *, struct vnode *); -int ncl_nget(struct mount *, u_int8_t *, int, struct nfsnode **); +int ncl_nget(struct mount *, u_int8_t *, int, struct nfsnode **, int); nfsuint64 *ncl_getcookie(struct nfsnode *, off_t, int); void ncl_invaldir(struct vnode *); int ncl_upgrade_vnlock(struct vnode *); -- cgit v1.1