Index: compat/common/vfs_syscalls_20.c =================================================================== RCS file: /cvsroot/src/sys/compat/common/vfs_syscalls_20.c,v retrieving revision 1.35 diff -u -p -u -r1.35 vfs_syscalls_20.c --- compat/common/vfs_syscalls_20.c 24 Jun 2010 13:03:06 -0000 1.35 +++ compat/common/vfs_syscalls_20.c 22 Nov 2013 21:50:25 -0000 @@ -214,7 +214,7 @@ compat_20_sys_getfsstat(struct lwp *l, c sfsp = SCARG(uap, buf); mutex_enter(&mountlist_lock); count = 0; - for (mp = CIRCLEQ_FIRST(&mountlist); mp != (void *)&mountlist; + for (mp = TAILQ_FIRST(&mountlist); mp != TAILQ_END(&mountlist); mp = nmp) { if (vfs_busy(mp, &nmp)) { continue; Index: kern/kern_verifiedexec.c =================================================================== RCS file: /cvsroot/src/sys/kern/kern_verifiedexec.c,v retrieving revision 1.129 diff -u -p -u -r1.129 kern_verifiedexec.c --- kern/kern_verifiedexec.c 13 Mar 2012 18:40:52 -0000 1.129 +++ kern/kern_verifiedexec.c 22 Nov 2013 21:50:39 -0000 @@ -1552,7 +1552,7 @@ veriexec_dump(struct lwp *l, prop_array_ struct mount *mp, *nmp; mutex_enter(&mountlist_lock); - for (mp = CIRCLEQ_FIRST(&mountlist); mp != (void *)&mountlist; + for (mp = TAILQ_FIRST(&mountlist); mp != TAILQ_END(&mountlist); mp = nmp) { /* If it fails, the file-system is [being] unmounted. */ if (vfs_busy(mp, &nmp) != 0) @@ -1575,7 +1575,7 @@ veriexec_flush(struct lwp *l) int error = 0; mutex_enter(&mountlist_lock); - for (mp = CIRCLEQ_FIRST(&mountlist); mp != (void *)&mountlist; + for (mp = TAILQ_FIRST(&mountlist); mp != TAILQ_END(&mountlist); mp = nmp) { int lerror; Index: kern/vfs_mount.c =================================================================== RCS file: /cvsroot/src/sys/kern/vfs_mount.c,v retrieving revision 1.23 diff -u -p -u -r1.23 vfs_mount.c --- kern/vfs_mount.c 29 Oct 2013 09:53:51 -0000 1.23 +++ kern/vfs_mount.c 22 Nov 2013 21:50:39 -0000 @@ -115,7 +115,7 @@ void vfs_mount_sysinit(void) { - CIRCLEQ_INIT(&mountlist); + TAILQ_INIT(&mountlist); mutex_init(&mountlist_lock, MUTEX_DEFAULT, IPL_NONE); mutex_init(&mntvnode_lock, MUTEX_DEFAULT, IPL_NONE); mutex_init(&vfs_list_lock, MUTEX_DEFAULT, IPL_NONE); @@ -213,7 +213,7 @@ vfs_getnewfsid(struct mount *mp) ++xxxfs_mntid; tfsid.__fsid_val[0] = makedev(mtype & 0xff, xxxfs_mntid); tfsid.__fsid_val[1] = mtype; - if (!CIRCLEQ_EMPTY(&mountlist)) { + if (!TAILQ_EMPTY(&mountlist)) { while (vfs_getvfs(&tfsid)) { tfsid.__fsid_val[0]++; xxxfs_mntid++; @@ -235,7 +235,7 @@ vfs_getvfs(fsid_t *fsid) struct mount *mp; mutex_enter(&mountlist_lock); - CIRCLEQ_FOREACH(mp, &mountlist, mnt_list) { + TAILQ_FOREACH(mp, &mountlist, mnt_list) { if (mp->mnt_stat.f_fsidx.__fsid_val[0] == fsid->__fsid_val[0] && mp->mnt_stat.f_fsidx.__fsid_val[1] == fsid->__fsid_val[1]) { mutex_exit(&mountlist_lock); @@ -293,7 +293,7 @@ vfs_busy(struct mount *mp, struct mount mutex_exit(&mp->mnt_unmounting); if (nextp != NULL) { KASSERT(mutex_owned(&mountlist_lock)); - *nextp = CIRCLEQ_NEXT(mp, mnt_list); + *nextp = TAILQ_NEXT(mp, mnt_list); } return ENOENT; } @@ -333,7 +333,7 @@ vfs_unbusy(struct mount *mp, bool keepre } if (nextp != NULL) { KASSERT(mutex_owned(&mountlist_lock)); - *nextp = CIRCLEQ_NEXT(mp, mnt_list); + *nextp = TAILQ_NEXT(mp, mnt_list); } } @@ -455,7 +455,8 @@ vflush(struct mount *mp, vnode_t *skipvp * and vclean() are called. */ mutex_enter(&mntvnode_lock); - for (vp = TAILQ_FIRST(&mp->mnt_vnodelist); vp != NULL; + for (vp = TAILQ_FIRST(&mp->mnt_vnodelist); + vp != TAILQ_END(&mp->mnt_nodelist); vp = vflushnext(mvp, &when)) { vmark(mvp, vp); if (vp->v_mount != mp || vismarker(vp)) @@ -533,8 +534,7 @@ vfs_scrubvnlist(struct mount *mp) retry: mutex_enter(&mntvnode_lock); - for (vp = TAILQ_FIRST(&mp->mnt_vnodelist); vp; vp = nvp) { - nvp = TAILQ_NEXT(vp, v_mntvnodes); + TAILQ_FOREACH_SAFE(vp, &mp->mnt_vnodelist, v_mntvnodes, nvp) { mutex_enter(vp->v_interlock); if ((vp->v_iflag & VI_CLEAN) != 0) { TAILQ_REMOVE(&mp->mnt_vnodelist, vp, v_mntvnodes); @@ -708,7 +708,7 @@ mount_domount(struct lwp *l, vnode_t **v mp->mnt_iflag &= ~IMNT_WANTRDWR; mutex_enter(&mountlist_lock); - CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list); + TAILQ_INSERT_TAIL(&mountlist, mp, mnt_list); mutex_exit(&mountlist_lock); if ((mp->mnt_flag & (MNT_RDONLY | MNT_ASYNC)) == 0) error = vfs_allocate_syncvnode(mp); @@ -741,7 +741,7 @@ mount_domount(struct lwp *l, vnode_t **v err_onmountlist: mutex_enter(&mountlist_lock); - CIRCLEQ_REMOVE(&mountlist, mp, mnt_list); + TAILQ_REMOVE(&mountlist, mp, mnt_list); mp->mnt_iflag |= IMNT_GONE; mutex_exit(&mountlist_lock); @@ -864,9 +864,9 @@ dounmount(struct mount *mp, int flags, s VOP_UNLOCK(coveredvp); } mutex_enter(&mountlist_lock); - CIRCLEQ_REMOVE(&mountlist, mp, mnt_list); + TAILQ_REMOVE(&mountlist, mp, mnt_list); mutex_exit(&mountlist_lock); - if (TAILQ_FIRST(&mp->mnt_vnodelist) != NULL) + if (TAILQ_FIRST(&mp->mnt_vnodelist) != TAILQ_END(&mp->mnt_vnodelist)) panic("unmount: dangling vnode"); if (used_syncer) mutex_exit(&syncer_mutex); @@ -909,7 +909,7 @@ vfs_unmount_forceone(struct lwp *l) nmp = NULL; - CIRCLEQ_FOREACH_REVERSE(mp, &mountlist, mnt_list) { + TAILQ_FOREACH_REVERSE(mp, &mountlist, mntlist, mnt_list) { if (nmp == NULL || mp->mnt_gen > nmp->mnt_gen) { nmp = mp; } @@ -945,10 +945,7 @@ vfs_unmountall1(struct lwp *l, bool forc bool any_error = false, progress = false; int error; - for (mp = CIRCLEQ_LAST(&mountlist); - mp != (void *)&mountlist; - mp = nmp) { - nmp = CIRCLEQ_PREV(mp, mnt_list); + TAILQ_FOREACH_REVERSE_SAFE(mp, &mountlist, mntlist, mnt_list, nmp) { #ifdef DEBUG printf("unmounting %p %s (%s)...\n", (void *)mp, mp->mnt_stat.f_mntonname, @@ -1150,16 +1147,18 @@ done: vrele(rootvp); } if (error == 0) { + struct mount *mp; extern struct cwdinfo cwdi0; - CIRCLEQ_FIRST(&mountlist)->mnt_flag |= MNT_ROOTFS; - CIRCLEQ_FIRST(&mountlist)->mnt_op->vfs_refcount++; + mp = TAILQ_FIRST(&mountlist); + mp->mnt_flag |= MNT_ROOTFS; + mp->mnt_op->vfs_refcount++; /* * Get the vnode for '/'. Set cwdi0.cwdi_cdir to * reference it. */ - error = VFS_ROOT(CIRCLEQ_FIRST(&mountlist), &rootvnode); + error = VFS_ROOT(mp, &rootvnode); if (error) panic("cannot find root vnode, error=%d", error); cwdi0.cwdi_cdir = rootvnode; @@ -1368,3 +1367,11 @@ makefstype(const char *type) } return rv; } + +void +mountlist_append(struct mount *mp) +{ + mutex_enter(&mountlist_lock); + TAILQ_INSERT_TAIL(&mountlist, mp, mnt_list); + mutex_exit(&mountlist_lock); +} Index: kern/vfs_subr.c =================================================================== RCS file: /cvsroot/src/sys/kern/vfs_subr.c,v retrieving revision 1.439 diff -u -p -u -r1.439 vfs_subr.c --- kern/vfs_subr.c 27 Oct 2013 16:19:33 -0000 1.439 +++ kern/vfs_subr.c 22 Nov 2013 21:50:39 -0000 @@ -631,7 +631,7 @@ sysctl_kern_vnode(SYSCTLFN_ARGS) sysctl_unlock(); mutex_enter(&mountlist_lock); - for (mp = CIRCLEQ_FIRST(&mountlist); mp != (void *)&mountlist; + for (mp = TAILQ_FIRST(&mountlist); mp != TAILQ_END(&mountlist); mp = nmp) { if (vfs_busy(mp, &nmp)) { continue; @@ -1264,7 +1264,7 @@ printlockedvnodes(void) printf("Locked vnodes\n"); mutex_enter(&mountlist_lock); - for (mp = CIRCLEQ_FIRST(&mountlist); mp != (void *)&mountlist; + for (mp = TAILQ_FIRST(&mountlist); mp != TAILQ_END(&mountlist); mp = nmp) { if (vfs_busy(mp, &nmp)) { continue; Index: kern/vfs_syscalls.c =================================================================== RCS file: /cvsroot/src/sys/kern/vfs_syscalls.c,v retrieving revision 1.469 diff -u -p -u -r1.469 vfs_syscalls.c --- kern/vfs_syscalls.c 18 Nov 2013 01:31:42 -0000 1.469 +++ kern/vfs_syscalls.c 22 Nov 2013 21:50:40 -0000 @@ -622,7 +622,7 @@ do_sys_sync(struct lwp *l) int asyncflag; mutex_enter(&mountlist_lock); - for (mp = CIRCLEQ_FIRST(&mountlist); mp != (void *)&mountlist; + for (mp = TAILQ_FIRST(&mountlist); mp != TAILQ_END(&mountlist); mp = nmp) { if (vfs_busy(mp, &nmp)) { continue; @@ -1237,7 +1237,7 @@ do_sys_getvfsstat(struct lwp *l, void *s maxcount = bufsize / entry_sz; mutex_enter(&mountlist_lock); count = 0; - for (mp = CIRCLEQ_FIRST(&mountlist); mp != (void *)&mountlist; + for (mp = TAILQ_FIRST(&mountlist); mp != TAILQ_END(&mountlist); mp = nmp) { if (vfs_busy(mp, &nmp)) { continue; Index: kern/vfs_trans.c =================================================================== RCS file: /cvsroot/src/sys/kern/vfs_trans.c,v retrieving revision 1.28 diff -u -p -u -r1.28 vfs_trans.c --- kern/vfs_trans.c 25 Oct 2013 20:38:10 -0000 1.28 +++ kern/vfs_trans.c 22 Nov 2013 21:50:41 -0000 @@ -812,7 +812,7 @@ fstrans_dump(int full) fstrans_print_lwp(p, l, full == 1); printf("Fstrans state by mount:\n"); - CIRCLEQ_FOREACH(mp, &mountlist, mnt_list) + TAILQ_FOREACH(mp, &mountlist, mnt_list) fstrans_print_mount(mp, full == 1); } #endif /* defined(DDB) */ Index: miscfs/procfs/procfs_linux.c =================================================================== RCS file: /cvsroot/src/sys/miscfs/procfs/procfs_linux.c,v retrieving revision 1.64 diff -u -p -u -r1.64 procfs_linux.c --- miscfs/procfs/procfs_linux.c 19 Dec 2011 03:02:31 -0000 1.64 +++ miscfs/procfs/procfs_linux.c 22 Nov 2013 21:50:41 -0000 @@ -599,7 +599,7 @@ procfs_domounts(struct lwp *curl, struct bf = malloc(LBFSZ, M_TEMP, M_WAITOK); mutex_enter(&mountlist_lock); - for (mp = CIRCLEQ_FIRST(&mountlist); mp != (void *)&mountlist; + for (mp = TAILQ_FIRST(&mountlist); mp != TAILQ_END(&mountlist); mp = nmp) { struct statvfs sfs; Index: nfs/nfs_vfsops.c =================================================================== RCS file: /cvsroot/src/sys/nfs/nfs_vfsops.c,v retrieving revision 1.222 diff -u -p -u -r1.222 nfs_vfsops.c --- nfs/nfs_vfsops.c 14 Sep 2013 22:27:01 -0000 1.222 +++ nfs/nfs_vfsops.c 22 Nov 2013 21:50:52 -0000 @@ -379,9 +379,7 @@ nfs_mountroot(void) /* * Link it into the mount list. */ - mutex_enter(&mountlist_lock); - CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list); - mutex_exit(&mountlist_lock); + mountlist_append(mp); rootvp = vp; mp->mnt_vnodecovered = NULLVP; vfs_unbusy(mp, false, NULL); Index: sys/mount.h =================================================================== RCS file: /cvsroot/src/sys/sys/mount.h,v retrieving revision 1.209 diff -u -p -u -r1.209 mount.h --- sys/mount.h 26 Apr 2013 22:27:16 -0000 1.209 +++ sys/mount.h 22 Nov 2013 21:50:55 -0000 @@ -107,7 +107,7 @@ struct vnode; * put on a doubly linked list. */ struct mount { - CIRCLEQ_ENTRY(mount) mnt_list; /* mount list */ + TAILQ_ENTRY(mount) mnt_list; /* mount list */ TAILQ_HEAD(, vnode) mnt_vnodelist; /* list of vnodes this mount */ struct vfsops *mnt_op; /* operations on fs */ struct vnode *mnt_vnodecovered; /* vnode we mounted on */ @@ -434,7 +434,7 @@ int vfs_quotactl_cursorrewind(struct mou int vfs_quotactl_quotaon(struct mount *, int, const char *); int vfs_quotactl_quotaoff(struct mount *, int); -extern CIRCLEQ_HEAD(mntlist, mount) mountlist; /* mounted filesystem list */ +extern TAILQ_HEAD(mntlist, mount) mountlist; /* mounted filesystem list */ extern struct vfsops *vfssw[]; /* filesystem type table */ extern int nvfssw; extern kmutex_t mountlist_lock; @@ -462,6 +462,7 @@ void * mount_getspecific(struct mount *, void mount_setspecific(struct mount *, specificdata_key_t, void *); int usermount_common_policy(struct mount *, u_long); +void mountlist_append(struct mount *); LIST_HEAD(vfs_list_head, vfsops); extern struct vfs_list_head vfs_list; Index: ufs/ext2fs/ext2fs_vfsops.c =================================================================== RCS file: /cvsroot/src/sys/ufs/ext2fs/ext2fs_vfsops.c,v retrieving revision 1.174 diff -u -p -u -r1.174 ext2fs_vfsops.c --- ufs/ext2fs/ext2fs_vfsops.c 29 Oct 2013 09:53:51 -0000 1.174 +++ ufs/ext2fs/ext2fs_vfsops.c 22 Nov 2013 21:50:55 -0000 @@ -278,9 +278,7 @@ ext2fs_mountroot(void) vfs_destroy(mp); return (error); } - mutex_enter(&mountlist_lock); - CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list); - mutex_exit(&mountlist_lock); + mountlist_append(mp); ump = VFSTOUFS(mp); fs = ump->um_e2fs; memset(fs->e2fs_fsmnt, 0, sizeof(fs->e2fs_fsmnt)); Index: ufs/ffs/ffs_vfsops.c =================================================================== RCS file: /cvsroot/src/sys/ufs/ffs/ffs_vfsops.c,v retrieving revision 1.290 diff -u -p -u -r1.290 ffs_vfsops.c --- ufs/ffs/ffs_vfsops.c 29 Oct 2013 09:53:51 -0000 1.290 +++ ufs/ffs/ffs_vfsops.c 22 Nov 2013 21:50:55 -0000 @@ -325,9 +325,7 @@ ffs_mountroot(void) return (error); } mp->mnt_flag &= ~MNT_FORCE; - mutex_enter(&mountlist_lock); - CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list); - mutex_exit(&mountlist_lock); + mountlist_append(mp); ump = VFSTOUFS(mp); fs = ump->um_fs; memset(fs->fs_fsmnt, 0, sizeof(fs->fs_fsmnt)); Index: ufs/lfs/lfs_bio.c =================================================================== RCS file: /cvsroot/src/sys/ufs/lfs/lfs_bio.c,v retrieving revision 1.126 diff -u -p -u -r1.126 lfs_bio.c --- ufs/lfs/lfs_bio.c 28 Jul 2013 01:05:52 -0000 1.126 +++ ufs/lfs/lfs_bio.c 22 Nov 2013 21:50:55 -0000 @@ -570,7 +570,7 @@ lfs_flush(struct lfs *fs, int flags, int } else { locked_fakequeue_count = 0; mutex_enter(&mountlist_lock); - for (mp = CIRCLEQ_FIRST(&mountlist); mp != (void *)&mountlist; + for (mp = TAILQ_FIRST(&mountlist); mp != TAILQ_END(&mountlist); mp = nmp) { if (vfs_busy(mp, &nmp)) { DLOG((DLOG_FLUSH, "lfs_flush: fs vfs_busy\n")); Index: ufs/lfs/lfs_vfsops.c =================================================================== RCS file: /cvsroot/src/sys/ufs/lfs/lfs_vfsops.c,v retrieving revision 1.315 diff -u -p -u -r1.315 lfs_vfsops.c --- ufs/lfs/lfs_vfsops.c 17 Oct 2013 21:01:08 -0000 1.315 +++ ufs/lfs/lfs_vfsops.c 22 Nov 2013 21:50:55 -0000 @@ -454,7 +454,7 @@ lfs_writerd(void *arg) mutex_enter(&mountlist_lock); lfsc = 0; skipc = 0; - for (mp = CIRCLEQ_FIRST(&mountlist); mp != (void *)&mountlist; + for (mp = TAILQ_FIRST(&mountlist); mp != TAILQ_END(&mountlist); mp = nmp) { if (vfs_busy(mp, &nmp)) { ++skipc; @@ -609,9 +609,7 @@ lfs_mountroot(void) vfs_destroy(mp); return (error); } - mutex_enter(&mountlist_lock); - CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list); - mutex_exit(&mountlist_lock); + mountlist_append(mp); ump = VFSTOULFS(mp); fs = ump->um_lfs; memset(fs->lfs_fsmnt, 0, sizeof(fs->lfs_fsmnt)); Index: ufs/mfs/mfs_vfsops.c =================================================================== RCS file: /cvsroot/src/sys/ufs/mfs/mfs_vfsops.c,v retrieving revision 1.103 diff -u -p -u -r1.103 mfs_vfsops.c --- ufs/mfs/mfs_vfsops.c 12 Jun 2011 03:36:01 -0000 1.103 +++ ufs/mfs/mfs_vfsops.c 22 Nov 2013 21:50:55 -0000 @@ -227,9 +227,7 @@ mfs_mountroot(void) kmem_free(mfsp, sizeof(*mfsp)); return (error); } - mutex_enter(&mountlist_lock); - CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list); - mutex_exit(&mountlist_lock); + mountlist_append(mp); mp->mnt_vnodecovered = NULLVP; ump = VFSTOUFS(mp); fs = ump->um_fs;