1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 22 unchanged lines hidden (view full) --- 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)vfs_subr.c 8.31 (Berkeley) 5/26/95 |
39 * $FreeBSD: head/sys/kern/vfs_export.c 53452 1999-11-20 10:00:46Z phk $ |
40 */ 41 42/* 43 * External virtual filesystem routines 44 */ 45#include "opt_ddb.h" 46 47#include <sys/param.h> --- 63 unchanged lines hidden (view full) --- 111static int reassignbufmethod = 1; 112SYSCTL_INT(_vfs, OID_AUTO, reassignbufmethod, CTLFLAG_RW, &reassignbufmethod, 0, ""); 113 114#ifdef ENABLE_VFS_IOOPT 115int vfs_ioopt = 0; 116SYSCTL_INT(_vfs, OID_AUTO, ioopt, CTLFLAG_RW, &vfs_ioopt, 0, ""); 117#endif 118 |
119struct mntlist mountlist = TAILQ_HEAD_INITIALIZER(mountlist); /* mounted fs */ |
120struct simplelock mountlist_slock; 121struct simplelock mntvnode_slock; 122int nfs_mount_type = -1; 123#ifndef NULL_SIMPLELOCKS 124static struct simplelock mntid_slock; 125static struct simplelock vnode_free_list_slock; 126static struct simplelock spechash_slock; 127#endif --- 39 unchanged lines hidden (view full) --- 167 168 desiredvnodes = maxproc + cnt.v_page_count / 4; 169 simple_lock_init(&mntvnode_slock); 170 simple_lock_init(&mntid_slock); 171 simple_lock_init(&spechash_slock); 172 TAILQ_INIT(&vnode_free_list); 173 TAILQ_INIT(&vnode_tobefree_list); 174 simple_lock_init(&vnode_free_list_slock); |
175 vnode_zone = zinit("VNODE", sizeof (struct vnode), 0, 0, 5); 176 /* 177 * Initialize the filesystem syncer. 178 */ 179 syncer_workitem_pending = hashinit(syncer_maxdelay, M_VNODE, 180 &syncer_mask); 181 syncer_maxdelay = syncer_mask + 1; 182} --- 126 unchanged lines hidden (view full) --- 309 */ 310struct mount * 311vfs_getvfs(fsid) 312 fsid_t *fsid; 313{ 314 register struct mount *mp; 315 316 simple_lock(&mountlist_slock); |
317 TAILQ_FOREACH(mp, &mountlist, mnt_list) { |
318 if (mp->mnt_stat.f_fsid.val[0] == fsid->val[0] && 319 mp->mnt_stat.f_fsid.val[1] == fsid->val[1]) { 320 simple_unlock(&mountlist_slock); 321 return (mp); 322 } 323 } 324 simple_unlock(&mountlist_slock); 325 return ((struct mount *) 0); --- 1641 unchanged lines hidden (view full) --- 1967DB_SHOW_COMMAND(lockedvnodes, lockedvnodes) 1968{ 1969 struct proc *p = curproc; /* XXX */ 1970 struct mount *mp, *nmp; 1971 struct vnode *vp; 1972 1973 printf("Locked vnodes\n"); 1974 simple_lock(&mountlist_slock); |
1975 for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) { |
1976 if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) { |
1977 nmp = TAILQ_NEXT(mp, mnt_list); |
1978 continue; 1979 } 1980 LIST_FOREACH(vp, &mp->mnt_vnodelist, v_mntvnodes) { 1981 if (VOP_ISLOCKED(vp)) 1982 vprint((char *)0, vp); 1983 } 1984 simple_lock(&mountlist_slock); |
1985 nmp = TAILQ_NEXT(mp, mnt_list); |
1986 vfs_unbusy(mp, p); 1987 } 1988 simple_unlock(&mountlist_slock); 1989} 1990#endif 1991 1992/* 1993 * Top level filesystem related information gathering. --- 91 unchanged lines hidden (view full) --- 2085#define VNODESZ sizeof (struct vnode) 2086 2087 req->lock = 0; 2088 if (!req->oldptr) /* Make an estimate */ 2089 return (SYSCTL_OUT(req, 0, 2090 (numvnodes + KINFO_VNODESLOP) * (VPTRSZ + VNODESZ))); 2091 2092 simple_lock(&mountlist_slock); |
2093 for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) { |
2094 if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) { |
2095 nmp = TAILQ_NEXT(mp, mnt_list); |
2096 continue; 2097 } 2098again: 2099 simple_lock(&mntvnode_slock); 2100 for (vp = LIST_FIRST(&mp->mnt_vnodelist); 2101 vp != NULL; 2102 vp = nvp) { 2103 /* --- 9 unchanged lines hidden (view full) --- 2113 simple_unlock(&mntvnode_slock); 2114 if ((error = SYSCTL_OUT(req, &vp, VPTRSZ)) || 2115 (error = SYSCTL_OUT(req, vp, VNODESZ))) 2116 return (error); 2117 simple_lock(&mntvnode_slock); 2118 } 2119 simple_unlock(&mntvnode_slock); 2120 simple_lock(&mountlist_slock); |
2121 nmp = TAILQ_NEXT(mp, mnt_list); |
2122 vfs_unbusy(mp, p); 2123 } 2124 simple_unlock(&mountlist_slock); 2125 2126 return (0); 2127} 2128#endif 2129 --- 22 unchanged lines hidden (view full) --- 2152 2153/* 2154 * Unmount all filesystems. The list is traversed in reverse order 2155 * of mounting to avoid dependencies. 2156 */ 2157void 2158vfs_unmountall() 2159{ |
2160 struct mount *mp; |
2161 struct proc *p; 2162 int error; 2163 2164 if (curproc != NULL) 2165 p = curproc; 2166 else 2167 p = initproc; /* XXX XXX should this be proc0? */ 2168 /* 2169 * Since this only runs when rebooting, it is not interlocked. 2170 */ |
2171 while(!TAILQ_EMPTY(&mountlist)) { 2172 mp = TAILQ_LAST(&mountlist, mntlist); |
2173 error = dounmount(mp, MNT_FORCE, p); 2174 if (error) { |
2175 TAILQ_REMOVE(&mountlist, mp, mnt_list); |
2176 printf("unmount of %s failed (", 2177 mp->mnt_stat.f_mntonname); 2178 if (error == EBUSY) 2179 printf("BUSY)\n"); 2180 else 2181 printf("%d)\n", error); |
2182 } else { 2183 /* The unmount has removed mp from the mountlist */ |
2184 } 2185 } 2186} 2187 2188/* 2189 * Build hash lists of net addresses and hang them off the mount point. 2190 * Called by ufs_mount() to set up the lists of export addresses. 2191 */ --- 689 unchanged lines hidden --- |