diff options
Diffstat (limited to 'sys/nfs/nfs_nqlease.c')
-rw-r--r-- | sys/nfs/nfs_nqlease.c | 325 |
1 files changed, 201 insertions, 124 deletions
diff --git a/sys/nfs/nfs_nqlease.c b/sys/nfs/nfs_nqlease.c index c128d1793fd..ef628160a12 100644 --- a/sys/nfs/nfs_nqlease.c +++ b/sys/nfs/nfs_nqlease.c @@ -1,5 +1,5 @@ -/* $OpenBSD: nfs_nqlease.c,v 1.3 1996/02/29 09:24:51 niklas Exp $ */ -/* $NetBSD: nfs_nqlease.c,v 1.12 1996/02/09 21:48:26 christos Exp $ */ +/* $OpenBSD: nfs_nqlease.c,v 1.4 1996/03/31 13:15:38 mickey Exp $ */ +/* $NetBSD: nfs_nqlease.c,v 1.14 1996/02/18 14:06:50 fvdl Exp $ */ /* * Copyright (c) 1992, 1993 @@ -36,7 +36,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)nfs_nqlease.c 8.5 (Berkeley) 8/18/94 + * @(#)nfs_nqlease.c 8.9 (Berkeley) 5/20/95 */ /* @@ -68,7 +68,7 @@ #include <netinet/in.h> #include <nfs/rpcv2.h> -#include <nfs/nfsv2.h> +#include <nfs/nfsproto.h> #include <nfs/nfs.h> #include <nfs/nfsm_subs.h> #include <nfs/xdr_subs.h> @@ -78,7 +78,6 @@ #include <nfs/nfs_var.h> time_t nqnfsstarttime = (time_t)0; -u_int32_t nqnfs_prog, nqnfs_vers; int nqsrv_clockskew = NQ_CLOCKSKEW; int nqsrv_writeslack = NQ_WRITESLACK; int nqsrv_maxlease = NQ_MAXLEASE; @@ -89,14 +88,13 @@ int nqsrv_maxnumlease = NQ_MAXNUMLEASE; */ int nqnfs_piggy[NFS_NPROCS] = { 0, - NQL_READ, - NQL_WRITE, 0, - NQL_READ, - NQL_READ, - NQL_READ, + ND_WRITE, + ND_READ, 0, - NQL_WRITE, + ND_READ, + ND_READ, + ND_WRITE, 0, 0, 0, @@ -104,24 +102,31 @@ int nqnfs_piggy[NFS_NPROCS] = { 0, 0, 0, - NQL_READ, 0, - NQL_READ, + ND_READ, + ND_READ, + 0, + 0, + 0, + 0, 0, 0, 0, 0, }; -extern nfstype nfs_type[9]; +extern nfstype nfsv2_type[9]; +extern nfstype nfsv3_type[9]; extern struct nfssvc_sock *nfs_udpsock, *nfs_cltpsock; extern int nfsd_waiting; +extern struct nfsstats nfsstats; + #define TRUE 1 #define FALSE 0 /* - * Get or check for a lease for "vp", based on NQL_CHECK flag. + * Get or check for a lease for "vp", based on ND_CHECK flag. * The rules are as follows: * - if a current non-caching lease, reply non-caching * - if a current lease for same host only, extend lease @@ -144,11 +149,12 @@ extern int nfsd_waiting; * queue yet. (Ditto for the splsoftclock() and splx(s) calls) */ int -nqsrv_getlease(vp, duration, flags, nd, nam, cachablep, frev, cred) +nqsrv_getlease(vp, duration, flags, slp, procp, nam, cachablep, frev, cred) struct vnode *vp; - u_int *duration; + u_int32_t *duration; int flags; - struct nfsd *nd; + struct nfssvc_sock *slp; + struct proc *procp; struct mbuf *nam; int *cachablep; u_quad_t *frev; @@ -167,19 +173,21 @@ nqsrv_getlease(vp, duration, flags, nd, nam, cachablep, frev, cred) return (0); if (*duration > nqsrv_maxlease) *duration = nqsrv_maxlease; - if ((error = VOP_GETATTR(vp, &vattr, cred, nd->nd_procp)) != 0) + error = VOP_GETATTR(vp, &vattr, cred, procp); + if (error) return (error); *frev = vattr.va_filerev; s = splsoftclock(); tlp = vp->v_lease; - if ((flags & NQL_CHECK) == 0) + if ((flags & ND_CHECK) == 0) nfsstats.srvnqnfs_getleases++; if (tlp == 0) { /* * Find the lease by searching the hash list. */ fh.fh_fsid = vp->v_mount->mnt_stat.f_fsid; - if ((error = VFS_VPTOFH(vp, &fh.fh_fid)) != 0) { + error = VFS_VPTOFH(vp, &fh.fh_fid); + if (error) { splx(s); return (error); } @@ -200,12 +208,12 @@ nqsrv_getlease(vp, duration, flags, nd, nam, cachablep, frev, cred) if (lp != 0) { if ((lp->lc_flag & LC_NONCACHABLE) || (lp->lc_morehosts == (struct nqm *)0 && - nqsrv_cmpnam(nd->nd_slp, nam, &lp->lc_host))) + nqsrv_cmpnam(slp, nam, &lp->lc_host))) goto doreply; - if ((flags & NQL_READ) && (lp->lc_flag & LC_WRITE) == 0) { - if (flags & NQL_CHECK) + if ((flags & ND_READ) && (lp->lc_flag & LC_WRITE) == 0) { + if (flags & ND_CHECK) goto doreply; - if (nqsrv_cmpnam(nd->nd_slp, nam, &lp->lc_host)) + if (nqsrv_cmpnam(slp, nam, &lp->lc_host)) goto doreply; i = 0; if (lp->lc_morehosts) { @@ -217,7 +225,7 @@ nqsrv_getlease(vp, duration, flags, nd, nam, cachablep, frev, cred) ok = 0; } while (ok && (lph->lph_flag & LC_VALID)) { - if (nqsrv_cmpnam(nd->nd_slp, nam, lph)) + if (nqsrv_cmpnam(slp, nam, lph)) goto doreply; if (++i == LC_MOREHOSTSIZ) { i = 0; @@ -237,12 +245,12 @@ nqsrv_getlease(vp, duration, flags, nd, nam, cachablep, frev, cred) bzero((caddr_t)*lphp, sizeof (struct nqm)); lph = (*lphp)->lpm_hosts; } - nqsrv_addhost(lph, nd->nd_slp, nam); + nqsrv_addhost(lph, slp, nam); nqsrv_unlocklease(lp); } else { lp->lc_flag |= LC_NONCACHABLE; nqsrv_locklease(lp); - nqsrv_send_eviction(vp, lp, nd->nd_slp, nam, cred); + nqsrv_send_eviction(vp, lp, slp, nam, cred); nqsrv_waitfor_expiry(lp); nqsrv_unlocklease(lp); } @@ -250,20 +258,20 @@ doreply: /* * Update the lease and return */ - if ((flags & NQL_CHECK) == 0) + if ((flags & ND_CHECK) == 0) nqsrv_instimeq(lp, *duration); if (lp->lc_flag & LC_NONCACHABLE) *cachablep = 0; else { *cachablep = 1; - if (flags & NQL_WRITE) + if (flags & ND_WRITE) lp->lc_flag |= LC_WRITTEN; } splx(s); return (0); } splx(s); - if (flags & NQL_CHECK) + if (flags & ND_CHECK) return (0); /* @@ -280,13 +288,15 @@ doreply: } MALLOC(lp, struct nqlease *, sizeof (struct nqlease), M_NQLEASE, M_WAITOK); bzero((caddr_t)lp, sizeof (struct nqlease)); - if (flags & NQL_WRITE) + if (flags & ND_WRITE) lp->lc_flag |= (LC_WRITE | LC_WRITTEN); - nqsrv_addhost(&lp->lc_host, nd->nd_slp, nam); + nqsrv_addhost(&lp->lc_host, slp, nam); lp->lc_vp = vp; lp->lc_fsid = fh.fh_fsid; bcopy(fh.fh_fid.fid_data, lp->lc_fiddata, fh.fh_fid.fid_len - sizeof (int32_t)); + if(!lpp) + panic("nfs_nqlease.c: Phoney lpp"); LIST_INSERT_HEAD(lpp, lp, lc_hash); vp->v_lease = lp; s = splsoftclock(); @@ -303,7 +313,7 @@ doreply: * Just set up args and let nqsrv_getlease() do the rest. */ int -lease_check(v) +nqnfs_vop_lease_check(v) void *v; { struct vop_lease_args /* { @@ -312,15 +322,13 @@ lease_check(v) struct ucred *a_cred; int a_flag; } */ *ap = v; - int duration = 0, cache; - struct nfsd nfsd; + u_int32_t duration = 0; + int cache; u_quad_t frev; - nfsd.nd_slp = NQLOCALSLP; - nfsd.nd_procp = ap->a_p; - (void) nqsrv_getlease(ap->a_vp, &duration, NQL_CHECK | ap->a_flag, - &nfsd, (struct mbuf *)0, &cache, &frev, ap->a_cred); - return 0; + (void) nqsrv_getlease(ap->a_vp, &duration, ND_CHECK | ap->a_flag, + NQLOCALSLP, ap->a_p, (struct mbuf *)0, &cache, &frev, ap->a_cred); + return (0); } /* @@ -357,7 +365,7 @@ nqsrv_addhost(lph, slp, nam) void nqsrv_instimeq(lp, duration) register struct nqlease *lp; - u_long duration; + u_int32_t duration; { register struct nqlease *tlp; time_t newexpiry; @@ -375,8 +383,10 @@ nqsrv_instimeq(lp, duration) tlp = nqtimerhead.cqh_last; while (tlp != (void *)&nqtimerhead && tlp->lc_expiry > newexpiry) tlp = tlp->lc_timer.cqe_prev; +#ifdef HASNVRAM if (tlp == nqtimerhead.cqh_last) NQSTORENOVRAM(newexpiry); +#endif /* HASNVRAM */ if (tlp == (void *)&nqtimerhead) { CIRCLEQ_INSERT_HEAD(&nqtimerhead, lp, lc_timer); } else { @@ -479,9 +489,9 @@ nqsrv_send_eviction(vp, lp, slp, nam, cred) else solockp = (int *)0; nfsm_reqhead((struct vnode *)0, NQNFSPROC_EVICTED, - NFSX_FH); - nfsm_build(cp, caddr_t, NFSX_FH); - bzero(cp, NFSX_FH); + NFSX_V3FH); + nfsm_build(cp, caddr_t, NFSX_V3FH); + bzero(cp, NFSX_V3FH); fhp = (fhandle_t *)cp; fhp->fh_fsid = vp->v_mount->mnt_stat.f_fsid; VFS_VPTOFH(vp, &fhp->fh_fid); @@ -495,9 +505,10 @@ nqsrv_send_eviction(vp, lp, slp, nam, cred) printf("mbuf siz=%d\n",siz); panic("Bad nfs svc reply"); } - m = nfsm_rpchead(cred, TRUE, NQNFSPROC_EVICTED, - RPCAUTH_UNIX, 5*NFSX_UNSIGNED, (char *)0, - mreq, siz, &mheadend, &xid); + m = nfsm_rpchead(cred, (NFSMNT_NFSV3 | NFSMNT_NQNFS), + NQNFSPROC_EVICTED, + RPCAUTH_UNIX, 5 * NFSX_UNSIGNED, (char *)0, + 0, (char *)0, mreq, siz, &mheadend, &xid); /* * For stream protocols, prepend a Sun RPC * Record Mark. @@ -671,17 +682,20 @@ nqnfs_serverd() * do the real work. */ int -nqnfsrv_getlease(nfsd, mrep, md, dpos, cred, nam, mrq) - struct nfsd *nfsd; - struct mbuf *mrep, *md; - caddr_t dpos; - struct ucred *cred; - struct mbuf *nam, **mrq; +nqnfsrv_getlease(nfsd, slp, procp, mrq) + struct nfsrv_descript *nfsd; + struct nfssvc_sock *slp; + struct proc *procp; + struct mbuf **mrq; { - register struct nfsv2_fattr *fp; + struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; + struct mbuf *nam = nfsd->nd_nam; + caddr_t dpos = nfsd->nd_dpos; + struct ucred *cred = &nfsd->nd_cr; + register struct nfs_fattr *fp; struct vattr va; struct vnode *vp; - nfsv2fh_t nfh; + nfsfh_t nfh; fhandle_t *fhp; register u_int32_t *tl; register int32_t t1; @@ -694,28 +708,29 @@ nqnfsrv_getlease(nfsd, mrep, md, dpos, cred, nam, mrq) fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); - nfsm_dissect(tl, u_int32_t *, 2*NFSX_UNSIGNED); + nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); flags = fxdr_unsigned(int, *tl++); nfsd->nd_duration = fxdr_unsigned(int, *tl); - error = nfsrv_fhtovp(fhp, - TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly); + error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, &rdonly, + (nfsd->nd_flag & ND_KERBAUTH)); if (error) nfsm_reply(0); - if (rdonly && flags == NQL_WRITE) { + if (rdonly && flags == ND_WRITE) { + vput(vp); error = EROFS; nfsm_reply(0); } - (void) nqsrv_getlease(vp, &nfsd->nd_duration, flags, nfsd, + (void) nqsrv_getlease(vp, &nfsd->nd_duration, flags, slp, procp, nam, &cache, &frev, cred); - error = VOP_GETATTR(vp, &va, cred, nfsd->nd_procp); + error = VOP_GETATTR(vp, &va, cred, procp); vput(vp); - nfsm_reply(NFSX_NQFATTR + 4*NFSX_UNSIGNED); - nfsm_build(tl, u_int32_t *, 4*NFSX_UNSIGNED); + nfsm_reply(NFSX_V3FATTR + 4 * NFSX_UNSIGNED); + nfsm_build(tl, u_int32_t *, 4 * NFSX_UNSIGNED); *tl++ = txdr_unsigned(cache); *tl++ = txdr_unsigned(nfsd->nd_duration); txdr_hyper(&frev, tl); - nfsm_build(fp, struct nfsv2_fattr *, NFSX_NQFATTR); - nfsm_srvfillattr; + nfsm_build(fp, struct nfs_fattr *, NFSX_V3FATTR); + nfsm_srvfillattr(&va, fp); nfsm_srvdone; } @@ -724,23 +739,27 @@ nqnfsrv_getlease(nfsd, mrep, md, dpos, cred, nam, mrq) * client. Find the entry and expire it. */ int -nqnfsrv_vacated(nfsd, mrep, md, dpos, cred, nam, mrq) - struct nfsd *nfsd; - struct mbuf *mrep, *md; - caddr_t dpos; - struct ucred *cred; - struct mbuf *nam, **mrq; +nqnfsrv_vacated(nfsd, slp, procp, mrq) + struct nfsrv_descript *nfsd; + struct nfssvc_sock *slp; + struct proc *procp; + struct mbuf **mrq; { + struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; + struct mbuf *nam = nfsd->nd_nam; + caddr_t dpos = nfsd->nd_dpos; register struct nqlease *lp; register struct nqhost *lph; struct nqlease *tlp = (struct nqlease *)0; - nfsv2fh_t nfh; + nfsfh_t nfh; fhandle_t *fhp; register u_int32_t *tl; register int32_t t1; struct nqm *lphnext; - int error = 0, i, len, ok, gotit = 0; - char *cp2; + struct mbuf *mreq, *mb; + int error = 0, i, len, ok, gotit = 0, cache = 0; + char *cp2, *bpos; + u_quad_t frev; fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); @@ -766,7 +785,7 @@ nqnfsrv_vacated(nfsd, mrep, md, dpos, cred, nam, mrq) lphnext = lp->lc_morehosts; ok = 1; while (ok && (lph->lph_flag & LC_VALID)) { - if (nqsrv_cmpnam(nfsd->nd_slp, nam, lph)) { + if (nqsrv_cmpnam(slp, nam, lph)) { lph->lph_flag |= LC_VACATED; gotit++; break; @@ -806,7 +825,7 @@ nqnfs_getlease(vp, rwflag, cred, p) { register u_int32_t *tl; register caddr_t cp; - register int32_t t1; + register int32_t t1, t2; register struct nfsnode *np; struct nfsmount *nmp = VFSTONFS(vp->v_mount); caddr_t bpos, dpos, cp2; @@ -817,16 +836,16 @@ nqnfs_getlease(vp, rwflag, cred, p) u_quad_t frev; nfsstats.rpccnt[NQNFSPROC_GETLEASE]++; - mb = mreq = nfsm_reqh(vp, NQNFSPROC_GETLEASE, NFSX_FH+2*NFSX_UNSIGNED, + mb = mreq = nfsm_reqh(vp, NQNFSPROC_GETLEASE, NFSX_V3FH+2*NFSX_UNSIGNED, &bpos); - nfsm_fhtom(vp); - nfsm_build(tl, u_int32_t *, 2*NFSX_UNSIGNED); + nfsm_fhtom(vp, 1); + nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); *tl++ = txdr_unsigned(rwflag); *tl = txdr_unsigned(nmp->nm_leaseterm); reqtime = time.tv_sec; nfsm_request(vp, NQNFSPROC_GETLEASE, p, cred); np = VTONFS(vp); - nfsm_dissect(tl, u_int32_t *, 4*NFSX_UNSIGNED); + nfsm_dissect(tl, u_int32_t *, 4 * NFSX_UNSIGNED); cachable = fxdr_unsigned(int, *tl++); reqtime += fxdr_unsigned(int, *tl++); if (reqtime > time.tv_sec) { @@ -850,6 +869,8 @@ nqnfs_vacated(vp, cred) register caddr_t cp; register struct mbuf *m; register int i; + register u_int32_t *tl; + register int32_t t2; caddr_t bpos; u_int32_t xid; int error = 0; @@ -859,17 +880,17 @@ nqnfs_vacated(vp, cred) nmp = VFSTONFS(vp->v_mount); nfsstats.rpccnt[NQNFSPROC_VACATED]++; - nfsm_reqhead(vp, NQNFSPROC_VACATED, NFSX_FH); - nfsm_fhtom(vp); + nfsm_reqhead(vp, NQNFSPROC_VACATED, NFSX_V3FH); + nfsm_fhtom(vp, 1); m = mreq; i = 0; while (m) { i += m->m_len; m = m->m_next; } - m = nfsm_rpchead(cred, TRUE, NQNFSPROC_VACATED, - RPCAUTH_UNIX, 5*NFSX_UNSIGNED, (char *)0, - mreq, i, &mheadend, &xid); + m = nfsm_rpchead(cred, nmp->nm_flag, NQNFSPROC_VACATED, + RPCAUTH_UNIX, 5 * NFSX_UNSIGNED, (char *)0, + 0, (char *)0, mreq, i, &mheadend, &xid); if (nmp->nm_sotype == SOCK_STREAM) { M_PREPEND(m, NFSX_UNSIGNED, M_WAIT); *mtod(m, u_int32_t *) = htonl(0x80000000 | (m->m_pkthdr.len - @@ -882,6 +903,7 @@ nqnfs_vacated(vp, cred) (void) nfs_send(nmp->nm_so, nmp->nm_nam, m, &myrep); if (nmp->nm_soflags & PR_CONNREQUIRED) nfs_sndunlock(&nmp->nm_flag); +nfsmout: return (error); } @@ -897,28 +919,37 @@ nqnfs_callback(nmp, mrep, md, dpos) register struct vnode *vp; register u_int32_t *tl; register int32_t t1; - nfsv2fh_t nfh; + nfsfh_t nfh; fhandle_t *fhp; struct nfsnode *np; - struct nfsd nd; - int error; - char *cp2; + struct nfsd tnfsd; + struct nfssvc_sock *slp; + struct nfsrv_descript ndesc; + register struct nfsrv_descript *nfsd = &ndesc; + struct mbuf **mrq = (struct mbuf **)0, *mb, *mreq; + int error = 0, cache = 0; + char *cp2, *bpos; + u_quad_t frev; - nd.nd_mrep = mrep; - nd.nd_md = md; - nd.nd_dpos = dpos; - if ((error = nfs_getreq(&nd, FALSE)) != 0) +#ifndef nolint + slp = NULL; +#endif + nfsd->nd_mrep = mrep; + nfsd->nd_md = md; + nfsd->nd_dpos = dpos; + error = nfs_getreq(nfsd, &tnfsd, FALSE); + if (error) return (error); - md = nd.nd_md; - dpos = nd.nd_dpos; - if (nd.nd_procnum != NQNFSPROC_EVICTED) { + md = nfsd->nd_md; + dpos = nfsd->nd_dpos; + if (nfsd->nd_procnum != NQNFSPROC_EVICTED) { m_freem(mrep); return (EPERM); } fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); m_freem(mrep); - error = nfs_nget(nmp->nm_mountp, (nfsv2fh_t *) fhp, &np); + error = nfs_nget(nmp->nm_mountp, (nfsfh_t *)fhp, NFSX_V3FH, &np); if (error) return (error); vp = NFSTOV(np); @@ -953,35 +984,39 @@ nqnfs_clientd(nmp, cred, ncd, flag, argp, p) register struct nfsnode *np; struct vnode *vp; struct nfsreq myrep; + struct nfsuid *nuidp, *nnuidp; int error = 0, vpid; /* * First initialize some variables */ - nqnfs_prog = txdr_unsigned(NQNFS_PROG); - nqnfs_vers = txdr_unsigned(NQNFS_VER1); /* * If an authorization string is being passed in, get it. */ if ((flag & NFSSVC_GOTAUTH) && - (nmp->nm_flag & (NFSMNT_WAITAUTH | NFSMNT_DISMNT)) == 0) { - if (nmp->nm_flag & NFSMNT_HASAUTH) - panic("cld kerb"); - if ((flag & NFSSVC_AUTHINFAIL) == 0) { - if (ncd->ncd_authlen <= RPCAUTH_MAXSIZ && - copyin(ncd->ncd_authstr, nmp->nm_authstr, - ncd->ncd_authlen) == 0) { - nmp->nm_authtype = ncd->ncd_authtype; - nmp->nm_authlen = ncd->ncd_authlen; - } else - nmp->nm_flag |= NFSMNT_AUTHERR; + (nmp->nm_flag & (NFSMNT_WAITAUTH | NFSMNT_DISMNT)) == 0) { + if (nmp->nm_flag & NFSMNT_HASAUTH) + panic("cld kerb"); + if ((flag & NFSSVC_AUTHINFAIL) == 0) { + if (ncd->ncd_authlen <= nmp->nm_authlen && + ncd->ncd_verflen <= nmp->nm_verflen && + !copyin(ncd->ncd_authstr,nmp->nm_authstr,ncd->ncd_authlen)&& + !copyin(ncd->ncd_verfstr,nmp->nm_verfstr,ncd->ncd_verflen)){ + nmp->nm_authtype = ncd->ncd_authtype; + nmp->nm_authlen = ncd->ncd_authlen; + nmp->nm_verflen = ncd->ncd_verflen; +#ifdef NFSKERB + nmp->nm_key = ncd->ncd_key; +#endif } else - nmp->nm_flag |= NFSMNT_AUTHERR; - nmp->nm_flag |= NFSMNT_HASAUTH; - wakeup((caddr_t)&nmp->nm_authlen); + nmp->nm_flag |= NFSMNT_AUTHERR; + } else + nmp->nm_flag |= NFSMNT_AUTHERR; + nmp->nm_flag |= NFSMNT_HASAUTH; + wakeup((caddr_t)&nmp->nm_authlen); } else - nmp->nm_flag |= NFSMNT_WAITAUTH; + nmp->nm_flag |= NFSMNT_WAITAUTH; /* * Loop every second updating queue until there is a termination sig. @@ -1009,15 +1044,15 @@ nqnfs_clientd(nmp, cred, ncd, flag, argp, p) while (np != (void *)&nmp->nm_timerhead && (nmp->nm_flag & NFSMNT_DISMINPROG) == 0) { vp = NFSTOV(np); -if (strncmp(&vp->v_mount->mnt_stat.f_fstypename[0], MOUNT_NFS, MFSNAMELEN)) - panic("trash2"); vpid = vp->v_id; if (np->n_expiry < time.tv_sec) { +#ifdef Lite2_integrated + if (vget(vp, LK_EXCLUSIVE, p) == 0) { +#else if (vget(vp, 1) == 0) { +#endif nmp->nm_inprog = vp; if (vpid == vp->v_id) { -if (strncmp(&vp->v_mount->mnt_stat.f_fstypename[0], MOUNT_NFS, MFSNAMELEN)) - panic("trash3"); CIRCLEQ_REMOVE(&nmp->nm_timerhead, np, n_timer); np->n_timer.cqe_next = 0; if ((np->n_flag & (NMODIFIED | NQNFSEVICTED)) @@ -1040,11 +1075,14 @@ if (strncmp(&vp->v_mount->mnt_stat.f_fstypename[0], MOUNT_NFS, MFSNAMELEN)) } else if ((np->n_expiry - NQ_RENEWAL) < time.tv_sec) { if ((np->n_flag & (NQNFSWRITE | NQNFSNONCACHE)) == NQNFSWRITE && vp->v_dirtyblkhd.lh_first && +#ifdef Lite2_integrated + vget(vp, LK_EXCLUSIVE, p) == 0) { +#else vget(vp, 1) == 0) { +#endif nmp->nm_inprog = vp; -if (strncmp(&vp->v_mount->mnt_stat.f_fstypename[0], MOUNT_NFS, MFSNAMELEN)) panic("trash4"); if (vpid == vp->v_id && - nqnfs_getlease(vp, NQL_WRITE, cred, p)==0) + nqnfs_getlease(vp, ND_WRITE, cred, p)==0) np->n_brev = np->n_lrev; vrele(vp); nmp->nm_inprog = NULLVP; @@ -1079,6 +1117,16 @@ if (strncmp(&vp->v_mount->mnt_stat.f_fstypename[0], MOUNT_NFS, MFSNAMELEN)) pani (void) dounmount(nmp->nm_mountp, MNT_FORCE, p); } } + + /* + * Finally, we can free up the mount structure. + */ + for (nuidp = nmp->nm_uidlruhead.tqh_first; nuidp != 0; nuidp = nnuidp) { + nnuidp = nuidp->nu_lru.tqe_next; + LIST_REMOVE(nuidp, nu_hash); + TAILQ_REMOVE(&nmp->nm_uidlruhead, nuidp, nu_lru); + free((caddr_t)nuidp, M_NFSUID); + } free((caddr_t)nmp, M_NFSMNT); if (error == EWOULDBLOCK) error = 0; @@ -1100,9 +1148,9 @@ nqnfs_clientlease(nmp, np, rwflag, cachable, expiry, frev) if (np->n_timer.cqe_next != 0) { CIRCLEQ_REMOVE(&nmp->nm_timerhead, np, n_timer); - if (rwflag == NQL_WRITE) + if (rwflag == ND_WRITE) np->n_flag |= NQNFSWRITE; - } else if (rwflag == NQL_READ) + } else if (rwflag == ND_READ) np->n_flag &= ~NQNFSWRITE; else np->n_flag |= NQNFSWRITE; @@ -1128,7 +1176,7 @@ nqnfs_clientlease(nmp, np, rwflag, cachable, expiry, frev) * Called from the settimeofday() syscall. */ void -lease_updatetime(deltat) +nqnfs_lease_updatetime(deltat) register int deltat; { register struct nqlease *lp; @@ -1136,6 +1184,10 @@ lease_updatetime(deltat) struct mount *mp; struct nfsmount *nmp; int s; +#ifdef Lite2_integrated + struct proc *p = curproc; /* XXX */ + struct mount *nxtmp; +#endif if (nqnfsstarttime != 0) nqnfsstarttime += deltat; @@ -1149,6 +1201,30 @@ lease_updatetime(deltat) * Search the mount list for all nqnfs mounts and do their timer * queues. */ +#ifdef Lite2_integrated + simple_lock(&mountlist_slock); + for (mp = mountlist.cqh_first; mp != (void *)&mountlist; mp = nxtmp) { + if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) { + nxtmp = mp->mnt_list.cqe_next; + continue; + } + if (!strncmp(&mp->mnt_stat.f_fstypename[0], MOUNT_NFS, + MFSNAMELEN)) { + nmp = VFSTONFS(mp); + if (nmp->nm_flag & NFSMNT_NQNFS) { + for (np = nmp->nm_timerhead.cqh_first; + np != (void *)&nmp->nm_timerhead; + np = np->n_timer.cqe_next) { + np->n_expiry += deltat; + } + } + } + simple_lock(&mountlist_slock); + nxtmp = mp->mnt_list.cqe_next; + vfs_unbusy(mp, p); + } + simple_unlock(&mountlist_slock); +#else /* Lite2_integrated */ for (mp = mountlist.cqh_first; mp != (void *)&mountlist; mp = mp->mnt_list.cqe_next) { if (!strncmp(&mp->mnt_stat.f_fstypename[0], MOUNT_NFS, @@ -1163,6 +1239,7 @@ lease_updatetime(deltat) } } } +#endif } /* |