From 4597dd33cdb4ce72a61cbb100cd7e442415c6e96 Mon Sep 17 00:00:00 2001 From: Kirk McKusick Date: Sun, 6 May 1990 00:07:46 -0800 Subject: [PATCH] have to check that vnode is still associated with mount point before using it SCCS-vsn: sys/kern/vfs_bio.c 7.28 SCCS-vsn: sys/kern/vfs_cluster.c 7.28 SCCS-vsn: sys/kern/vfs_subr.c 7.44 --- usr/src/sys/kern/vfs_bio.c | 14 +++++++------- usr/src/sys/kern/vfs_cluster.c | 14 +++++++------- usr/src/sys/kern/vfs_subr.c | 30 +++++++++++++++--------------- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/usr/src/sys/kern/vfs_bio.c b/usr/src/sys/kern/vfs_bio.c index ffb0a5774d..205724a193 100644 --- a/usr/src/sys/kern/vfs_bio.c +++ b/usr/src/sys/kern/vfs_bio.c @@ -14,7 +14,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * @(#)vfs_bio.c 7.27 (Berkeley) %G% + * @(#)vfs_bio.c 7.28 (Berkeley) %G% */ #include "param.h" @@ -571,17 +571,17 @@ mntflushbuf(mountp, flags) int flags; { register struct vnode *vp; - struct vnode *nvp; if ((mountp->mnt_flag & MNT_MPBUSY) == 0) panic("mntflushbuf: not busy"); loop: - for (vp = mountp->mnt_mounth; vp; vp = nvp) { - nvp = vp->v_mountf; + for (vp = mountp->mnt_mounth; vp; vp = vp->v_mountf) { if (vget(vp)) goto loop; vflushbuf(vp, flags); vput(vp); + if (vp->v_mount != mountp) + goto loop; } } @@ -649,18 +649,18 @@ mntinvalbuf(mountp) struct mount *mountp; { register struct vnode *vp; - struct vnode *nvp; int dirty = 0; if ((mountp->mnt_flag & MNT_MPBUSY) == 0) panic("mntinvalbuf: not busy"); loop: - for (vp = mountp->mnt_mounth; vp; vp = nvp) { - nvp = vp->v_mountf; + for (vp = mountp->mnt_mounth; vp; vp = vp->v_mountf) { if (vget(vp)) goto loop; dirty += vinvalbuf(vp, 1); vput(vp); + if (vp->v_mount != mountp) + goto loop; } return (dirty); } diff --git a/usr/src/sys/kern/vfs_cluster.c b/usr/src/sys/kern/vfs_cluster.c index d9e6ff160e..4c465e2d0d 100644 --- a/usr/src/sys/kern/vfs_cluster.c +++ b/usr/src/sys/kern/vfs_cluster.c @@ -14,7 +14,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * @(#)vfs_cluster.c 7.27 (Berkeley) %G% + * @(#)vfs_cluster.c 7.28 (Berkeley) %G% */ #include "param.h" @@ -571,17 +571,17 @@ mntflushbuf(mountp, flags) int flags; { register struct vnode *vp; - struct vnode *nvp; if ((mountp->mnt_flag & MNT_MPBUSY) == 0) panic("mntflushbuf: not busy"); loop: - for (vp = mountp->mnt_mounth; vp; vp = nvp) { - nvp = vp->v_mountf; + for (vp = mountp->mnt_mounth; vp; vp = vp->v_mountf) { if (vget(vp)) goto loop; vflushbuf(vp, flags); vput(vp); + if (vp->v_mount != mountp) + goto loop; } } @@ -649,18 +649,18 @@ mntinvalbuf(mountp) struct mount *mountp; { register struct vnode *vp; - struct vnode *nvp; int dirty = 0; if ((mountp->mnt_flag & MNT_MPBUSY) == 0) panic("mntinvalbuf: not busy"); loop: - for (vp = mountp->mnt_mounth; vp; vp = nvp) { - nvp = vp->v_mountf; + for (vp = mountp->mnt_mounth; vp; vp = vp->v_mountf) { if (vget(vp)) goto loop; dirty += vinvalbuf(vp, 1); vput(vp); + if (vp->v_mount != mountp) + goto loop; } return (dirty); } diff --git a/usr/src/sys/kern/vfs_subr.c b/usr/src/sys/kern/vfs_subr.c index 09e1f4d1a3..782ff43325 100644 --- a/usr/src/sys/kern/vfs_subr.c +++ b/usr/src/sys/kern/vfs_subr.c @@ -14,7 +14,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * @(#)vfs_subr.c 7.43 (Berkeley) %G% + * @(#)vfs_subr.c 7.44 (Berkeley) %G% */ /* @@ -532,7 +532,10 @@ vflush(mp, skipvp, flags) if ((mp->mnt_flag & MNT_MPBUSY) == 0) panic("vflush: not busy"); +loop: for (vp = mp->mnt_mounth; vp; vp = nvp) { + if (vp->v_mount != mp) + goto loop; nvp = vp->v_mountf; /* * Skip over a selected vnode. @@ -873,7 +876,6 @@ kinfo_vnode(op, where, acopysize, arg, aneeded) int *acopysize, *aneeded; { register struct mount *mp = rootfs; - register struct vnode *nextvp; struct mount *omp; struct vnode *vp; register needed = 0; @@ -888,7 +890,6 @@ kinfo_vnode(op, where, acopysize, arg, aneeded) return (0); } -#define RETRY bp = savebp ; goto again do { if (vfs_busy(mp)) { mp = mp->mnt_next; @@ -898,25 +899,25 @@ kinfo_vnode(op, where, acopysize, arg, aneeded) * A vget can fail if the vnode is being * recycled. In this (rare) case, we have to start * over with this filesystem. Also, have to - * check that nextvp is still associated + * check that the next vp is still associated * with this filesystem. RACE: could have been - * recycled onto same filesystem. + * recycled onto the same filesystem. */ savebp = bp; again: - nextvp = mp->mnt_mounth; - while (vp = nextvp) { + for (vp = mp->mnt_mounth; vp; vp = vp->v_mountf) { + if (vp->v_mount != mp) { + if (kinfo_vdebug) + printf("kinfo: vp changed\n"); + bp = savebp; + goto again; + } if (vget(vp)) { if (kinfo_vdebug) printf("kinfo: vget failed\n"); kinfo_vgetfailed++; - RETRY; - } - if (vp->v_mount != mp) { - if (kinfo_vdebug) - printf("kinfo: vp changed\n"); - vput(vp); - RETRY; + bp = savebp; + goto again; } if ((bp + VPTRSZ + VNODESZ <= ewhere) && ((error = copyout((caddr_t)&vp, bp, VPTRSZ)) || @@ -926,7 +927,6 @@ again: return (error); } bp += VPTRSZ + VNODESZ; - nextvp = vp->v_mountf; vput(vp); } omp = mp; -- 2.20.1