sys/nfs/nfs_nqlease.c
/*
 * Nqnfs server timer that maintains the server lease queue.
 * Scan the lease queue for expired entries:
 * - when one is found, wakeup anyone waiting for it
 *   else dequeue and free
 */
Nqnfs server timer that maintains the server lease queue.
Scan the lease queue for expired entries:
- when one is found, wakeup anyone waiting for it
else dequeue and free
Nqnfs server timer that maintains the server lease queue . Scan the lease queue for expired entries : - when one is found wakeup anyone waiting for it else dequeue and free
void
nqnfs_serverd()
{
	register struct nqlease *lp;
	register struct nqhost *lph;
	struct nqlease *nextlp;
	struct nqm *lphnext, *olphnext;
	struct mbuf *n;
	int i, len, ok;
	for (lp = nqtimerhead.cqh_first; lp != (void *)&nqtimerhead;
	    lp = nextlp) {
		if (lp->lc_expiry >= time.tv_sec)
			break;
		nextlp = lp->lc_timer.cqe_next;
		if (lp->lc_flag & LC_EXPIREDWANTED) {
			lp->lc_flag &= ~LC_EXPIREDWANTED;
			wakeup((caddr_t)&lp->lc_flag);
		} else if ((lp->lc_flag & (LC_LOCKED | LC_WANTED)) == 0) {
		    if ((lp->lc_flag & (LC_WRITE | LC_VACATED)) == LC_WRITE &&
			((lp->lc_flag & LC_WRITTEN) || nfsd_waiting == 0)) {
			lp->lc_flag &= ~LC_WRITTEN;
			nqsrv_instimeq(lp, nqsrv_writeslack);
		    } else {
			CIRCLEQ_REMOVE(&nqtimerhead, lp, lc_timer);
			LIST_REMOVE(lp, lc_hash);
			lp->lc_vp->v_lease = (struct nqlease *)0;
			lph = &lp->lc_host;
			lphnext = lp->lc_morehosts;
			olphnext = (struct nqm *)0;
			len = 1;
			i = 0;
			ok = 1;
			while (ok && (lph->lph_flag & LC_VALID)) {
				if (lph->lph_flag & LC_CLTP)
					MFREE(lph->lph_nam, n);
				if (lph->lph_flag & LC_SREF)
					nfsrv_slpderef(lph->lph_slp);
				if (++i == len) {
					if (olphnext) {
						free((caddr_t)olphnext, M_NQMHOST);
						olphnext = (struct nqm *)0;
					}
					if (lphnext) {
						olphnext = lphnext;
						i = 0;
						len = LC_MOREHOSTSIZ;
						lph = lphnext->lpm_hosts;
						lphnext = lphnext->lpm_next;
					} else
						ok = 0;
				} else
					lph++;
			}
			FREE((caddr_t)lp, M_NQLEASE);
			if (olphnext)
				free((caddr_t)olphnext, M_NQMHOST);
			nfsstats.srvnqnfs_leases--;
		    }
		}
	}
}
void nqnfs_serverd ( ) { register struct nqlease * lp ; register struct nqhost * lph ; struct nqlease * nextlp ; struct nqm * lphnext , * olphnext ; struct mbuf * n ; int i , len , ok ; for ( lp = nqtimerhead . cqh_first ; lp != ( void * ) & nqtimerhead ; lp = nextlp ) { if ( lp -> lc_expiry >= time . tv_sec ) break ; nextlp = lp -> lc_timer . cqe_next ; if ( lp -> lc_flag & LC_EXPIREDWANTED ) { lp -> lc_flag &= ~ LC_EXPIREDWANTED ; wakeup ( ( caddr_t ) & lp -> lc_flag ) ; } else if ( ( lp -> lc_flag & ( LC_LOCKED | LC_WANTED ) ) == 0 ) { if ( ( lp -> lc_flag & ( LC_WRITE | LC_VACATED ) ) == LC_WRITE && ( ( lp -> lc_flag & LC_WRITTEN ) || nfsd_waiting == 0 ) ) { lp -> lc_flag &= ~ LC_WRITTEN ; nqsrv_instimeq ( lp , nqsrv_writeslack ) ; } else { CIRCLEQ_REMOVE ( & nqtimerhead , lp , lc_timer ) ; LIST_REMOVE ( lp , lc_hash ) ; lp -> lc_vp -> v_lease = ( struct nqlease * ) 0 ; lph = & lp -> lc_host ; lphnext = lp -> lc_morehosts ; olphnext = ( struct nqm * ) 0 ; len = 1 ; i = 0 ; ok = 1 ; while ( ok && ( lph -> lph_flag & LC_VALID ) ) { if ( lph -> lph_flag & LC_CLTP ) MFREE ( lph -> lph_nam , n ) ; if ( lph -> lph_flag & LC_SREF ) nfsrv_slpderef ( lph -> lph_slp ) ; if ( ++ i == len ) { if ( olphnext ) { free ( ( caddr_t ) olphnext , M_NQMHOST ) ; olphnext = ( struct nqm * ) 0 ; } if ( lphnext ) { olphnext = lphnext ; i = 0 ; len = LC_MOREHOSTSIZ ; lph = lphnext -> lpm_hosts ; lphnext = lphnext -> lpm_next ; } else ok = 0 ; } else lph ++ ; } FREE ( ( caddr_t ) lp , M_NQLEASE ) ; if ( olphnext ) free ( ( caddr_t ) olphnext , M_NQMHOST ) ; nfsstats . srvnqnfs_leases -- ; } } } }
Nqnfs server timer that maintains the server lease queue.
Nqnfs server timer that maintains the server lease queue .
/*
		     * Make a best effort at keeping a write caching lease long
		     * enough by not deleting it until it has been explicitly
		     * vacated or there have been no writes in the previous
		     * write_slack seconds since expiry and the nfsds are not
		     * all busy. The assumption is that if the nfsds are not
		     * all busy now (no queue of nfs requests), then the client
		     * would have been able to do at least one write to the
		     * file during the last write_slack seconds if it was still
		     * trying to push writes to the server.
		     */ /*
			 * This soft reference may no longer be valid, but
			 * no harm done. The worst case is if the vnode was
			 * recycled and has another valid lease reference,
			 * which is dereferenced prematurely.
			 */