From 9e4c9a6ce908881b1e6f83cbb906a9fce08dd3ab Mon Sep 17 00:00:00 2001 From: jeff Date: Tue, 25 Feb 2003 03:37:48 +0000 Subject: - Add an interlock argument to BUF_LOCK and BUF_TIMELOCK. - Remove the buftimelock mutex and acquire the buf's interlock to protect these fields instead. - Hold the vnode interlock while locking bufs on the clean/dirty queues. This reduces some cases from one BUF_LOCK with a LK_NOWAIT and another BUF_LOCK with a LK_TIMEFAIL to a single lock. Reviewed by: arch, mckusick --- sys/nfsserver/nfs_serv.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'sys/nfsserver') diff --git a/sys/nfsserver/nfs_serv.c b/sys/nfsserver/nfs_serv.c index 1d953cd..e35b4dc 100644 --- a/sys/nfsserver/nfs_serv.c +++ b/sys/nfsserver/nfs_serv.c @@ -3687,6 +3687,7 @@ nfsrv_commit(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, } s = splbio(); + VI_LOCK(vp); while (cnt > 0) { struct buf *bp; @@ -3700,16 +3701,18 @@ nfsrv_commit(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, * should not be set if B_INVAL is set there could be * a race here since we haven't locked the buffer). */ - if ((bp = incore(vp, lblkno)) != NULL && + if ((bp = gbincore(vp, lblkno)) != NULL && (bp->b_flags & (B_DELWRI|B_INVAL)) == B_DELWRI) { - if (BUF_LOCK(bp, LK_EXCLUSIVE | LK_NOWAIT)) { - BUF_LOCK(bp, LK_EXCLUSIVE | LK_SLEEPFAIL); + if (BUF_LOCK(bp, LK_EXCLUSIVE | LK_SLEEPFAIL | + LK_INTERLOCK, VI_MTX(vp)) == ENOLCK) { + VI_LOCK(vp); continue; /* retry */ } bremfree(bp); bp->b_flags &= ~B_ASYNC; BUF_WRITE(bp); ++nfs_commit_miss; + VI_LOCK(vp); } ++nfs_commit_blks; if (cnt < iosize) @@ -3717,6 +3720,7 @@ nfsrv_commit(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, cnt -= iosize; ++lblkno; } + VI_UNLOCK(vp); splx(s); } -- cgit v1.1