From 628641f8a647a1892765a8bade2d2a3f289290ea Mon Sep 17 00:00:00 2001 From: David Greenman Date: Fri, 11 Aug 1995 11:31:18 +0000 Subject: [PATCH] Converted mountlist to a CIRCLEQ. Partially obtained from: 4.4BSD-Lite2 --- sys/fs/cd9660/cd9660_vfsops.c | 4 ++-- sys/isofs/cd9660/cd9660_vfsops.c | 4 ++-- sys/kern/init_main.c | 4 ++-- sys/kern/vfs_export.c | 22 ++++++++++++---------- sys/kern/vfs_extattr.c | 15 +++++++++------ sys/kern/vfs_subr.c | 22 ++++++++++++---------- sys/kern/vfs_syscalls.c | 15 +++++++++------ sys/nfs/nfs_nqlease.c | 6 +----- sys/nfs/nfs_vfsops.c | 6 +----- sys/nfsclient/nfs_vfsops.c | 6 +----- sys/sys/mount.h | 8 ++++---- sys/ufs/ffs/ffs_vfsops.c | 4 ++-- sys/ufs/lfs/lfs_bio.c | 4 ++-- sys/ufs/mfs/mfs_vfsops.c | 4 ++-- 14 files changed, 61 insertions(+), 63 deletions(-) diff --git a/sys/fs/cd9660/cd9660_vfsops.c b/sys/fs/cd9660/cd9660_vfsops.c index afa08f473811..e7f51ad4267d 100644 --- a/sys/fs/cd9660/cd9660_vfsops.c +++ b/sys/fs/cd9660/cd9660_vfsops.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)cd9660_vfsops.c 8.3 (Berkeley) 1/31/94 - * $Id: cd9660_vfsops.c,v 1.12 1995/05/19 03:25:35 davidg Exp $ + * $Id: cd9660_vfsops.c,v 1.13 1995/05/30 08:05:03 rgrimes Exp $ */ #include @@ -113,7 +113,7 @@ cd9660_mountroot() free(mp, M_MOUNT); return (error); } - TAILQ_INSERT_TAIL(&mountlist, mp, mnt_list); + CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list); mp->mnt_flag |= MNT_ROOTFS; mp->mnt_vnodecovered = NULLVP; imp = VFSTOISOFS(mp); diff --git a/sys/isofs/cd9660/cd9660_vfsops.c b/sys/isofs/cd9660/cd9660_vfsops.c index afa08f473811..e7f51ad4267d 100644 --- a/sys/isofs/cd9660/cd9660_vfsops.c +++ b/sys/isofs/cd9660/cd9660_vfsops.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)cd9660_vfsops.c 8.3 (Berkeley) 1/31/94 - * $Id: cd9660_vfsops.c,v 1.12 1995/05/19 03:25:35 davidg Exp $ + * $Id: cd9660_vfsops.c,v 1.13 1995/05/30 08:05:03 rgrimes Exp $ */ #include @@ -113,7 +113,7 @@ cd9660_mountroot() free(mp, M_MOUNT); return (error); } - TAILQ_INSERT_TAIL(&mountlist, mp, mnt_list); + CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list); mp->mnt_flag |= MNT_ROOTFS; mp->mnt_vnodecovered = NULLVP; imp = VFSTOISOFS(mp); diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 89874b23d0ec..854b6caa2bad 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)init_main.c 8.9 (Berkeley) 1/21/94 - * $Id: init_main.c,v 1.24 1995/05/14 02:59:55 davidg Exp $ + * $Id: init_main.c,v 1.25 1995/05/19 03:26:43 davidg Exp $ */ #include @@ -288,7 +288,7 @@ main(framep) panic("cannot mount root"); /* Get the vnode for '/'. Set fdp->fd_fd.fd_cdir to reference it. */ - if (VFS_ROOT(mountlist.tqh_first, &rootvnode)) + if (VFS_ROOT(mountlist.cqh_first, &rootvnode)) panic("cannot find root vnode"); fdp->fd_fd.fd_cdir = rootvnode; VREF(fdp->fd_fd.fd_cdir); diff --git a/sys/kern/vfs_export.c b/sys/kern/vfs_export.c index 2b2b7d76a270..491a8108f9f5 100644 --- a/sys/kern/vfs_export.c +++ b/sys/kern/vfs_export.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)vfs_subr.c 8.13 (Berkeley) 4/18/94 - * $Id: vfs_subr.c,v 1.33 1995/07/08 04:10:32 davidg Exp $ + * $Id: vfs_subr.c,v 1.34 1995/07/13 08:47:40 davidg Exp $ */ /* @@ -100,7 +100,7 @@ vntblinit() desiredvnodes = maxproc + vm_object_cache_max; TAILQ_INIT(&vnode_free_list); - TAILQ_INIT(&mountlist); + CIRCLEQ_INIT(&mountlist); } /* @@ -214,12 +214,12 @@ vfs_unmountroot(rootfs) void vfs_unmountall() { - struct mount *mp, *mp_next, *rootfs = NULL; + struct mount *mp, *nmp, *rootfs = NULL; int error; /* unmount all but rootfs */ - for (mp = mountlist.tqh_first; mp != NULL; mp = mp_next) { - mp_next = mp->mnt_list.tqe_next; + for (mp = mountlist.cqh_last; mp != (void *)&mountlist; mp = nmp) { + nmp = mp->mnt_list.cqe_prev; if (mp->mnt_flag & MNT_ROOTFS) { rootfs = mp; @@ -252,7 +252,8 @@ getvfs(fsid) { register struct mount *mp; - for (mp = mountlist.tqh_first; mp != NULL; mp = mp->mnt_list.tqe_next) { + for (mp = mountlist.cqh_first; mp != (void *)&mountlist; + mp = mp->mnt_list.cqe_next) { if (mp->mnt_stat.f_fsid.val[0] == fsid->val[0] && mp->mnt_stat.f_fsid.val[1] == fsid->val[1]) return (mp); @@ -278,7 +279,7 @@ getnewfsid(mp, mtype) ++xxxfs_mntid; tfsid.val[0] = makedev(nblkdev + mtype, xxxfs_mntid); tfsid.val[1] = mtype; - if (mountlist.tqh_first != NULL) { + if (mountlist.cqh_first != (void *)&mountlist) { while (getvfs(&tfsid)) { tfsid.val[0]++; xxxfs_mntid++; @@ -1252,7 +1253,8 @@ printlockedvnodes() register struct vnode *vp; printf("Locked vnodes\n"); - for (mp = mountlist.tqh_first; mp != NULL; mp = mp->mnt_list.tqe_next) { + for (mp = mountlist.cqh_first; mp != (void *)&mountlist; + mp = mp->mnt_list.cqe_next) { for (vp = mp->mnt_vnodelist.lh_first; vp != NULL; vp = vp->v_mntvnodes.le_next) @@ -1290,8 +1292,8 @@ sysctl_vnode(where, sizep) } ewhere = where + *sizep; - for (mp = mountlist.tqh_first; mp != NULL; mp = nmp) { - nmp = mp->mnt_list.tqe_next; + for (mp = mountlist.cqh_first; mp != (void *)&mountlist; mp = nmp) { + nmp = mp->mnt_list.cqe_next; if (vfs_busy(mp)) continue; savebp = bp; diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c index 99e2b5803519..8d6eca1ff8d2 100644 --- a/sys/kern/vfs_extattr.c +++ b/sys/kern/vfs_extattr.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)vfs_syscalls.c 8.13 (Berkeley) 4/15/94 - * $Id: vfs_syscalls.c,v 1.29 1995/07/31 00:35:47 bde Exp $ + * $Id: vfs_syscalls.c,v 1.30 1995/08/01 18:50:39 davidg Exp $ */ #include @@ -190,10 +190,12 @@ update: */ cache_purge(vp); if (!error) { - TAILQ_INSERT_TAIL(&mountlist, mp, mnt_list); + CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list); VOP_UNLOCK(vp); vfs_unlock(mp); error = VFS_START(mp, 0, p); + if (error) + vrele(vp); } else { mp->mnt_vnodecovered->v_mountedhere = (struct mount *)0; vfs_unlock(mp); @@ -294,7 +296,7 @@ dounmount(mp, flags, p) vfs_unlock(mp); } else { vrele(coveredvp); - TAILQ_REMOVE(&mountlist, mp, mnt_list); + CIRCLEQ_REMOVE(&mountlist, mp, mnt_list); mp->mnt_vnodecovered->v_mountedhere = (struct mount *)0; vfs_unlock(mp); mp->mnt_vfc->vfc_refcount--; @@ -323,7 +325,7 @@ sync(p, uap, retval) register struct mount *mp; int asyncflag; - for (mp = mountlist.tqh_first; mp != NULL; mp = mp->mnt_list.tqe_next) { + for (mp = mountlist.cqh_first; mp != (void *)&mountlist; mp = mp->mnt_list.cqe_next) { /* * The lock check below is to avoid races with mount * and unmount. @@ -456,8 +458,9 @@ getfsstat(p, uap, retval) maxcount = uap->bufsize / sizeof(struct statfs); sfsp = (caddr_t)uap->buf; - for (count = 0, mp = mountlist.tqh_first; mp != NULL; mp = nmp) { - nmp = mp->mnt_list.tqe_next; + count = 0; + for (mp = mountlist.cqh_first; mp != (void *)&mountlist; mp = nmp) { + nmp = mp->mnt_list.cqe_next; if (sfsp && count < maxcount && ((mp->mnt_flag & MNT_MLOCK) == 0)) { sp = &mp->mnt_stat; diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 2b2b7d76a270..491a8108f9f5 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)vfs_subr.c 8.13 (Berkeley) 4/18/94 - * $Id: vfs_subr.c,v 1.33 1995/07/08 04:10:32 davidg Exp $ + * $Id: vfs_subr.c,v 1.34 1995/07/13 08:47:40 davidg Exp $ */ /* @@ -100,7 +100,7 @@ vntblinit() desiredvnodes = maxproc + vm_object_cache_max; TAILQ_INIT(&vnode_free_list); - TAILQ_INIT(&mountlist); + CIRCLEQ_INIT(&mountlist); } /* @@ -214,12 +214,12 @@ vfs_unmountroot(rootfs) void vfs_unmountall() { - struct mount *mp, *mp_next, *rootfs = NULL; + struct mount *mp, *nmp, *rootfs = NULL; int error; /* unmount all but rootfs */ - for (mp = mountlist.tqh_first; mp != NULL; mp = mp_next) { - mp_next = mp->mnt_list.tqe_next; + for (mp = mountlist.cqh_last; mp != (void *)&mountlist; mp = nmp) { + nmp = mp->mnt_list.cqe_prev; if (mp->mnt_flag & MNT_ROOTFS) { rootfs = mp; @@ -252,7 +252,8 @@ getvfs(fsid) { register struct mount *mp; - for (mp = mountlist.tqh_first; mp != NULL; mp = mp->mnt_list.tqe_next) { + for (mp = mountlist.cqh_first; mp != (void *)&mountlist; + mp = mp->mnt_list.cqe_next) { if (mp->mnt_stat.f_fsid.val[0] == fsid->val[0] && mp->mnt_stat.f_fsid.val[1] == fsid->val[1]) return (mp); @@ -278,7 +279,7 @@ getnewfsid(mp, mtype) ++xxxfs_mntid; tfsid.val[0] = makedev(nblkdev + mtype, xxxfs_mntid); tfsid.val[1] = mtype; - if (mountlist.tqh_first != NULL) { + if (mountlist.cqh_first != (void *)&mountlist) { while (getvfs(&tfsid)) { tfsid.val[0]++; xxxfs_mntid++; @@ -1252,7 +1253,8 @@ printlockedvnodes() register struct vnode *vp; printf("Locked vnodes\n"); - for (mp = mountlist.tqh_first; mp != NULL; mp = mp->mnt_list.tqe_next) { + for (mp = mountlist.cqh_first; mp != (void *)&mountlist; + mp = mp->mnt_list.cqe_next) { for (vp = mp->mnt_vnodelist.lh_first; vp != NULL; vp = vp->v_mntvnodes.le_next) @@ -1290,8 +1292,8 @@ sysctl_vnode(where, sizep) } ewhere = where + *sizep; - for (mp = mountlist.tqh_first; mp != NULL; mp = nmp) { - nmp = mp->mnt_list.tqe_next; + for (mp = mountlist.cqh_first; mp != (void *)&mountlist; mp = nmp) { + nmp = mp->mnt_list.cqe_next; if (vfs_busy(mp)) continue; savebp = bp; diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 99e2b5803519..8d6eca1ff8d2 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)vfs_syscalls.c 8.13 (Berkeley) 4/15/94 - * $Id: vfs_syscalls.c,v 1.29 1995/07/31 00:35:47 bde Exp $ + * $Id: vfs_syscalls.c,v 1.30 1995/08/01 18:50:39 davidg Exp $ */ #include @@ -190,10 +190,12 @@ update: */ cache_purge(vp); if (!error) { - TAILQ_INSERT_TAIL(&mountlist, mp, mnt_list); + CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list); VOP_UNLOCK(vp); vfs_unlock(mp); error = VFS_START(mp, 0, p); + if (error) + vrele(vp); } else { mp->mnt_vnodecovered->v_mountedhere = (struct mount *)0; vfs_unlock(mp); @@ -294,7 +296,7 @@ dounmount(mp, flags, p) vfs_unlock(mp); } else { vrele(coveredvp); - TAILQ_REMOVE(&mountlist, mp, mnt_list); + CIRCLEQ_REMOVE(&mountlist, mp, mnt_list); mp->mnt_vnodecovered->v_mountedhere = (struct mount *)0; vfs_unlock(mp); mp->mnt_vfc->vfc_refcount--; @@ -323,7 +325,7 @@ sync(p, uap, retval) register struct mount *mp; int asyncflag; - for (mp = mountlist.tqh_first; mp != NULL; mp = mp->mnt_list.tqe_next) { + for (mp = mountlist.cqh_first; mp != (void *)&mountlist; mp = mp->mnt_list.cqe_next) { /* * The lock check below is to avoid races with mount * and unmount. @@ -456,8 +458,9 @@ getfsstat(p, uap, retval) maxcount = uap->bufsize / sizeof(struct statfs); sfsp = (caddr_t)uap->buf; - for (count = 0, mp = mountlist.tqh_first; mp != NULL; mp = nmp) { - nmp = mp->mnt_list.tqe_next; + count = 0; + for (mp = mountlist.cqh_first; mp != (void *)&mountlist; mp = nmp) { + nmp = mp->mnt_list.cqe_next; if (sfsp && count < maxcount && ((mp->mnt_flag & MNT_MLOCK) == 0)) { sp = &mp->mnt_stat; diff --git a/sys/nfs/nfs_nqlease.c b/sys/nfs/nfs_nqlease.c index d953699dd91b..49e47c862b80 100644 --- a/sys/nfs/nfs_nqlease.c +++ b/sys/nfs/nfs_nqlease.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs_nqlease.c 8.3 (Berkeley) 1/4/94 - * $Id: nfs_nqlease.c,v 1.11 1995/05/30 08:12:36 rgrimes Exp $ + * $Id: nfs_nqlease.c,v 1.12 1995/06/27 11:06:36 dfr Exp $ */ /* @@ -1172,12 +1172,8 @@ nqnfs_lease_updatetime(deltat) * Search the mount list for all nqnfs mounts and do their timer * queues. */ -#if NetBSD >= 1994101 for (mp = mountlist.cqh_first; mp != (void *)&mountlist; mp = mp->mnt_list.cqe_next) { -#else - for (mp = mountlist.tqh_first; mp != NULL; mp = mp->mnt_list.tqe_next) { -#endif #ifdef __NetBSD__ if (!strcmp(&mp->mnt_stat.f_fstypename[0], MOUNT_NFS)) { #else diff --git a/sys/nfs/nfs_vfsops.c b/sys/nfs/nfs_vfsops.c index df3fea517e9e..cc140931db29 100644 --- a/sys/nfs/nfs_vfsops.c +++ b/sys/nfs/nfs_vfsops.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs_vfsops.c 8.3 (Berkeley) 1/4/94 - * $Id: nfs_vfsops.c,v 1.16 1995/06/27 11:06:51 dfr Exp $ + * $Id: nfs_vfsops.c,v 1.17 1995/07/07 11:01:31 dfr Exp $ */ #include @@ -417,11 +417,7 @@ nfs_mountroot() if (vfs_lock(mp)) panic("nfs_mountroot: vfs_lock"); -#if NetBSD >= 1994101 CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list); -#else - TAILQ_INSERT_TAIL(&mountlist, mp, mnt_list); -#endif mp->mnt_flag |= MNT_ROOTFS; mp->mnt_vnodecovered = NULLVP; vfs_unlock(mp); diff --git a/sys/nfsclient/nfs_vfsops.c b/sys/nfsclient/nfs_vfsops.c index df3fea517e9e..cc140931db29 100644 --- a/sys/nfsclient/nfs_vfsops.c +++ b/sys/nfsclient/nfs_vfsops.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs_vfsops.c 8.3 (Berkeley) 1/4/94 - * $Id: nfs_vfsops.c,v 1.16 1995/06/27 11:06:51 dfr Exp $ + * $Id: nfs_vfsops.c,v 1.17 1995/07/07 11:01:31 dfr Exp $ */ #include @@ -417,11 +417,7 @@ nfs_mountroot() if (vfs_lock(mp)) panic("nfs_mountroot: vfs_lock"); -#if NetBSD >= 1994101 CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list); -#else - TAILQ_INSERT_TAIL(&mountlist, mp, mnt_list); -#endif mp->mnt_flag |= MNT_ROOTFS; mp->mnt_vnodecovered = NULLVP; vfs_unlock(mp); diff --git a/sys/sys/mount.h b/sys/sys/mount.h index 0580e98d16ed..71fb6b121b04 100644 --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)mount.h 8.13 (Berkeley) 3/27/94 - * $Id: mount.h,v 1.19 1995/05/30 08:14:28 rgrimes Exp $ + * $Id: mount.h,v 1.20 1995/06/27 11:07:08 dfr Exp $ */ #ifndef _SYS_MOUNT_H_ @@ -129,15 +129,15 @@ struct statfs { LIST_HEAD(vnodelst, vnode); struct mount { - TAILQ_ENTRY(mount) mnt_list; /* mount list */ + CIRCLEQ_ENTRY(mount) mnt_list; /* mount list */ struct vfsops *mnt_op; /* operations on fs */ + struct vfsconf *mnt_vfc; /* configuration info */ struct vnode *mnt_vnodecovered; /* vnode we mounted on */ struct vnodelst mnt_vnodelist; /* list of vnodes this mount */ int mnt_flag; /* flags */ int mnt_maxsymlinklen; /* max size of short symlink */ struct statfs mnt_stat; /* cache of filesystem stats */ qaddr_t mnt_data; /* private data */ - struct vfsconf *mnt_vfc; /* configuration info */ }; /* @@ -484,7 +484,7 @@ void vfs_unlock __P((struct mount *)); /* unlock a vfs */ void vfs_unmountall __P((void)); int vfs_busy __P((struct mount *)); /* mark a vfs busy */ void vfs_unbusy __P((struct mount *)); /* mark a vfs not busy */ -extern TAILQ_HEAD(mntlist, mount) mountlist; /* mounted filesystem list */ +extern CIRCLEQ_HEAD(mntlist, mount) mountlist; /* mounted filesystem list */ extern struct vfsops *vfssw[]; /* filesystem type table */ #else /* KERNEL */ diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 52657be14044..19c78cf3e94f 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)ffs_vfsops.c 8.8 (Berkeley) 4/18/94 - * $Id: ffs_vfsops.c,v 1.25 1995/07/21 16:20:20 davidg Exp $ + * $Id: ffs_vfsops.c,v 1.26 1995/08/06 11:56:42 davidg Exp $ */ #include @@ -125,7 +125,7 @@ ffs_mountroot() free(mp, M_MOUNT); return (error); } - TAILQ_INSERT_TAIL(&mountlist, mp, mnt_list); + CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list); mp->mnt_flag |= MNT_ROOTFS; mp->mnt_vnodecovered = NULLVP; ump = VFSTOUFS(mp); diff --git a/sys/ufs/lfs/lfs_bio.c b/sys/ufs/lfs/lfs_bio.c index 9344dbb590f5..b1388d1fd300 100644 --- a/sys/ufs/lfs/lfs_bio.c +++ b/sys/ufs/lfs/lfs_bio.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)lfs_bio.c 8.4 (Berkeley) 12/30/93 - * $Id: lfs_bio.c,v 1.4 1994/08/20 03:49:01 davidg Exp $ + * $Id: lfs_bio.c,v 1.5 1994/10/10 01:04:49 phk Exp $ */ #include @@ -142,7 +142,7 @@ lfs_flush() if (lfs_writing) return; lfs_writing = 1; - for (mp = mountlist.tqh_first; mp != NULL; mp = mp->mnt_list.tqe_next) { + for (mp = mountlist.cqh_first; mp != (void *)&mountlist; mp = mp->mnt_list.cqe_next) { /* The lock check below is to avoid races with unmount. */ if (mp->mnt_stat.f_type == MOUNT_LFS && (mp->mnt_flag & (MNT_MLOCK|MNT_RDONLY|MNT_UNMOUNT)) == 0 && diff --git a/sys/ufs/mfs/mfs_vfsops.c b/sys/ufs/mfs/mfs_vfsops.c index e491fe12a896..db2cbff0db60 100644 --- a/sys/ufs/mfs/mfs_vfsops.c +++ b/sys/ufs/mfs/mfs_vfsops.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)mfs_vfsops.c 8.4 (Berkeley) 4/16/94 - * $Id: mfs_vfsops.c,v 1.8 1995/05/19 03:27:01 davidg Exp $ + * $Id: mfs_vfsops.c,v 1.9 1995/05/29 03:27:37 phk Exp $ */ #include @@ -129,7 +129,7 @@ mfs_mountroot() free(mfsp, M_MFSNODE); return (error); } - TAILQ_INSERT_TAIL(&mountlist, mp, mnt_list); + CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list); mp->mnt_flag |= MNT_ROOTFS; mp->mnt_vnodecovered = NULLVP; ump = VFSTOUFS(mp);