Deleted Added
full compact
vfs_export.c (53225) vfs_export.c (53452)
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
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 $
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
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 */
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);
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);
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);
318 CIRCLEQ_FOREACH(mp, &mountlist, mnt_list) {
317 TAILQ_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);
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);
1976 for (mp = CIRCLEQ_FIRST(&mountlist); mp != (void *)&mountlist; mp = nmp) {
1975 for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) {
1977 if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) {
1976 if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) {
1978 nmp = CIRCLEQ_NEXT(mp, mnt_list);
1977 nmp = TAILQ_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);
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);
1986 nmp = CIRCLEQ_NEXT(mp, mnt_list);
1985 nmp = TAILQ_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);
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);
2094 mp = CIRCLEQ_FIRST(&mountlist);
2095 for (; mp != (void *)&mountlist; mp = nmp) {
2093 for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) {
2096 if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) {
2094 if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) {
2097 nmp = CIRCLEQ_NEXT(mp, mnt_list);
2095 nmp = TAILQ_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);
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);
2123 nmp = CIRCLEQ_NEXT(mp, mnt_list);
2121 nmp = TAILQ_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{
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{
2162 struct mount *mp, *nmp;
2160 struct mount *mp;
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 */
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 */
2173 mp = CIRCLEQ_LAST(&mountlist);
2174 for (; mp != (void *)&mountlist; mp = nmp) {
2175 nmp = CIRCLEQ_PREV(mp, mnt_list);
2171 while(!TAILQ_EMPTY(&mountlist)) {
2172 mp = TAILQ_LAST(&mountlist, mntlist);
2176 error = dounmount(mp, MNT_FORCE, p);
2177 if (error) {
2173 error = dounmount(mp, MNT_FORCE, p);
2174 if (error) {
2175 TAILQ_REMOVE(&mountlist, mp, mnt_list);
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);
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 ---
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 ---