Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/nfs/nfs_subs.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/nfs/nfs_subs.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.170.2.1 retrieving revision 1.170.2.2 diff -u -p -r1.170.2.1 -r1.170.2.2 --- src/sys/nfs/nfs_subs.c 2006/11/18 21:39:44 1.170.2.1 +++ src/sys/nfs/nfs_subs.c 2007/01/12 01:04:19 1.170.2.2 @@ -1,4 +1,4 @@ -/* $NetBSD: nfs_subs.c,v 1.170.2.1 2006/11/18 21:39:44 ad Exp $ */ +/* $NetBSD: nfs_subs.c,v 1.170.2.2 2007/01/12 01:04:19 ad Exp $ */ /* * Copyright (c) 1989, 1993 @@ -70,7 +70,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nfs_subs.c,v 1.170.2.1 2006/11/18 21:39:44 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nfs_subs.c,v 1.170.2.2 2007/01/12 01:04:19 ad Exp $"); #include "fs_nfs.h" #include "opt_nfs.h" @@ -109,7 +109,6 @@ __KERNEL_RCSID(0, "$NetBSD: nfs_subs.c,v #include #include #include -#include #include #include @@ -128,7 +127,7 @@ u_int32_t nfs_xdrneg1; u_int32_t rpc_call, rpc_vers, rpc_reply, rpc_msgdenied, rpc_autherr, rpc_mismatch, rpc_auth_unix, rpc_msgaccepted, rpc_auth_kerb; -u_int32_t nfs_prog, nqnfs_prog, nfs_true, nfs_false; +u_int32_t nfs_prog, nfs_true, nfs_false; /* And other global data */ const nfstype nfsv2_type[9] = @@ -173,9 +172,6 @@ const int nfsv3_procid[NFS_NPROCS] = { NFSPROC_NOOP, NFSPROC_NOOP, NFSPROC_NOOP, - NFSPROC_NOOP, - NFSPROC_NOOP, - NFSPROC_NOOP, NFSPROC_NOOP }; @@ -206,9 +202,6 @@ const int nfsv2_procid[NFS_NPROCS] = { NFSV2PROC_NOOP, NFSV2PROC_NOOP, NFSV2PROC_NOOP, - NFSV2PROC_NOOP, - NFSV2PROC_NOOP, - NFSV2PROC_NOOP, }; /* @@ -571,11 +564,6 @@ static const short * const nfsrv_v3errma }; extern struct nfsrtt nfsrtt; -extern time_t nqnfsstarttime; -extern int nqsrv_clockskew; -extern int nqsrv_writeslack; -extern int nqsrv_maxlease; -extern const int nqnfs_piggy[NFS_NPROCS]; extern struct nfsnodehashhead *nfsnodehashtbl; extern u_long nfsnodehash; @@ -593,11 +581,6 @@ nfsm_reqh(struct nfsnode *np, u_long pro { struct mbuf *mb; caddr_t bpos; -#ifndef NFS_V2_ONLY - struct nfsmount *nmp; - u_int32_t *tl; - int nqflag; -#endif mb = m_get(M_WAIT, MT_DATA); MCLAIM(mb, &nfs_mowner); @@ -606,25 +589,6 @@ nfsm_reqh(struct nfsnode *np, u_long pro mb->m_len = 0; bpos = mtod(mb, caddr_t); -#ifndef NFS_V2_ONLY - /* - * For NQNFS, add lease request. - */ - if (np) { - nmp = VFSTONFS(np->n_vnode->v_mount); - if (nmp->nm_flag & NFSMNT_NQNFS) { - nqflag = NQNFS_NEEDLEASE(np, procid); - if (nqflag) { - nfsm_build(tl, u_int32_t *, 2*NFSX_UNSIGNED); - *tl++ = txdr_unsigned(nqflag); - *tl = txdr_unsigned(nmp->nm_leaseterm); - } else { - nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); - *tl = 0; - } - } - } -#endif /* Finally, return values */ *bposp = bpos; return (mb); @@ -681,16 +645,11 @@ nfsm_rpchead(cr, nmflag, procid, auth_ty *tl++ = *xidp = nfs_getxid(); *tl++ = rpc_call; *tl++ = rpc_vers; - if (nmflag & NFSMNT_NQNFS) { - *tl++ = txdr_unsigned(NQNFS_PROG); - *tl++ = txdr_unsigned(NQNFS_VER3); - } else { - *tl++ = txdr_unsigned(NFS_PROG); - if (nmflag & NFSMNT_NFSV3) - *tl++ = txdr_unsigned(NFS_VER3); - else - *tl++ = txdr_unsigned(NFS_VER2); - } + *tl++ = txdr_unsigned(NFS_PROG); + if (nmflag & NFSMNT_NFSV3) + *tl++ = txdr_unsigned(NFS_VER3); + else + *tl++ = txdr_unsigned(NFS_VER2); if (nmflag & NFSMNT_NFSV3) *tl++ = txdr_unsigned(procid); else @@ -1543,7 +1502,6 @@ nfs_init0(void) rpc_auth_unix = txdr_unsigned(RPCAUTH_UNIX); rpc_auth_kerb = txdr_unsigned(RPCAUTH_KERB4); nfs_prog = txdr_unsigned(NFS_PROG); - nqnfs_prog = txdr_unsigned(NQNFS_PROG); nfs_true = txdr_unsigned(TRUE); nfs_false = txdr_unsigned(FALSE); nfs_xdrneg1 = txdr_unsigned(-1); @@ -1559,20 +1517,6 @@ nfs_init0(void) nfsdreq_init(); #endif /* defined(NFSSERVER) || (defined(NFS) && !defined(NFS_V2_ONLY)) */ -#if defined(NFSSERVER) || !defined(NFS_V2_ONLY) - /* - * Initialize the nqnfs data structures. - */ - if (nqnfsstarttime == 0) { - nqnfsstarttime = boottime.tv_sec + nqsrv_maxlease - + nqsrv_clockskew + nqsrv_writeslack; - NQLOADNOVRAM(nqnfsstarttime); - CIRCLEQ_INIT(&nqtimerhead); - nqfhhashtbl = hashinit(NQLCHSZ, HASH_LIST, M_NQLEASE, - M_WAITOK, &nqfhhash); - } -#endif - exithook_establish(nfs_exit, NULL); /* @@ -2104,7 +2048,7 @@ nfs_namei(ndp, nsfh, len, slp, nam, mdp, int error, rdonly, linklen; struct componentname *cnp = &ndp->ni_cnd; - *retdirp = (struct vnode *)0; + *retdirp = NULL; if ((len + 1) > MAXPATHLEN) return (ENAMETOOLONG); @@ -2189,6 +2133,7 @@ nfs_namei(ndp, nsfh, len, slp, nam, mdp, */ default: error = EIO; + vrele(dp); PNBUF_PUT(cp); goto out; } @@ -2205,6 +2150,7 @@ nfs_namei(ndp, nsfh, len, slp, nam, mdp, continue; } else { error = ENOENT; + vrele(dp); PNBUF_PUT(cp); goto out; } @@ -2230,35 +2176,45 @@ nfs_namei(ndp, nsfh, len, slp, nam, mdp, cnp->cn_lwp = l; VREF(dp); + vn_lock(dp, LK_EXCLUSIVE | LK_RETRY); for (;;) { cnp->cn_nameptr = cnp->cn_pnbuf; ndp->ni_startdir = dp; + /* * And call lookup() to do the real work */ error = lookup(ndp); if (error) { + if (ndp->ni_dvp) { + vput(ndp->ni_dvp); + } PNBUF_PUT(cnp->cn_pnbuf); return (error); } + /* * Check for encountering a symbolic link */ if ((cnp->cn_flags & ISSYMLINK) == 0) { + if ((cnp->cn_flags & LOCKPARENT) == 0 && ndp->ni_dvp) { + if (ndp->ni_dvp == ndp->ni_vp) { + vrele(ndp->ni_dvp); + } else { + vput(ndp->ni_dvp); + } + } if (cnp->cn_flags & (SAVENAME | SAVESTART)) cnp->cn_flags |= HASBUF; else PNBUF_PUT(cnp->cn_pnbuf); return (0); } else { - if ((cnp->cn_flags & LOCKPARENT) && (cnp->cn_flags & ISLASTCN)) - VOP_UNLOCK(ndp->ni_dvp, 0); if (!pubflag) { error = EINVAL; break; } - if (ndp->ni_loopcnt++ >= MAXSYMLINKS) { error = ELOOP; break; @@ -2283,7 +2239,7 @@ nfs_namei(ndp, nsfh, len, slp, nam, mdp, UIO_SETUP_SYSSPACE(&auio); error = VOP_READLINK(ndp->ni_vp, &auio, cnp->cn_cred); if (error) { - badlink: +badlink: if (ndp->ni_pathlen > 1) PNBUF_PUT(cp); break; @@ -2306,17 +2262,19 @@ nfs_namei(ndp, nsfh, len, slp, nam, mdp, ndp->ni_pathlen += linklen; vput(ndp->ni_vp); dp = ndp->ni_dvp; + /* * Check if root directory should replace current directory. */ if (cnp->cn_pnbuf[0] == '/') { - vrele(dp); + vput(dp); dp = ndp->ni_rootdir; VREF(dp); + vn_lock(dp, LK_EXCLUSIVE | LK_RETRY); } } } - vrele(ndp->ni_dvp); + vput(ndp->ni_dvp); vput(ndp->ni_vp); ndp->ni_vp = NULL; out: