vfs_subr.c (92723) | vfs_subr.c (92751) |
---|---|
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_subr.c 92723 2002-03-19 21:25:46Z alfred $ | 39 * $FreeBSD: head/sys/kern/vfs_subr.c 92751 2002-03-20 04:09:59Z jeff $ |
40 */ 41 42/* 43 * External virtual filesystem routines 44 */ 45#include "opt_ddb.h" 46#include "opt_ffs.h" 47 --- 16 unchanged lines hidden (view full) --- 64#include <sys/vnode.h> 65 66#include <vm/vm.h> 67#include <vm/vm_object.h> 68#include <vm/vm_extern.h> 69#include <vm/pmap.h> 70#include <vm/vm_map.h> 71#include <vm/vm_page.h> | 40 */ 41 42/* 43 * External virtual filesystem routines 44 */ 45#include "opt_ddb.h" 46#include "opt_ffs.h" 47 --- 16 unchanged lines hidden (view full) --- 64#include <sys/vnode.h> 65 66#include <vm/vm.h> 67#include <vm/vm_object.h> 68#include <vm/vm_extern.h> 69#include <vm/pmap.h> 70#include <vm/vm_map.h> 71#include <vm/vm_page.h> |
72#include <vm/vm_zone.h> | 72#include <vm/uma.h> |
73 74static MALLOC_DEFINE(M_NETADDR, "Export Host", "Export host address structure"); 75 76static void addalias(struct vnode *vp, dev_t nvp_rdev); 77static void insmntque(struct vnode *vp, struct mount *mp); 78static void vclean(struct vnode *vp, int flags, struct thread *td); 79static void vlruvp(struct vnode *vp); 80 --- 102 unchanged lines hidden (view full) --- 183 * v_specnext) 184 */ 185static struct mtx spechash_mtx; 186 187/* Publicly exported FS */ 188struct nfs_public nfs_pub; 189 190/* Zone for allocation of new vnodes - used exclusively by getnewvnode() */ | 73 74static MALLOC_DEFINE(M_NETADDR, "Export Host", "Export host address structure"); 75 76static void addalias(struct vnode *vp, dev_t nvp_rdev); 77static void insmntque(struct vnode *vp, struct mount *mp); 78static void vclean(struct vnode *vp, int flags, struct thread *td); 79static void vlruvp(struct vnode *vp); 80 --- 102 unchanged lines hidden (view full) --- 183 * v_specnext) 184 */ 185static struct mtx spechash_mtx; 186 187/* Publicly exported FS */ 188struct nfs_public nfs_pub; 189 190/* Zone for allocation of new vnodes - used exclusively by getnewvnode() */ |
191static vm_zone_t vnode_zone; 192static vm_zone_t vnodepoll_zone; | 191static uma_zone_t vnode_zone; 192static uma_zone_t vnodepoll_zone; |
193 194/* Set to 1 to print out reclaim of active vnodes */ 195int prtactive; 196 197/* 198 * The workitem queue. 199 * 200 * It is useful to delay writes of file data and filesystem metadata --- 51 unchanged lines hidden (view full) --- 252 &minvnodes, 0, "Minimum number of vnodes"); 253static int vnlru_nowhere; 254SYSCTL_INT(_debug, OID_AUTO, vnlru_nowhere, CTLFLAG_RW, &vnlru_nowhere, 0, 255 "Number of times the vnlru process ran without success"); 256 257void 258v_addpollinfo(struct vnode *vp) 259{ | 193 194/* Set to 1 to print out reclaim of active vnodes */ 195int prtactive; 196 197/* 198 * The workitem queue. 199 * 200 * It is useful to delay writes of file data and filesystem metadata --- 51 unchanged lines hidden (view full) --- 252 &minvnodes, 0, "Minimum number of vnodes"); 253static int vnlru_nowhere; 254SYSCTL_INT(_debug, OID_AUTO, vnlru_nowhere, CTLFLAG_RW, &vnlru_nowhere, 0, 255 "Number of times the vnlru process ran without success"); 256 257void 258v_addpollinfo(struct vnode *vp) 259{ |
260 vp->v_pollinfo = zalloc(vnodepoll_zone); | 260 vp->v_pollinfo = uma_zalloc(vnodepoll_zone, M_WAITOK); |
261 mtx_init(&vp->v_pollinfo->vpi_lock, "vnode pollinfo", MTX_DEF); 262} 263 264/* 265 * Initialize the vnode management data structures. 266 */ 267static void 268vntblinit(void *dummy __unused) 269{ 270 271 desiredvnodes = maxproc + cnt.v_page_count / 4; 272 minvnodes = desiredvnodes / 4; 273 mtx_init(&mountlist_mtx, "mountlist", MTX_DEF); 274 mtx_init(&mntvnode_mtx, "mntvnode", MTX_DEF); 275 mtx_init(&mntid_mtx, "mntid", MTX_DEF); 276 mtx_init(&spechash_mtx, "spechash", MTX_DEF); 277 TAILQ_INIT(&vnode_free_list); 278 mtx_init(&vnode_free_list_mtx, "vnode_free_list", MTX_DEF); | 261 mtx_init(&vp->v_pollinfo->vpi_lock, "vnode pollinfo", MTX_DEF); 262} 263 264/* 265 * Initialize the vnode management data structures. 266 */ 267static void 268vntblinit(void *dummy __unused) 269{ 270 271 desiredvnodes = maxproc + cnt.v_page_count / 4; 272 minvnodes = desiredvnodes / 4; 273 mtx_init(&mountlist_mtx, "mountlist", MTX_DEF); 274 mtx_init(&mntvnode_mtx, "mntvnode", MTX_DEF); 275 mtx_init(&mntid_mtx, "mntid", MTX_DEF); 276 mtx_init(&spechash_mtx, "spechash", MTX_DEF); 277 TAILQ_INIT(&vnode_free_list); 278 mtx_init(&vnode_free_list_mtx, "vnode_free_list", MTX_DEF); |
279 vnode_zone = zinit("VNODE", sizeof (struct vnode), 0, 0, 5); 280 vnodepoll_zone = zinit("VNODEPOLL", sizeof (struct vpollinfo), 0, 0, 5); | 279 vnode_zone = uma_zcreate("VNODE", sizeof (struct vnode), NULL, NULL, 280 NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE); 281 vnodepoll_zone = uma_zcreate("VNODEPOLL", sizeof (struct vpollinfo), 282 NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE); |
281 /* 282 * Initialize the filesystem syncer. 283 */ 284 syncer_workitem_pending = hashinit(syncer_maxdelay, M_VNODE, 285 &syncer_mask); 286 syncer_maxdelay = syncer_mask + 1; 287} 288SYSINIT(vfs, SI_SUB_VFS, SI_ORDER_FIRST, vntblinit, NULL) --- 502 unchanged lines hidden (view full) --- 791 panic("Clean vnode has pending I/O's"); 792 splx(s); 793 if (vp->v_writecount != 0) 794 panic("Non-zero write count"); 795 } 796#endif 797 if (vp->v_pollinfo) { 798 mtx_destroy(&vp->v_pollinfo->vpi_lock); | 283 /* 284 * Initialize the filesystem syncer. 285 */ 286 syncer_workitem_pending = hashinit(syncer_maxdelay, M_VNODE, 287 &syncer_mask); 288 syncer_maxdelay = syncer_mask + 1; 289} 290SYSINIT(vfs, SI_SUB_VFS, SI_ORDER_FIRST, vntblinit, NULL) --- 502 unchanged lines hidden (view full) --- 793 panic("Clean vnode has pending I/O's"); 794 splx(s); 795 if (vp->v_writecount != 0) 796 panic("Non-zero write count"); 797 } 798#endif 799 if (vp->v_pollinfo) { 800 mtx_destroy(&vp->v_pollinfo->vpi_lock); |
799 zfree(vnodepoll_zone, vp->v_pollinfo); | 801 uma_zfree(vnodepoll_zone, vp->v_pollinfo); |
800 } 801 vp->v_pollinfo = NULL; 802 vp->v_flag = 0; 803 vp->v_lastw = 0; 804 vp->v_lasta = 0; 805 vp->v_cstart = 0; 806 vp->v_clen = 0; 807 vp->v_socket = 0; 808 } else { 809 mtx_unlock(&vnode_free_list_mtx); | 802 } 803 vp->v_pollinfo = NULL; 804 vp->v_flag = 0; 805 vp->v_lastw = 0; 806 vp->v_lasta = 0; 807 vp->v_cstart = 0; 808 vp->v_clen = 0; 809 vp->v_socket = 0; 810 } else { 811 mtx_unlock(&vnode_free_list_mtx); |
810 vp = (struct vnode *) zalloc(vnode_zone); | 812 vp = (struct vnode *) uma_zalloc(vnode_zone, M_WAITOK); |
811 bzero((char *) vp, sizeof *vp); 812 mtx_init(&vp->v_interlock, "vnode interlock", MTX_DEF); 813 vp->v_dd = vp; 814 cache_purge(vp); 815 LIST_INIT(&vp->v_cache_src); 816 TAILQ_INIT(&vp->v_cache_dst); 817 numvnodes++; 818 } --- 2213 unchanged lines hidden (view full) --- 3032 */ 3033void 3034NDFREE(ndp, flags) 3035 struct nameidata *ndp; 3036 const uint flags; 3037{ 3038 if (!(flags & NDF_NO_FREE_PNBUF) && 3039 (ndp->ni_cnd.cn_flags & HASBUF)) { | 813 bzero((char *) vp, sizeof *vp); 814 mtx_init(&vp->v_interlock, "vnode interlock", MTX_DEF); 815 vp->v_dd = vp; 816 cache_purge(vp); 817 LIST_INIT(&vp->v_cache_src); 818 TAILQ_INIT(&vp->v_cache_dst); 819 numvnodes++; 820 } --- 2213 unchanged lines hidden (view full) --- 3034 */ 3035void 3036NDFREE(ndp, flags) 3037 struct nameidata *ndp; 3038 const uint flags; 3039{ 3040 if (!(flags & NDF_NO_FREE_PNBUF) && 3041 (ndp->ni_cnd.cn_flags & HASBUF)) { |
3040 zfree(namei_zone, ndp->ni_cnd.cn_pnbuf); | 3042 uma_zfree(namei_zone, ndp->ni_cnd.cn_pnbuf); |
3041 ndp->ni_cnd.cn_flags &= ~HASBUF; 3042 } 3043 if (!(flags & NDF_NO_DVP_UNLOCK) && 3044 (ndp->ni_cnd.cn_flags & LOCKPARENT) && 3045 ndp->ni_dvp != ndp->ni_vp) 3046 VOP_UNLOCK(ndp->ni_dvp, 0, ndp->ni_cnd.cn_thread); 3047 if (!(flags & NDF_NO_DVP_RELE) && 3048 (ndp->ni_cnd.cn_flags & (LOCKPARENT|WANTPARENT))) { --- 146 unchanged lines hidden --- | 3043 ndp->ni_cnd.cn_flags &= ~HASBUF; 3044 } 3045 if (!(flags & NDF_NO_DVP_UNLOCK) && 3046 (ndp->ni_cnd.cn_flags & LOCKPARENT) && 3047 ndp->ni_dvp != ndp->ni_vp) 3048 VOP_UNLOCK(ndp->ni_dvp, 0, ndp->ni_cnd.cn_thread); 3049 if (!(flags & NDF_NO_DVP_RELE) && 3050 (ndp->ni_cnd.cn_flags & (LOCKPARENT|WANTPARENT))) { --- 146 unchanged lines hidden --- |