Deleted Added
full compact
vfs_subr.c (130585) vfs_subr.c (130640)
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.

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

34 * @(#)vfs_subr.c 8.31 (Berkeley) 5/26/95
35 */
36
37/*
38 * External virtual filesystem routines
39 */
40
41#include <sys/cdefs.h>
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.

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

34 * @(#)vfs_subr.c 8.31 (Berkeley) 5/26/95
35 */
36
37/*
38 * External virtual filesystem routines
39 */
40
41#include <sys/cdefs.h>
42__FBSDID("$FreeBSD: head/sys/kern/vfs_subr.c 130585 2004-06-16 09:47:26Z phk $");
42__FBSDID("$FreeBSD: head/sys/kern/vfs_subr.c 130640 2004-06-17 17:16:53Z phk $");
43
44#include "opt_ddb.h"
45#include "opt_mac.h"
46
47#include <sys/param.h>
48#include <sys/systm.h>
49#include <sys/bio.h>
50#include <sys/buf.h>

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

362 fsid_t tfsid;
363 int mtype;
364
365 mtx_lock(&mntid_mtx);
366 mtype = mp->mnt_vfc->vfc_typenum;
367 tfsid.val[1] = mtype;
368 mtype = (mtype & 0xFF) << 24;
369 for (;;) {
43
44#include "opt_ddb.h"
45#include "opt_mac.h"
46
47#include <sys/param.h>
48#include <sys/systm.h>
49#include <sys/bio.h>
50#include <sys/buf.h>

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

362 fsid_t tfsid;
363 int mtype;
364
365 mtx_lock(&mntid_mtx);
366 mtype = mp->mnt_vfc->vfc_typenum;
367 tfsid.val[1] = mtype;
368 mtype = (mtype & 0xFF) << 24;
369 for (;;) {
370 tfsid.val[0] = makeudev(255,
370 tfsid.val[0] = makedev(255,
371 mtype | ((mntid_base & 0xFF00) << 8) | (mntid_base & 0xFF));
372 mntid_base++;
373 if (vfs_getvfs(&tfsid) == NULL)
374 break;
375 }
376 mp->mnt_stat.f_fsid.val[0] = tfsid.val[0];
377 mp->mnt_stat.f_fsid.val[1] = tfsid.val[1];
378 mtx_unlock(&mntid_mtx);

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

1739bdevvp(dev, vpp)
1740 struct cdev *dev;
1741 struct vnode **vpp;
1742{
1743 register struct vnode *vp;
1744 struct vnode *nvp;
1745 int error;
1746
371 mtype | ((mntid_base & 0xFF00) << 8) | (mntid_base & 0xFF));
372 mntid_base++;
373 if (vfs_getvfs(&tfsid) == NULL)
374 break;
375 }
376 mp->mnt_stat.f_fsid.val[0] = tfsid.val[0];
377 mp->mnt_stat.f_fsid.val[1] = tfsid.val[1];
378 mtx_unlock(&mntid_mtx);

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

1739bdevvp(dev, vpp)
1740 struct cdev *dev;
1741 struct vnode **vpp;
1742{
1743 register struct vnode *vp;
1744 struct vnode *nvp;
1745 int error;
1746
1747 if (dev == NODEV) {
1747 if (dev == NULL) {
1748 *vpp = NULLVP;
1749 return (ENXIO);
1750 }
1751 if (vfinddev(dev, vpp))
1752 return (0);
1753
1754 error = getnewvnode("none", (struct mount *)0, spec_vnodeop_p, &nvp);
1755 if (error) {

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

1781 * The reason for this gunk is that multiple vnodes can reference
1782 * the same physical device, so checking vp->v_usecount to see
1783 * how many users there are is inadequate; the v_usecount for
1784 * the vnodes need to be accumulated. vcount() does that.
1785 */
1786struct vnode *
1787addaliasu(nvp, nvp_rdev)
1788 struct vnode *nvp;
1748 *vpp = NULLVP;
1749 return (ENXIO);
1750 }
1751 if (vfinddev(dev, vpp))
1752 return (0);
1753
1754 error = getnewvnode("none", (struct mount *)0, spec_vnodeop_p, &nvp);
1755 if (error) {

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

1781 * The reason for this gunk is that multiple vnodes can reference
1782 * the same physical device, so checking vp->v_usecount to see
1783 * how many users there are is inadequate; the v_usecount for
1784 * the vnodes need to be accumulated. vcount() does that.
1785 */
1786struct vnode *
1787addaliasu(nvp, nvp_rdev)
1788 struct vnode *nvp;
1789 udev_t nvp_rdev;
1789 dev_t nvp_rdev;
1790{
1791 struct vnode *ovp;
1792 vop_t **ops;
1793 struct cdev *dev;
1794
1795 if (nvp->v_type == VBLK)
1796 return (nvp);
1797 if (nvp->v_type != VCHR)
1798 panic("addaliasu on non-special vnode");
1790{
1791 struct vnode *ovp;
1792 vop_t **ops;
1793 struct cdev *dev;
1794
1795 if (nvp->v_type == VBLK)
1796 return (nvp);
1797 if (nvp->v_type != VCHR)
1798 panic("addaliasu on non-special vnode");
1799 dev = udev2dev(nvp_rdev);
1800 if (dev == NODEV)
1799 dev = findcdev(nvp_rdev);
1800 if (dev == NULL)
1801 return (nvp);
1802 /*
1803 * Check to see if we have a bdevvp vnode with no associated
1804 * filesystem. If so, we want to associate the filesystem of
1805 * the new newly instigated vnode with the bdevvp vnode and
1806 * discard the newly created vnode rather than leaving the
1807 * bdevvp vnode lying around with no associated filesystem.
1808 */

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

1831 nvp->v_op = ops;
1832 insmntque(ovp, nvp->v_mount);
1833 vrele(nvp);
1834 vgone(nvp);
1835 return (ovp);
1836}
1837
1838/* This is a local helper function that do the same as addaliasu, but for a
1801 return (nvp);
1802 /*
1803 * Check to see if we have a bdevvp vnode with no associated
1804 * filesystem. If so, we want to associate the filesystem of
1805 * the new newly instigated vnode with the bdevvp vnode and
1806 * discard the newly created vnode rather than leaving the
1807 * bdevvp vnode lying around with no associated filesystem.
1808 */

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

1831 nvp->v_op = ops;
1832 insmntque(ovp, nvp->v_mount);
1833 vrele(nvp);
1834 vgone(nvp);
1835 return (ovp);
1836}
1837
1838/* This is a local helper function that do the same as addaliasu, but for a
1839 * struct cdev *instead of an udev_t. */
1839 * struct cdev *instead of an dev_t. */
1840static void
1841addalias(nvp, dev)
1842 struct vnode *nvp;
1843 struct cdev *dev;
1844{
1845
1846 KASSERT(nvp->v_type == VCHR, ("addalias on non-special vnode"));
1847 dev_ref(dev);

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

2576 vclean(vp, DOCLOSE, td);
2577 VI_UNLOCK(vp);
2578
2579 /*
2580 * If special device, remove it from special device alias list
2581 * if it is on one.
2582 */
2583 VI_LOCK(vp);
1840static void
1841addalias(nvp, dev)
1842 struct vnode *nvp;
1843 struct cdev *dev;
1844{
1845
1846 KASSERT(nvp->v_type == VCHR, ("addalias on non-special vnode"));
1847 dev_ref(dev);

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

2576 vclean(vp, DOCLOSE, td);
2577 VI_UNLOCK(vp);
2578
2579 /*
2580 * If special device, remove it from special device alias list
2581 * if it is on one.
2582 */
2583 VI_LOCK(vp);
2584 if (vp->v_type == VCHR && vp->v_rdev != NODEV) {
2584 if (vp->v_type == VCHR && vp->v_rdev != NULL) {
2585 mtx_lock(&spechash_mtx);
2586 SLIST_REMOVE(&vp->v_rdev->si_hlist, vp, vnode, v_specnext);
2587 vp->v_rdev->si_usecount -= vp->v_usecount;
2588 mtx_unlock(&spechash_mtx);
2589 dev_rel(vp->v_rdev);
2590 vp->v_rdev = NULL;
2591 }
2592

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

3402 * extract the struct cdev *from a VCHR
3403 */
3404struct cdev *
3405vn_todev(vp)
3406 struct vnode *vp;
3407{
3408
3409 if (vp->v_type != VCHR)
2585 mtx_lock(&spechash_mtx);
2586 SLIST_REMOVE(&vp->v_rdev->si_hlist, vp, vnode, v_specnext);
2587 vp->v_rdev->si_usecount -= vp->v_usecount;
2588 mtx_unlock(&spechash_mtx);
2589 dev_rel(vp->v_rdev);
2590 vp->v_rdev = NULL;
2591 }
2592

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

3402 * extract the struct cdev *from a VCHR
3403 */
3404struct cdev *
3405vn_todev(vp)
3406 struct vnode *vp;
3407{
3408
3409 if (vp->v_type != VCHR)
3410 return (NODEV);
3410 return (NULL);
3411 return (vp->v_rdev);
3412}
3413
3414/*
3415 * Check if vnode represents a disk device
3416 */
3417int
3418vn_isdisk(vp, errp)

--- 430 unchanged lines hidden ---
3411 return (vp->v_rdev);
3412}
3413
3414/*
3415 * Check if vnode represents a disk device
3416 */
3417int
3418vn_isdisk(vp, errp)

--- 430 unchanged lines hidden ---