vfs_subr.c (2210e5d9fa5266a80c6ba106eeff306c7328b4a8) vfs_subr.c (c72ccd014de73fd63ea50101bc509fbd889a7dd5)
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.

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

340 for (vfsp = vfsconf; vfsp; vfsp = vfsp->vfc_next)
341 if (!strcmp(vfsp->vfc_name, fstypename))
342 break;
343 if (vfsp == NULL)
344 return (ENODEV);
345 mp = malloc((u_long)sizeof(struct mount), M_MOUNT, M_WAITOK | M_ZERO);
346 lockinit(&mp->mnt_lock, PVFS, "vfslock", 0, LK_NOPAUSE);
347 (void)vfs_busy(mp, LK_NOWAIT, 0, td);
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.

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

340 for (vfsp = vfsconf; vfsp; vfsp = vfsp->vfc_next)
341 if (!strcmp(vfsp->vfc_name, fstypename))
342 break;
343 if (vfsp == NULL)
344 return (ENODEV);
345 mp = malloc((u_long)sizeof(struct mount), M_MOUNT, M_WAITOK | M_ZERO);
346 lockinit(&mp->mnt_lock, PVFS, "vfslock", 0, LK_NOPAUSE);
347 (void)vfs_busy(mp, LK_NOWAIT, 0, td);
348 LIST_INIT(&mp->mnt_vnodelist);
348 TAILQ_INIT(&mp->mnt_nvnodelist);
349 mp->mnt_vfc = vfsp;
350 mp->mnt_op = vfsp->vfc_vfsops;
351 mp->mnt_flag = MNT_RDONLY;
352 mp->mnt_vnodecovered = NULLVP;
353 vfsp->vfc_refcount++;
354 mp->mnt_iosize_max = DFLTPHYS;
355 mp->mnt_stat.f_type = vfsp->vfc_typenum;
356 mp->mnt_flag |= vfsp->vfc_flags & MNT_VISFLAGMASK;

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

695 register struct mount *mp;
696{
697
698 mtx_lock(&mntvnode_mtx);
699 /*
700 * Delete from old mount point vnode list, if on one.
701 */
702 if (vp->v_mount != NULL)
349 mp->mnt_vfc = vfsp;
350 mp->mnt_op = vfsp->vfc_vfsops;
351 mp->mnt_flag = MNT_RDONLY;
352 mp->mnt_vnodecovered = NULLVP;
353 vfsp->vfc_refcount++;
354 mp->mnt_iosize_max = DFLTPHYS;
355 mp->mnt_stat.f_type = vfsp->vfc_typenum;
356 mp->mnt_flag |= vfsp->vfc_flags & MNT_VISFLAGMASK;

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

695 register struct mount *mp;
696{
697
698 mtx_lock(&mntvnode_mtx);
699 /*
700 * Delete from old mount point vnode list, if on one.
701 */
702 if (vp->v_mount != NULL)
703 LIST_REMOVE(vp, v_mntvnodes);
703 TAILQ_REMOVE(&vp->v_mount->mnt_nvnodelist, vp, v_nmntvnodes);
704 /*
705 * Insert into list of vnodes for the new mount point, if available.
706 */
707 if ((vp->v_mount = mp) == NULL) {
708 mtx_unlock(&mntvnode_mtx);
709 return;
710 }
704 /*
705 * Insert into list of vnodes for the new mount point, if available.
706 */
707 if ((vp->v_mount = mp) == NULL) {
708 mtx_unlock(&mntvnode_mtx);
709 return;
710 }
711 LIST_INSERT_HEAD(&mp->mnt_vnodelist, vp, v_mntvnodes);
711 TAILQ_INSERT_TAIL(&mp->mnt_nvnodelist, vp, v_nmntvnodes);
712 mtx_unlock(&mntvnode_mtx);
713}
714
715/*
716 * Update outstanding I/O count and do wakeup if requested.
717 */
718void
719vwakeup(bp)

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

1718 * immediately, since with rootrefs > 0, it won't go away.
1719 */
1720 if ((error = VFS_ROOT(mp, &rootvp)) != 0)
1721 return (error);
1722 vput(rootvp);
1723 }
1724 mtx_lock(&mntvnode_mtx);
1725loop:
712 mtx_unlock(&mntvnode_mtx);
713}
714
715/*
716 * Update outstanding I/O count and do wakeup if requested.
717 */
718void
719vwakeup(bp)

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

1718 * immediately, since with rootrefs > 0, it won't go away.
1719 */
1720 if ((error = VFS_ROOT(mp, &rootvp)) != 0)
1721 return (error);
1722 vput(rootvp);
1723 }
1724 mtx_lock(&mntvnode_mtx);
1725loop:
1726 for (vp = LIST_FIRST(&mp->mnt_vnodelist); vp; vp = nvp) {
1726 for (vp = TAILQ_FIRST(&mp->mnt_nvnodelist); vp; vp = nvp) {
1727 /*
1728 * Make sure this vnode wasn't reclaimed in getnewvnode().
1729 * Start over if it has (it won't be on the list anymore).
1730 */
1731 if (vp->v_mount != mp)
1732 goto loop;
1727 /*
1728 * Make sure this vnode wasn't reclaimed in getnewvnode().
1729 * Start over if it has (it won't be on the list anymore).
1730 */
1731 if (vp->v_mount != mp)
1732 goto loop;
1733 nvp = LIST_NEXT(vp, v_mntvnodes);
1733 nvp = TAILQ_NEXT(vp, v_nmntvnodes);
1734
1735 mtx_unlock(&mntvnode_mtx);
1736 mtx_lock(&vp->v_interlock);
1737 /*
1738 * Skip over a vnodes marked VSYSTEM.
1739 */
1740 if ((flags & SKIPSYSTEM) && (vp->v_flag & VSYSTEM)) {
1741 mtx_unlock(&vp->v_interlock);

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

2186 printf("Locked vnodes\n");
2187 mtx_lock(&mountlist_mtx);
2188 for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) {
2189 if (vfs_busy(mp, LK_NOWAIT, &mountlist_mtx, td)) {
2190 nmp = TAILQ_NEXT(mp, mnt_list);
2191 continue;
2192 }
2193 mtx_lock(&mntvnode_mtx);
1734
1735 mtx_unlock(&mntvnode_mtx);
1736 mtx_lock(&vp->v_interlock);
1737 /*
1738 * Skip over a vnodes marked VSYSTEM.
1739 */
1740 if ((flags & SKIPSYSTEM) && (vp->v_flag & VSYSTEM)) {
1741 mtx_unlock(&vp->v_interlock);

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

2186 printf("Locked vnodes\n");
2187 mtx_lock(&mountlist_mtx);
2188 for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) {
2189 if (vfs_busy(mp, LK_NOWAIT, &mountlist_mtx, td)) {
2190 nmp = TAILQ_NEXT(mp, mnt_list);
2191 continue;
2192 }
2193 mtx_lock(&mntvnode_mtx);
2194 LIST_FOREACH(vp, &mp->mnt_vnodelist, v_mntvnodes) {
2194 TAILQ_FOREACH(vp, &mp->mnt_nvnodelist, v_nmntvnodes) {
2195 if (VOP_ISLOCKED(vp, NULL))
2196 vprint((char *)0, vp);
2197 }
2198 mtx_unlock(&mntvnode_mtx);
2199 mtx_lock(&mountlist_mtx);
2200 nmp = TAILQ_NEXT(mp, mnt_list);
2201 vfs_unbusy(mp, td);
2202 }

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

2308 mtx_lock(&mountlist_mtx);
2309 for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) {
2310 if (vfs_busy(mp, LK_NOWAIT, &mountlist_mtx, td)) {
2311 nmp = TAILQ_NEXT(mp, mnt_list);
2312 continue;
2313 }
2314 mtx_lock(&mntvnode_mtx);
2315again:
2195 if (VOP_ISLOCKED(vp, NULL))
2196 vprint((char *)0, vp);
2197 }
2198 mtx_unlock(&mntvnode_mtx);
2199 mtx_lock(&mountlist_mtx);
2200 nmp = TAILQ_NEXT(mp, mnt_list);
2201 vfs_unbusy(mp, td);
2202 }

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

2308 mtx_lock(&mountlist_mtx);
2309 for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) {
2310 if (vfs_busy(mp, LK_NOWAIT, &mountlist_mtx, td)) {
2311 nmp = TAILQ_NEXT(mp, mnt_list);
2312 continue;
2313 }
2314 mtx_lock(&mntvnode_mtx);
2315again:
2316 for (vp = LIST_FIRST(&mp->mnt_vnodelist);
2316 for (vp = TAILQ_FIRST(&mp->mnt_nvnodelist);
2317 vp != NULL;
2318 vp = nvp) {
2319 /*
2320 * Check that the vp is still associated with
2321 * this filesystem. RACE: could have been
2322 * recycled onto the same filesystem.
2323 */
2324 if (vp->v_mount != mp)
2325 goto again;
2317 vp != NULL;
2318 vp = nvp) {
2319 /*
2320 * Check that the vp is still associated with
2321 * this filesystem. RACE: could have been
2322 * recycled onto the same filesystem.
2323 */
2324 if (vp->v_mount != mp)
2325 goto again;
2326 nvp = LIST_NEXT(vp, v_mntvnodes);
2326 nvp = TAILQ_NEXT(vp, v_nmntvnodes);
2327 mtx_unlock(&mntvnode_mtx);
2328 if ((error = SYSCTL_OUT(req, &vp, VPTRSZ)) ||
2329 (error = SYSCTL_OUT(req, vp, VNODESZ)))
2330 return (error);
2331 mtx_lock(&mntvnode_mtx);
2332 }
2333 mtx_unlock(&mntvnode_mtx);
2334 mtx_lock(&mountlist_mtx);

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

2397 }
2398}
2399
2400/*
2401 * perform msync on all vnodes under a mount point
2402 * the mount point must be locked.
2403 */
2404void
2327 mtx_unlock(&mntvnode_mtx);
2328 if ((error = SYSCTL_OUT(req, &vp, VPTRSZ)) ||
2329 (error = SYSCTL_OUT(req, vp, VNODESZ)))
2330 return (error);
2331 mtx_lock(&mntvnode_mtx);
2332 }
2333 mtx_unlock(&mntvnode_mtx);
2334 mtx_lock(&mountlist_mtx);

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

2397 }
2398}
2399
2400/*
2401 * perform msync on all vnodes under a mount point
2402 * the mount point must be locked.
2403 */
2404void
2405vfs_msync(struct mount *mp, int flags) {
2405vfs_msync(struct mount *mp, int flags)
2406{
2406 struct vnode *vp, *nvp;
2407 struct vm_object *obj;
2408 int anyio, tries;
2409
2410 GIANT_REQUIRED;
2411
2412 tries = 5;
2413loop:
2414 anyio = 0;
2415 mtx_lock(&mntvnode_mtx);
2407 struct vnode *vp, *nvp;
2408 struct vm_object *obj;
2409 int anyio, tries;
2410
2411 GIANT_REQUIRED;
2412
2413 tries = 5;
2414loop:
2415 anyio = 0;
2416 mtx_lock(&mntvnode_mtx);
2416 for (vp = LIST_FIRST(&mp->mnt_vnodelist); vp != NULL; vp = nvp) {
2417 for (vp = TAILQ_FIRST(&mp->mnt_nvnodelist); vp != NULL; vp = nvp) {
2417
2418
2418 nvp = LIST_NEXT(vp, v_mntvnodes);
2419 nvp = TAILQ_NEXT(vp, v_nmntvnodes);
2419
2420 if (vp->v_mount != mp) {
2421 mtx_unlock(&mntvnode_mtx);
2422 goto loop;
2423 }
2424
2425 if (vp->v_flag & VXLOCK) /* XXX: what if MNT_WAIT? */
2426 continue;

--- 566 unchanged lines hidden ---
2420
2421 if (vp->v_mount != mp) {
2422 mtx_unlock(&mntvnode_mtx);
2423 goto loop;
2424 }
2425
2426 if (vp->v_flag & VXLOCK) /* XXX: what if MNT_WAIT? */
2427 continue;

--- 566 unchanged lines hidden ---