Deleted Added
full compact
vfs_export.c (53059) vfs_export.c (53225)
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 53059 1999-11-09 14:15:33Z phk $
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>

--- 262 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);
40 */
41
42/*
43 * External virtual filesystem routines
44 */
45#include "opt_ddb.h"
46
47#include <sys/param.h>

--- 262 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 for (mp = mountlist.cqh_first; mp != (void *)&mountlist;
319 mp = mp->mnt_list.cqe_next) {
318 CIRCLEQ_FOREACH(mp, &mountlist, mnt_list) {
320 if (mp->mnt_stat.f_fsid.val[0] == fsid->val[0] &&
321 mp->mnt_stat.f_fsid.val[1] == fsid->val[1]) {
322 simple_unlock(&mountlist_slock);
323 return (mp);
324 }
325 }
326 simple_unlock(&mountlist_slock);
327 return ((struct mount *) 0);

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

1538 int flags;
1539{
1540 struct proc *p = curproc; /* XXX */
1541 struct vnode *vp, *nvp;
1542 int busy = 0;
1543
1544 simple_lock(&mntvnode_slock);
1545loop:
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);

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

1537 int flags;
1538{
1539 struct proc *p = curproc; /* XXX */
1540 struct vnode *vp, *nvp;
1541 int busy = 0;
1542
1543 simple_lock(&mntvnode_slock);
1544loop:
1546 for (vp = mp->mnt_vnodelist.lh_first; vp; vp = nvp) {
1545 for (vp = LIST_FIRST(&mp->mnt_vnodelist); vp; vp = nvp) {
1547 /*
1548 * Make sure this vnode wasn't reclaimed in getnewvnode().
1549 * Start over if it has (it won't be on the list anymore).
1550 */
1551 if (vp->v_mount != mp)
1552 goto loop;
1546 /*
1547 * Make sure this vnode wasn't reclaimed in getnewvnode().
1548 * Start over if it has (it won't be on the list anymore).
1549 */
1550 if (vp->v_mount != mp)
1551 goto loop;
1553 nvp = vp->v_mntvnodes.le_next;
1552 nvp = LIST_NEXT(vp, v_mntvnodes);
1554 /*
1555 * Skip over a selected vnode.
1556 */
1557 if (vp == skipvp)
1558 continue;
1559
1560 simple_lock(&vp->v_interlock);
1561 /*

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

1969DB_SHOW_COMMAND(lockedvnodes, lockedvnodes)
1970{
1971 struct proc *p = curproc; /* XXX */
1972 struct mount *mp, *nmp;
1973 struct vnode *vp;
1974
1975 printf("Locked vnodes\n");
1976 simple_lock(&mountlist_slock);
1553 /*
1554 * Skip over a selected vnode.
1555 */
1556 if (vp == skipvp)
1557 continue;
1558
1559 simple_lock(&vp->v_interlock);
1560 /*

--- 407 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);
1977 for (mp = mountlist.cqh_first; mp != (void *)&mountlist; mp = nmp) {
1976 for (mp = CIRCLEQ_FIRST(&mountlist); mp != (void *)&mountlist; mp = nmp) {
1978 if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) {
1977 if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) {
1979 nmp = mp->mnt_list.cqe_next;
1978 nmp = CIRCLEQ_NEXT(mp, mnt_list);
1980 continue;
1981 }
1979 continue;
1980 }
1982 for (vp = mp->mnt_vnodelist.lh_first;
1983 vp != NULL;
1984 vp = vp->v_mntvnodes.le_next) {
1981 LIST_FOREACH(vp, &mp->mnt_vnodelist, v_mntvnodes) {
1985 if (VOP_ISLOCKED(vp))
1986 vprint((char *)0, vp);
1987 }
1988 simple_lock(&mountlist_slock);
1982 if (VOP_ISLOCKED(vp))
1983 vprint((char *)0, vp);
1984 }
1985 simple_lock(&mountlist_slock);
1989 nmp = mp->mnt_list.cqe_next;
1986 nmp = CIRCLEQ_NEXT(mp, mnt_list);
1990 vfs_unbusy(mp, p);
1991 }
1992 simple_unlock(&mountlist_slock);
1993}
1994#endif
1995
1996/*
1997 * Top level filesystem related information gathering.

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

2089#define VNODESZ sizeof (struct vnode)
2090
2091 req->lock = 0;
2092 if (!req->oldptr) /* Make an estimate */
2093 return (SYSCTL_OUT(req, 0,
2094 (numvnodes + KINFO_VNODESLOP) * (VPTRSZ + VNODESZ)));
2095
2096 simple_lock(&mountlist_slock);
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);
2097 for (mp = mountlist.cqh_first; mp != (void *)&mountlist; mp = nmp) {
2094 mp = CIRCLEQ_FIRST(&mountlist);
2095 for (; mp != (void *)&mountlist; mp = nmp) {
2098 if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) {
2096 if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) {
2099 nmp = mp->mnt_list.cqe_next;
2097 nmp = CIRCLEQ_NEXT(mp, mnt_list);
2100 continue;
2101 }
2102again:
2103 simple_lock(&mntvnode_slock);
2098 continue;
2099 }
2100again:
2101 simple_lock(&mntvnode_slock);
2104 for (vp = mp->mnt_vnodelist.lh_first;
2102 for (vp = LIST_FIRST(&mp->mnt_vnodelist);
2105 vp != NULL;
2106 vp = nvp) {
2107 /*
2108 * Check that the vp is still associated with
2109 * this filesystem. RACE: could have been
2110 * recycled onto the same filesystem.
2111 */
2112 if (vp->v_mount != mp) {
2113 simple_unlock(&mntvnode_slock);
2114 goto again;
2115 }
2103 vp != NULL;
2104 vp = nvp) {
2105 /*
2106 * Check that the vp is still associated with
2107 * this filesystem. RACE: could have been
2108 * recycled onto the same filesystem.
2109 */
2110 if (vp->v_mount != mp) {
2111 simple_unlock(&mntvnode_slock);
2112 goto again;
2113 }
2116 nvp = vp->v_mntvnodes.le_next;
2114 nvp = LIST_NEXT(vp, v_mntvnodes);
2117 simple_unlock(&mntvnode_slock);
2118 if ((error = SYSCTL_OUT(req, &vp, VPTRSZ)) ||
2119 (error = SYSCTL_OUT(req, vp, VNODESZ)))
2120 return (error);
2121 simple_lock(&mntvnode_slock);
2122 }
2123 simple_unlock(&mntvnode_slock);
2124 simple_lock(&mountlist_slock);
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);
2125 nmp = mp->mnt_list.cqe_next;
2123 nmp = CIRCLEQ_NEXT(mp, mnt_list);
2126 vfs_unbusy(mp, p);
2127 }
2128 simple_unlock(&mountlist_slock);
2129
2130 return (0);
2131}
2132#endif
2133

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

2167
2168 if (curproc != NULL)
2169 p = curproc;
2170 else
2171 p = initproc; /* XXX XXX should this be proc0? */
2172 /*
2173 * Since this only runs when rebooting, it is not interlocked.
2174 */
2124 vfs_unbusy(mp, p);
2125 }
2126 simple_unlock(&mountlist_slock);
2127
2128 return (0);
2129}
2130#endif
2131

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

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 */
2175 for (mp = mountlist.cqh_last; mp != (void *)&mountlist; mp = nmp) {
2176 nmp = mp->mnt_list.cqe_prev;
2173 mp = CIRCLEQ_LAST(&mountlist);
2174 for (; mp != (void *)&mountlist; mp = nmp) {
2175 nmp = CIRCLEQ_PREV(mp, mnt_list);
2177 error = dounmount(mp, MNT_FORCE, p);
2178 if (error) {
2179 printf("unmount of %s failed (",
2180 mp->mnt_stat.f_mntonname);
2181 if (error == EBUSY)
2182 printf("BUSY)\n");
2183 else
2184 printf("%d)\n", error);

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

2447vfs_msync(struct mount *mp, int flags) {
2448 struct vnode *vp, *nvp;
2449 struct vm_object *obj;
2450 int anyio, tries;
2451
2452 tries = 5;
2453loop:
2454 anyio = 0;
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);

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

2446vfs_msync(struct mount *mp, int flags) {
2447 struct vnode *vp, *nvp;
2448 struct vm_object *obj;
2449 int anyio, tries;
2450
2451 tries = 5;
2452loop:
2453 anyio = 0;
2455 for (vp = mp->mnt_vnodelist.lh_first; vp != NULL; vp = nvp) {
2454 for (vp = LIST_FIRST(&mp->mnt_vnodelist); vp != NULL; vp = nvp) {
2456
2455
2457 nvp = vp->v_mntvnodes.le_next;
2456 nvp = LIST_NEXT(vp, v_mntvnodes);
2458
2459 if (vp->v_mount != mp) {
2460 goto loop;
2461 }
2462
2463 if (vp->v_flag & VXLOCK) /* XXX: what if MNT_WAIT? */
2464 continue;
2465

--- 416 unchanged lines hidden ---
2457
2458 if (vp->v_mount != mp) {
2459 goto loop;
2460 }
2461
2462 if (vp->v_flag & VXLOCK) /* XXX: what if MNT_WAIT? */
2463 continue;
2464

--- 416 unchanged lines hidden ---