Deleted Added
sdiff udiff text old ( 53225 ) new ( 53452 )
full compact
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 53225 1999-11-16 16:28:58Z 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; /* mounted filesystem list */
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 CIRCLEQ_INIT(&mountlist);
176 vnode_zone = zinit("VNODE", sizeof (struct vnode), 0, 0, 5);
177 /*
178 * Initialize the filesystem syncer.
179 */
180 syncer_workitem_pending = hashinit(syncer_maxdelay, M_VNODE,
181 &syncer_mask);
182 syncer_maxdelay = syncer_mask + 1;
183}

--- 126 unchanged lines hidden (view full) ---

310 */
311struct mount *
312vfs_getvfs(fsid)
313 fsid_t *fsid;
314{
315 register struct mount *mp;
316
317 simple_lock(&mountlist_slock);
318 CIRCLEQ_FOREACH(mp, &mountlist, mnt_list) {
319 if (mp->mnt_stat.f_fsid.val[0] == fsid->val[0] &&
320 mp->mnt_stat.f_fsid.val[1] == fsid->val[1]) {
321 simple_unlock(&mountlist_slock);
322 return (mp);
323 }
324 }
325 simple_unlock(&mountlist_slock);
326 return ((struct mount *) 0);

--- 1641 unchanged lines hidden (view full) ---

1968DB_SHOW_COMMAND(lockedvnodes, lockedvnodes)
1969{
1970 struct proc *p = curproc; /* XXX */
1971 struct mount *mp, *nmp;
1972 struct vnode *vp;
1973
1974 printf("Locked vnodes\n");
1975 simple_lock(&mountlist_slock);
1976 for (mp = CIRCLEQ_FIRST(&mountlist); mp != (void *)&mountlist; mp = nmp) {
1977 if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) {
1978 nmp = CIRCLEQ_NEXT(mp, mnt_list);
1979 continue;
1980 }
1981 LIST_FOREACH(vp, &mp->mnt_vnodelist, v_mntvnodes) {
1982 if (VOP_ISLOCKED(vp))
1983 vprint((char *)0, vp);
1984 }
1985 simple_lock(&mountlist_slock);
1986 nmp = CIRCLEQ_NEXT(mp, mnt_list);
1987 vfs_unbusy(mp, p);
1988 }
1989 simple_unlock(&mountlist_slock);
1990}
1991#endif
1992
1993/*
1994 * Top level filesystem related information gathering.

--- 91 unchanged lines hidden (view full) ---

2086#define VNODESZ sizeof (struct vnode)
2087
2088 req->lock = 0;
2089 if (!req->oldptr) /* Make an estimate */
2090 return (SYSCTL_OUT(req, 0,
2091 (numvnodes + KINFO_VNODESLOP) * (VPTRSZ + VNODESZ)));
2092
2093 simple_lock(&mountlist_slock);
2094 mp = CIRCLEQ_FIRST(&mountlist);
2095 for (; mp != (void *)&mountlist; mp = nmp) {
2096 if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) {
2097 nmp = CIRCLEQ_NEXT(mp, mnt_list);
2098 continue;
2099 }
2100again:
2101 simple_lock(&mntvnode_slock);
2102 for (vp = LIST_FIRST(&mp->mnt_vnodelist);
2103 vp != NULL;
2104 vp = nvp) {
2105 /*

--- 9 unchanged lines hidden (view full) ---

2115 simple_unlock(&mntvnode_slock);
2116 if ((error = SYSCTL_OUT(req, &vp, VPTRSZ)) ||
2117 (error = SYSCTL_OUT(req, vp, VNODESZ)))
2118 return (error);
2119 simple_lock(&mntvnode_slock);
2120 }
2121 simple_unlock(&mntvnode_slock);
2122 simple_lock(&mountlist_slock);
2123 nmp = CIRCLEQ_NEXT(mp, mnt_list);
2124 vfs_unbusy(mp, p);
2125 }
2126 simple_unlock(&mountlist_slock);
2127
2128 return (0);
2129}
2130#endif
2131

--- 22 unchanged lines hidden (view full) ---

2154
2155/*
2156 * Unmount all filesystems. The list is traversed in reverse order
2157 * of mounting to avoid dependencies.
2158 */
2159void
2160vfs_unmountall()
2161{
2162 struct mount *mp, *nmp;
2163 struct proc *p;
2164 int error;
2165
2166 if (curproc != NULL)
2167 p = curproc;
2168 else
2169 p = initproc; /* XXX XXX should this be proc0? */
2170 /*
2171 * Since this only runs when rebooting, it is not interlocked.
2172 */
2173 mp = CIRCLEQ_LAST(&mountlist);
2174 for (; mp != (void *)&mountlist; mp = nmp) {
2175 nmp = CIRCLEQ_PREV(mp, mnt_list);
2176 error = dounmount(mp, MNT_FORCE, p);
2177 if (error) {
2178 printf("unmount of %s failed (",
2179 mp->mnt_stat.f_mntonname);
2180 if (error == EBUSY)
2181 printf("BUSY)\n");
2182 else
2183 printf("%d)\n", error);
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 ---