diff options
author | jhb <jhb@FreeBSD.org> | 2001-06-28 04:10:07 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2001-06-28 04:10:07 +0000 |
commit | ab91beada7d88e4a56b4217fee5826cb97b5cef7 (patch) | |
tree | 3520caa3d566aad1d0e33edb86f240a96f040425 /sys | |
parent | f7198d2b3a1299ad745cab94d5192d42710bb046 (diff) | |
download | FreeBSD-src-ab91beada7d88e4a56b4217fee5826cb97b5cef7.zip FreeBSD-src-ab91beada7d88e4a56b4217fee5826cb97b5cef7.tar.gz |
- Protect the mnt_vnode list with the mntvnode lock.
- Use queue(9) macros.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/nfs/nfs_common.c | 6 | ||||
-rw-r--r-- | sys/nfs/nfs_subs.c | 6 | ||||
-rw-r--r-- | sys/nfs/nfs_vfsops.c | 21 | ||||
-rw-r--r-- | sys/nfsclient/nfs_subs.c | 6 | ||||
-rw-r--r-- | sys/nfsclient/nfs_vfsops.c | 21 | ||||
-rw-r--r-- | sys/nfsserver/nfs_srvsubs.c | 6 |
6 files changed, 48 insertions, 18 deletions
diff --git a/sys/nfs/nfs_common.c b/sys/nfs/nfs_common.c index 18cb8a9..b9c4197 100644 --- a/sys/nfs/nfs_common.c +++ b/sys/nfs/nfs_common.c @@ -2141,11 +2141,12 @@ nfs_clearcommit(mp) s = splbio(); mtx_assert(&Giant, MA_OWNED); mtx_assert(&vm_mtx, MA_NOTOWNED); + mtx_lock(&mntvnode_mtx); loop: - for (vp = mp->mnt_vnodelist.lh_first; vp; vp = nvp) { + for (vp = LIST_FIRST(&mp->mnt_vnodelist); vp; vp = nvp) { if (vp->v_mount != mp) /* Paranoia */ goto loop; - nvp = vp->v_mntvnodes.le_next; + nvp = LIST_NEXT(vp, v_mntvnodes); for (bp = TAILQ_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) { nbp = TAILQ_NEXT(bp, b_vnbufs); if (BUF_REFCNT(bp) == 0 && @@ -2154,6 +2155,7 @@ loop: bp->b_flags &= ~(B_NEEDCOMMIT | B_CLUSTEROK); } } + mtx_unlock(&mntvnode_mtx); splx(s); } diff --git a/sys/nfs/nfs_subs.c b/sys/nfs/nfs_subs.c index 18cb8a9..b9c4197 100644 --- a/sys/nfs/nfs_subs.c +++ b/sys/nfs/nfs_subs.c @@ -2141,11 +2141,12 @@ nfs_clearcommit(mp) s = splbio(); mtx_assert(&Giant, MA_OWNED); mtx_assert(&vm_mtx, MA_NOTOWNED); + mtx_lock(&mntvnode_mtx); loop: - for (vp = mp->mnt_vnodelist.lh_first; vp; vp = nvp) { + for (vp = LIST_FIRST(&mp->mnt_vnodelist); vp; vp = nvp) { if (vp->v_mount != mp) /* Paranoia */ goto loop; - nvp = vp->v_mntvnodes.le_next; + nvp = LIST_NEXT(vp, v_mntvnodes); for (bp = TAILQ_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) { nbp = TAILQ_NEXT(bp, b_vnbufs); if (BUF_REFCNT(bp) == 0 && @@ -2154,6 +2155,7 @@ loop: bp->b_flags &= ~(B_NEEDCOMMIT | B_CLUSTEROK); } } + mtx_unlock(&mntvnode_mtx); splx(s); } diff --git a/sys/nfs/nfs_vfsops.c b/sys/nfs/nfs_vfsops.c index 3c76ed5..706fd1f 100644 --- a/sys/nfs/nfs_vfsops.c +++ b/sys/nfs/nfs_vfsops.c @@ -1031,32 +1031,43 @@ nfs_sync(mp, waitfor, cred, p) struct ucred *cred; struct proc *p; { - register struct vnode *vp; + struct vnode *vp, *vnp; int error, allerror = 0; /* * Force stale buffer cache information to be flushed. */ + mtx_lock(&mntvnode_mtx); loop: - for (vp = mp->mnt_vnodelist.lh_first; + for (vp = LIST_FIRST(&mp->mnt_vnodelist); vp != NULL; - vp = vp->v_mntvnodes.le_next) { + vp = vnp) { /* * If the vnode that we are about to sync is no longer * associated with this mount point, start over. */ if (vp->v_mount != mp) goto loop; + vnp = LIST_NEXT(vp, v_mntvnodes); + mtx_unlock(&mntvnode_mtx); + mtx_lock(&vp->v_interlock); if (VOP_ISLOCKED(vp, NULL) || TAILQ_EMPTY(&vp->v_dirtyblkhd) || - waitfor == MNT_LAZY) + waitfor == MNT_LAZY) { + mtx_unlock(&vp->v_interlock); + mtx_lock(&mntvnode_mtx); continue; - if (vget(vp, LK_EXCLUSIVE, p)) + } + if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p)) { + mtx_lock(&mntvnode_mtx); goto loop; + } error = VOP_FSYNC(vp, cred, waitfor, p); if (error) allerror = error; vput(vp); + mtx_lock(&mntvnode_mtx); } + mtx_unlock(&mntvnode_mtx); return (allerror); } diff --git a/sys/nfsclient/nfs_subs.c b/sys/nfsclient/nfs_subs.c index 18cb8a9..b9c4197 100644 --- a/sys/nfsclient/nfs_subs.c +++ b/sys/nfsclient/nfs_subs.c @@ -2141,11 +2141,12 @@ nfs_clearcommit(mp) s = splbio(); mtx_assert(&Giant, MA_OWNED); mtx_assert(&vm_mtx, MA_NOTOWNED); + mtx_lock(&mntvnode_mtx); loop: - for (vp = mp->mnt_vnodelist.lh_first; vp; vp = nvp) { + for (vp = LIST_FIRST(&mp->mnt_vnodelist); vp; vp = nvp) { if (vp->v_mount != mp) /* Paranoia */ goto loop; - nvp = vp->v_mntvnodes.le_next; + nvp = LIST_NEXT(vp, v_mntvnodes); for (bp = TAILQ_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) { nbp = TAILQ_NEXT(bp, b_vnbufs); if (BUF_REFCNT(bp) == 0 && @@ -2154,6 +2155,7 @@ loop: bp->b_flags &= ~(B_NEEDCOMMIT | B_CLUSTEROK); } } + mtx_unlock(&mntvnode_mtx); splx(s); } diff --git a/sys/nfsclient/nfs_vfsops.c b/sys/nfsclient/nfs_vfsops.c index 3c76ed5..706fd1f 100644 --- a/sys/nfsclient/nfs_vfsops.c +++ b/sys/nfsclient/nfs_vfsops.c @@ -1031,32 +1031,43 @@ nfs_sync(mp, waitfor, cred, p) struct ucred *cred; struct proc *p; { - register struct vnode *vp; + struct vnode *vp, *vnp; int error, allerror = 0; /* * Force stale buffer cache information to be flushed. */ + mtx_lock(&mntvnode_mtx); loop: - for (vp = mp->mnt_vnodelist.lh_first; + for (vp = LIST_FIRST(&mp->mnt_vnodelist); vp != NULL; - vp = vp->v_mntvnodes.le_next) { + vp = vnp) { /* * If the vnode that we are about to sync is no longer * associated with this mount point, start over. */ if (vp->v_mount != mp) goto loop; + vnp = LIST_NEXT(vp, v_mntvnodes); + mtx_unlock(&mntvnode_mtx); + mtx_lock(&vp->v_interlock); if (VOP_ISLOCKED(vp, NULL) || TAILQ_EMPTY(&vp->v_dirtyblkhd) || - waitfor == MNT_LAZY) + waitfor == MNT_LAZY) { + mtx_unlock(&vp->v_interlock); + mtx_lock(&mntvnode_mtx); continue; - if (vget(vp, LK_EXCLUSIVE, p)) + } + if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p)) { + mtx_lock(&mntvnode_mtx); goto loop; + } error = VOP_FSYNC(vp, cred, waitfor, p); if (error) allerror = error; vput(vp); + mtx_lock(&mntvnode_mtx); } + mtx_unlock(&mntvnode_mtx); return (allerror); } diff --git a/sys/nfsserver/nfs_srvsubs.c b/sys/nfsserver/nfs_srvsubs.c index 18cb8a9..b9c4197 100644 --- a/sys/nfsserver/nfs_srvsubs.c +++ b/sys/nfsserver/nfs_srvsubs.c @@ -2141,11 +2141,12 @@ nfs_clearcommit(mp) s = splbio(); mtx_assert(&Giant, MA_OWNED); mtx_assert(&vm_mtx, MA_NOTOWNED); + mtx_lock(&mntvnode_mtx); loop: - for (vp = mp->mnt_vnodelist.lh_first; vp; vp = nvp) { + for (vp = LIST_FIRST(&mp->mnt_vnodelist); vp; vp = nvp) { if (vp->v_mount != mp) /* Paranoia */ goto loop; - nvp = vp->v_mntvnodes.le_next; + nvp = LIST_NEXT(vp, v_mntvnodes); for (bp = TAILQ_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) { nbp = TAILQ_NEXT(bp, b_vnbufs); if (BUF_REFCNT(bp) == 0 && @@ -2154,6 +2155,7 @@ loop: bp->b_flags &= ~(B_NEEDCOMMIT | B_CLUSTEROK); } } + mtx_unlock(&mntvnode_mtx); splx(s); } |