Date: Wed, 17 Nov 1999 19:37:28 -0800 (PST) From: jake@checker.org To: FreeBSD-gnats-submit@freebsd.org Subject: kern/14967: Convert mountlist and mount.mnt_list from CIRCLEQ to TAILQ Message-ID: <19991118033728.5C05F1FD7@24.66.174.118.bc.wave.home.com>
next in thread | raw e-mail | index | archive | help
>Number: 14967 >Category: kern >Synopsis: Convert mountlist and mount.mnt_list from CIRCLEQ to TAILQ >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Wed Nov 17 19:40:01 PST 1999 >Closed-Date: >Last-Modified: >Originator: Jake Burkholder >Release: FreeBSD 4.0-CURRENT i386 >Organization: none >Environment: 4.0-CURRENT >Description: struct mountlist and struct mount.mnt_list have no business being a CIRCLEQ. Change them to TAILQ_HEAD and TAILQ_ENTRY respectively. This removes ugly mp != (void*)&mountlist comparisons. >How-To-Repeat: n/a >Fix: Index: sys/coda/coda_vfsops.c =================================================================== RCS file: /home/ncvs/src/sys/coda/coda_vfsops.c,v retrieving revision 1.20 diff -c -r1.20 coda_vfsops.c *** coda_vfsops.c 1999/09/11 00:45:56 1.20 --- coda_vfsops.c 1999/11/17 21:43:46 *************** *** 507,516 **** struct mount *devtomp(dev) dev_t dev; { ! struct mount *mp, *nmp; ! ! for (mp = mountlist.cqh_first; mp != (void*)&mountlist; mp = nmp) { ! nmp = mp->mnt_list.cqe_next; if (((VFSTOUFS(mp))->um_dev == dev)) { /* mount corresponds to UFS and the device matches one we want */ return(mp); --- 507,515 ---- struct mount *devtomp(dev) dev_t dev; { ! struct mount *mp; ! ! TAILQ_FOREACH(mp, &mountlist, mnt_list) { if (((VFSTOUFS(mp))->um_dev == dev)) { /* mount corresponds to UFS and the device matches one we want */ return(mp); Index: sys/contrib/softupdates/ffs_softdep.c =================================================================== RCS file: /home/ncvs/src/sys/contrib/softupdates/ffs_softdep.c,v retrieving revision 1.36 diff -c -r1.36 ffs_softdep.c *** ffs_softdep.c 1999/08/28 02:16:29 1.36 --- ffs_softdep.c 1999/11/17 21:43:45 *************** *** 4363,4370 **** * Ugly code to find mount point given pointer to superblock. */ fs = inodedep->id_fs; ! for (mp = CIRCLEQ_FIRST(&mountlist); mp != (void *)&mountlist; ! mp = CIRCLEQ_NEXT(mp, mnt_list)) if ((mp->mnt_flag & MNT_SOFTDEP) && fs == VFSTOUFS(mp)->um_fs) break; /* --- 4363,4369 ---- * Ugly code to find mount point given pointer to superblock. */ fs = inodedep->id_fs; ! TAILQ_FOREACH(mp, &mountlist, mnt_list) if ((mp->mnt_flag & MNT_SOFTDEP) && fs == VFSTOUFS(mp)->um_fs) break; /* Index: sys/gnu/ext2fs/ext2_vfsops.c =================================================================== RCS file: /home/ncvs/src/sys/gnu/ext2fs/ext2_vfsops.c,v retrieving revision 1.57 diff -c -r1.57 ext2_vfsops.c *** ext2_vfsops.c 1999/11/09 14:15:10 1.57 --- ext2_vfsops.c 1999/11/17 21:43:45 *************** *** 144,150 **** bsd_free(mp, M_MOUNT); return (error); } ! CIRCLEQ_INSERT_HEAD(&mountlist, mp, mnt_list); mp->mnt_flag |= MNT_ROOTFS; mp->mnt_vnodecovered = NULLVP; ump = VFSTOUFS(mp); --- 144,150 ---- bsd_free(mp, M_MOUNT); return (error); } ! TAILQ_INSERT_HEAD(&mountlist, mp, mnt_list); mp->mnt_flag |= MNT_ROOTFS; mp->mnt_vnodecovered = NULLVP; ump = VFSTOUFS(mp); Index: sys/kern/init_main.c =================================================================== RCS file: /home/ncvs/src/sys/kern/init_main.c,v retrieving revision 1.131 diff -c -r1.131 init_main.c *** init_main.c 1999/11/16 10:56:04 1.131 --- init_main.c 1999/11/17 21:43:45 *************** *** 447,453 **** register struct filedesc0 *fdp = &filedesc0; /* Get the vnode for '/'. Set fdp->fd_fd.fd_cdir to reference it. */ ! if (VFS_ROOT(CIRCLEQ_FIRST(&mountlist), &rootvnode)) panic("cannot find root vnode"); fdp->fd_fd.fd_cdir = rootvnode; VREF(fdp->fd_fd.fd_cdir); --- 447,453 ---- register struct filedesc0 *fdp = &filedesc0; /* Get the vnode for '/'. Set fdp->fd_fd.fd_cdir to reference it. */ ! if (VFS_ROOT(TAILQ_FIRST(&mountlist), &rootvnode)) panic("cannot find root vnode"); fdp->fd_fd.fd_cdir = rootvnode; VREF(fdp->fd_fd.fd_cdir); Index: sys/kern/kern_shutdown.c =================================================================== RCS file: /home/ncvs/src/sys/kern/kern_shutdown.c,v retrieving revision 1.66 diff -c -r1.66 kern_shutdown.c *** kern_shutdown.c 1999/11/08 19:36:45 1.66 --- kern_shutdown.c 1999/11/17 21:43:45 *************** *** 229,235 **** if (((bp->b_flags&B_INVAL) == 0 && BUF_REFCNT(bp)) || ((bp->b_flags & (B_DELWRI|B_INVAL)) == B_DELWRI)) { if (bp->b_dev == NODEV) { ! CIRCLEQ_REMOVE(&mountlist, bp->b_vp->v_mount, mnt_list); continue; } --- 229,235 ---- if (((bp->b_flags&B_INVAL) == 0 && BUF_REFCNT(bp)) || ((bp->b_flags & (B_DELWRI|B_INVAL)) == B_DELWRI)) { if (bp->b_dev == NODEV) { ! TAILQ_REMOVE(&mountlist, bp->b_vp->v_mount, mnt_list); continue; } Index: sys/kern/vfs_conf.c =================================================================== RCS file: /home/ncvs/src/sys/kern/vfs_conf.c,v retrieving revision 1.41 diff -c -r1.41 vfs_conf.c *** vfs_conf.c 1999/11/08 11:44:51 1.41 --- vfs_conf.c 1999/11/17 21:43:45 *************** *** 213,219 **** /* register with list of mounted filesystems */ simple_lock(&mountlist_slock); ! CIRCLEQ_INSERT_HEAD(&mountlist, mp, mnt_list); simple_unlock(&mountlist_slock); /* sanity check system clock against root filesystem timestamp */ --- 213,219 ---- /* register with list of mounted filesystems */ simple_lock(&mountlist_slock); ! TAILQ_INSERT_HEAD(&mountlist, mp, mnt_list); simple_unlock(&mountlist_slock); /* sanity check system clock against root filesystem timestamp */ Index: sys/kern/vfs_subr.c =================================================================== RCS file: /home/ncvs/src/sys/kern/vfs_subr.c,v retrieving revision 1.234 diff -c -r1.234 vfs_subr.c *** vfs_subr.c 1999/11/16 16:28:57 1.234 --- vfs_subr.c 1999/11/18 01:21:42 *************** *** 172,178 **** TAILQ_INIT(&vnode_free_list); TAILQ_INIT(&vnode_tobefree_list); simple_lock_init(&vnode_free_list_slock); ! CIRCLEQ_INIT(&mountlist); vnode_zone = zinit("VNODE", sizeof (struct vnode), 0, 0, 5); /* * Initialize the filesystem syncer. --- 172,178 ---- TAILQ_INIT(&vnode_free_list); TAILQ_INIT(&vnode_tobefree_list); simple_lock_init(&vnode_free_list_slock); ! TAILQ_INIT(&mountlist); vnode_zone = zinit("VNODE", sizeof (struct vnode), 0, 0, 5); /* * Initialize the filesystem syncer. *************** *** 315,321 **** register struct mount *mp; simple_lock(&mountlist_slock); ! CIRCLEQ_FOREACH(mp, &mountlist, mnt_list) { if (mp->mnt_stat.f_fsid.val[0] == fsid->val[0] && mp->mnt_stat.f_fsid.val[1] == fsid->val[1]) { simple_unlock(&mountlist_slock); --- 315,321 ---- register struct mount *mp; simple_lock(&mountlist_slock); ! TAILQ_FOREACH(mp, &mountlist, mnt_list) { if (mp->mnt_stat.f_fsid.val[0] == fsid->val[0] && mp->mnt_stat.f_fsid.val[1] == fsid->val[1]) { simple_unlock(&mountlist_slock); *************** *** 1973,1981 **** printf("Locked vnodes\n"); simple_lock(&mountlist_slock); ! for (mp = CIRCLEQ_FIRST(&mountlist); mp != (void *)&mountlist; mp = nmp) { if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) { ! nmp = CIRCLEQ_NEXT(mp, mnt_list); continue; } LIST_FOREACH(vp, &mp->mnt_vnodelist, v_mntvnodes) { --- 1973,1981 ---- printf("Locked vnodes\n"); simple_lock(&mountlist_slock); ! for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) { if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) { ! nmp = TAILQ_NEXT(mp, mnt_list); continue; } LIST_FOREACH(vp, &mp->mnt_vnodelist, v_mntvnodes) { *************** *** 1983,1989 **** vprint((char *)0, vp); } simple_lock(&mountlist_slock); ! nmp = CIRCLEQ_NEXT(mp, mnt_list); vfs_unbusy(mp, p); } simple_unlock(&mountlist_slock); --- 1983,1989 ---- vprint((char *)0, vp); } simple_lock(&mountlist_slock); ! nmp = TAILQ_NEXT(mp, mnt_list); vfs_unbusy(mp, p); } simple_unlock(&mountlist_slock); *************** *** 2091,2100 **** (numvnodes + KINFO_VNODESLOP) * (VPTRSZ + VNODESZ))); simple_lock(&mountlist_slock); ! mp = CIRCLEQ_FIRST(&mountlist); ! for (; mp != (void *)&mountlist; mp = nmp) { if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) { ! nmp = CIRCLEQ_NEXT(mp, mnt_list); continue; } again: --- 2091,2099 ---- (numvnodes + KINFO_VNODESLOP) * (VPTRSZ + VNODESZ))); simple_lock(&mountlist_slock); ! for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) { if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) { ! nmp = TAILQ_NEXT(mp, mnt_list); continue; } again: *************** *** 2120,2126 **** } simple_unlock(&mntvnode_slock); simple_lock(&mountlist_slock); ! nmp = CIRCLEQ_NEXT(mp, mnt_list); vfs_unbusy(mp, p); } simple_unlock(&mountlist_slock); --- 2119,2125 ---- } simple_unlock(&mntvnode_slock); simple_lock(&mountlist_slock); ! nmp = TAILQ_NEXT(mp, mnt_list); vfs_unbusy(mp, p); } simple_unlock(&mountlist_slock); *************** *** 2170,2180 **** /* * Since this only runs when rebooting, it is not interlocked. */ ! mp = CIRCLEQ_LAST(&mountlist); ! for (; mp != (void *)&mountlist; mp = nmp) { ! nmp = CIRCLEQ_PREV(mp, mnt_list); error = dounmount(mp, MNT_FORCE, p); if (error) { printf("unmount of %s failed (", mp->mnt_stat.f_mntonname); if (error == EBUSY) --- 2169,2179 ---- /* * Since this only runs when rebooting, it is not interlocked. */ ! while(!TAILQ_EMPTY(&mountlist)) { ! mp = TAILQ_LAST(&mountlist, mntlist); error = dounmount(mp, MNT_FORCE, p); if (error) { + TAILQ_REMOVE(&mountlist, mp, mnt_list); printf("unmount of %s failed (", mp->mnt_stat.f_mntonname); if (error == EBUSY) Index: sys/kern/vfs_syscalls.c =================================================================== RCS file: /home/ncvs/src/sys/kern/vfs_syscalls.c,v retrieving revision 1.144 diff -c -r1.144 vfs_syscalls.c *** vfs_syscalls.c 1999/11/16 16:28:58 1.144 --- vfs_syscalls.c 1999/11/17 21:43:45 *************** *** 331,337 **** vp->v_mountedhere = mp; simple_unlock(&vp->v_interlock); simple_lock(&mountlist_slock); ! CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list); simple_unlock(&mountlist_slock); checkdirs(vp); VOP_UNLOCK(vp, 0, p); --- 331,337 ---- vp->v_mountedhere = mp; simple_unlock(&vp->v_interlock); simple_lock(&mountlist_slock); ! TAILQ_INSERT_TAIL(&mountlist, mp, mnt_list); simple_unlock(&mountlist_slock); checkdirs(vp); VOP_UNLOCK(vp, 0, p); *************** *** 494,500 **** wakeup((caddr_t)mp); return (error); } ! CIRCLEQ_REMOVE(&mountlist, mp, mnt_list); if ((coveredvp = mp->mnt_vnodecovered) != NULLVP) { coveredvp->v_mountedhere = (struct mount *)0; vrele(coveredvp); --- 494,500 ---- wakeup((caddr_t)mp); return (error); } ! TAILQ_REMOVE(&mountlist, mp, mnt_list); if ((coveredvp = mp->mnt_vnodecovered) != NULLVP) { coveredvp->v_mountedhere = (struct mount *)0; vrele(coveredvp); *************** *** 533,542 **** int asyncflag; simple_lock(&mountlist_slock); ! mp = CIRCLEQ_FIRST(&mountlist); ! for (; mp != (void *)&mountlist; mp = nmp) { if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) { ! nmp = CIRCLEQ_NEXT(mp, mnt_list); continue; } if ((mp->mnt_flag & MNT_RDONLY) == 0) { --- 533,541 ---- int asyncflag; simple_lock(&mountlist_slock); ! for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) { if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) { ! nmp = TAILQ_NEXT(mp, mnt_list); continue; } if ((mp->mnt_flag & MNT_RDONLY) == 0) { *************** *** 548,554 **** mp->mnt_flag |= asyncflag; } simple_lock(&mountlist_slock); ! nmp = CIRCLEQ_NEXT(mp, mnt_list); vfs_unbusy(mp, p); } simple_unlock(&mountlist_slock); --- 547,553 ---- mp->mnt_flag |= asyncflag; } simple_lock(&mountlist_slock); ! nmp = TAILQ_NEXT(mp, mnt_list); vfs_unbusy(mp, p); } simple_unlock(&mountlist_slock); *************** *** 718,727 **** sfsp = (caddr_t)SCARG(uap, buf); count = 0; simple_lock(&mountlist_slock); ! mp = CIRCLEQ_FIRST(&mountlist); ! for (; mp != (void *)&mountlist; mp = nmp) { if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) { ! nmp = CIRCLEQ_NEXT(mp, mnt_list); continue; } if (sfsp && count < maxcount) { --- 717,725 ---- sfsp = (caddr_t)SCARG(uap, buf); count = 0; simple_lock(&mountlist_slock); ! for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) { if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) { ! nmp = TAILQ_NEXT(mp, mnt_list); continue; } if (sfsp && count < maxcount) { *************** *** 735,741 **** (SCARG(uap, flags) & MNT_WAIT)) && (error = VFS_STATFS(mp, sp, p))) { simple_lock(&mountlist_slock); ! nmp = CIRCLEQ_NEXT(mp, mnt_list); vfs_unbusy(mp, p); continue; } --- 733,739 ---- (SCARG(uap, flags) & MNT_WAIT)) && (error = VFS_STATFS(mp, sp, p))) { simple_lock(&mountlist_slock); ! nmp = TAILQ_NEXT(mp, mnt_list); vfs_unbusy(mp, p); continue; } *************** *** 749,755 **** } count++; simple_lock(&mountlist_slock); ! nmp = CIRCLEQ_NEXT(mp, mnt_list); vfs_unbusy(mp, p); } simple_unlock(&mountlist_slock); --- 747,753 ---- } count++; simple_lock(&mountlist_slock); ! nmp = TAILQ_NEXT(mp, mnt_list); vfs_unbusy(mp, p); } simple_unlock(&mountlist_slock); Index: sys/miscfs/devfs/devfs_vfsops.c =================================================================== RCS file: /home/ncvs/src/sys/miscfs/devfs/devfs_vfsops.c,v retrieving revision 1.39 diff -c -r1.39 devfs_vfsops.c *** devfs_vfsops.c 1999/09/11 00:46:00 1.39 --- devfs_vfsops.c 1999/11/17 21:43:46 *************** *** 67,73 **** /* Mark a reference for the "invisible" blueprint mount */ mp->mnt_vfc->vfc_refcount++; ! CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list); printf("DEVFS: ready to run\n"); return 0; /*XXX*/ --- 67,73 ---- /* Mark a reference for the "invisible" blueprint mount */ mp->mnt_vfc->vfc_refcount++; ! TAILQ_INSERT_TAIL(&mountlist, mp, mnt_list); printf("DEVFS: ready to run\n"); return 0; /*XXX*/ Index: sys/msdosfs/msdosfs_vfsops.c =================================================================== RCS file: /home/ncvs/src/sys/msdosfs/msdosfs_vfsops.c,v retrieving revision 1.54 diff -c -r1.54 msdosfs_vfsops.c *** msdosfs_vfsops.c 1999/11/09 14:15:30 1.54 --- msdosfs_vfsops.c 1999/11/17 21:43:46 *************** *** 188,194 **** return (error); } ! CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list); mp->mnt_vnodecovered = NULLVP; (void) copystr("/", mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size); --- 188,194 ---- return (error); } ! TAILQ_INSERT_TAIL(&mountlist, mp, mnt_list); mp->mnt_vnodecovered = NULLVP; (void) copystr("/", mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size); Index: sys/nfs/nfs_nqlease.c =================================================================== RCS file: /home/ncvs/src/sys/nfs/nfs_nqlease.c,v retrieving revision 1.45 diff -c -r1.45 nfs_nqlease.c *** nfs_nqlease.c 1999/11/11 17:24:02 1.45 --- nfs_nqlease.c 1999/11/17 21:43:46 *************** *** 1216,1224 **** * queues. */ simple_lock(&mountlist_slock); ! for (mp = mountlist.cqh_first; mp != (void *)&mountlist; mp = nxtmp) { if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) { ! nxtmp = mp->mnt_list.cqe_next; continue; } if (mp->mnt_stat.f_type == nfs_mount_type) { --- 1216,1224 ---- * queues. */ simple_lock(&mountlist_slock); ! for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nxtmp) { if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) { ! nxtmp = TAILQ_NEXT(mp, mnt_list); continue; } if (mp->mnt_stat.f_type == nfs_mount_type) { *************** *** 1232,1238 **** } } simple_lock(&mountlist_slock); ! nxtmp = mp->mnt_list.cqe_next; vfs_unbusy(mp, p); } simple_unlock(&mountlist_slock); --- 1232,1238 ---- } } simple_lock(&mountlist_slock); ! nxtmp = TAILQ_NEXT(mp, mnt_list); vfs_unbusy(mp, p); } simple_unlock(&mountlist_slock); Index: sys/sys/mount.h =================================================================== RCS file: /home/ncvs/src/sys/sys/mount.h,v retrieving revision 1.83 diff -c -r1.83 mount.h *** mount.h 1999/11/01 04:57:41 1.83 --- mount.h 1999/11/17 21:43:46 *************** *** 97,103 **** LIST_HEAD(vnodelst, vnode); struct mount { ! 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 */ --- 97,103 ---- LIST_HEAD(vnodelst, vnode); struct mount { ! TAILQ_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 */ *************** *** 403,409 **** void vfs_unmountall __P((void)); int vfs_register __P((struct vfsconf *)); int vfs_unregister __P((struct vfsconf *)); ! extern CIRCLEQ_HEAD(mntlist, mount) mountlist; /* mounted filesystem list */ extern struct simplelock mountlist_slock; extern struct nfs_public nfs_pub; --- 403,409 ---- void vfs_unmountall __P((void)); int vfs_register __P((struct vfsconf *)); int vfs_unregister __P((struct vfsconf *)); ! extern TAILQ_HEAD(mntlist, mount) mountlist; /* mounted filesystem list */ extern struct simplelock mountlist_slock; extern struct nfs_public nfs_pub; Index: usr.sbin/pstat/pstat.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/pstat/pstat.c,v retrieving revision 1.44 diff -c -r1.44 pstat.c *** pstat.c 1999/08/28 01:19:14 1.44 --- pstat.c 1999/11/18 01:16:28 *************** *** 677,685 **** bp = vbuf; evbuf = vbuf + (numvnodes + 20) * (VPTRSZ + VNODESZ); KGET(V_MOUNTLIST, mountlist); ! for (num = 0, mp = mountlist.cqh_first; ; mp = mp_next) { KGET2(mp, &mount, sizeof(mount), "mount entry"); ! mp_next = mount.mnt_list.cqe_next; for (vp = mount.mnt_vnodelist.lh_first; vp != NULL; vp = vp_next) { KGET2(vp, &vnode, sizeof(vnode), "vnode"); --- 677,685 ---- bp = vbuf; evbuf = vbuf + (numvnodes + 20) * (VPTRSZ + VNODESZ); KGET(V_MOUNTLIST, mountlist); ! for (num = 0, mp = TAILQ_FIRST(&mountlist); ; mp = mp_next) { KGET2(mp, &mount, sizeof(mount), "mount entry"); ! mp_next = TAILQ_NEXT(&mount, mnt_list); for (vp = mount.mnt_vnodelist.lh_first; vp != NULL; vp = vp_next) { KGET2(vp, &vnode, sizeof(vnode), "vnode"); *************** *** 693,699 **** bp += VNODESZ; num++; } ! if (mp == mountlist.cqh_last) break; } *avnodes = num; --- 693,699 ---- bp += VNODESZ; num++; } ! if (mp == TAILQ_LAST(&mountlist, mntlist)) break; } *avnodes = num; >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19991118033728.5C05F1FD7>