Annotation of XNU/bsd/kern/mapfs.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
                      3:  *
                      4:  * @APPLE_LICENSE_HEADER_START@
                      5:  * 
                      6:  * The contents of this file constitute Original Code as defined in and
                      7:  * are subject to the Apple Public Source License Version 1.1 (the
                      8:  * "License").  You may not use this file except in compliance with the
                      9:  * License.  Please obtain a copy of the License at
                     10:  * http://www.apple.com/publicsource and read it before using this file.
                     11:  * 
                     12:  * This Original Code and all software distributed under the License are
                     13:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
                     14:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
                     15:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
                     16:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
                     17:  * License for the specific language governing rights and limitations
                     18:  * under the License.
                     19:  * 
                     20:  * @APPLE_LICENSE_HEADER_END@
                     21:  */
                     22: /* 
                     23:  * Mach Operating System
                     24:  * Copyright (c) 1987 Carnegie-Mellon University
                     25:  * All rights reserved.  The CMU software License Agreement specifies
                     26:  * the terms and conditions for use and redistribution.
                     27:  */
                     28: /*
                     29:  *     File:   mapfs.c
                     30:  *     Author: Avadis Tevanian, Jr.
                     31:  *
                     32:  *     Copyright (C) 1987, Avadis Tevanian, Jr.
                     33:  *
                     34:  *     Support for mapped file system implementation.
                     35:  *
                     36:  * HISTORY
                     37:  * 6-Dev-1997 A.Ramesh at Apple
                     38:  *     Made the chages for MacOSX; Reanamed mfs to mapfs to avoid confusion
                     39:  *     with memory based filesystem.
                     40:  *
                     41:  * 18-Nov-92 Phillip Dibner at NeXT
                     42:  *     Made the i/o throttle global.   This is a hack on top of a hack and 
                     43:  *     should be fixed properly, probably in the vm system.
                     44:  *
                     45:  *  3-Sep-92 Joe Murdock at NeXT
                     46:  *     Added an i/o throttle to mfs_io as a cheap work-around for a i/o buffer
                     47:  *     resource conflict with usr-space system bottle-necks (nfs servers, etc)
                     48:  *
                     49:  *  7-Feb-92 Jim Hays
                     50:  *     There are still bugs in this code dealing with vmp_pushing wired 
                     51:  *     pages. We need to modify the sound drivers locks to be breakable
                     52:  *     except during the actual playing. 
                     53:  *
                     54:  *  3-Aug-90  Doug Mitchell at NeXT
                     55:  *     Added primitives for loadable file system support.
                     56:  *
                     57:  *  7-Mar-90  Brian Pinkerton (bpinker) at NeXT
                     58:  *     Changed mfs_trunc to return an indication of change.
                     59:  *
                     60:  *  9-Mar-88  John Seamons (jks) at NeXT
                     61:  *     SUN_VFS: allocate vm_info structures from a zone.
                     62:  *
                     63:  * 29-Jan-88  David Golub (dbg) at Carnegie-Mellon University
                     64:  *     Corrected calls to inode_pager_setup and kmem_alloc.
                     65:  *
                     66:  * 15-Sep-87  Michael Young (mwyoung) at Carnegie-Mellon University
                     67:  *     De-linted.
                     68:  *
                     69:  * 18-Jun-87  Michael Young (mwyoung) at Carnegie-Mellon University
                     70:  *     Make most of this file dependent on MACH_NBC.
                     71:  *
                     72:  * 30-Apr-87  Avadis Tevanian (avie) at Carnegie-Mellon University
                     73:  *     Created.
                     74:  */
                     75: 
                     76: 
                     77: #include <kern/mapfs.h>
                     78: #include <sys/param.h>
                     79: #include <sys/systm.h>
                     80: #include <sys/mount.h>
                     81: #include <sys/proc.h>
                     82: #include <sys/user.h>
                     83: #include <sys/vnode.h>
                     84: #include <sys/uio.h>
                     85: #include <ufs/ufs/quota.h>
                     86: #include <ufs/ufs/inode.h>
                     87: #include <sys/dir.h>
                     88: #include <vm/vm_kern.h>
                     89: #include <mach/vm_param.h>
                     90: #include <mach/machine.h>
                     91: #include <vm/vnode_pager.h>
                     92: #include <sys/lock.h>
                     93: 
                     94: struct zone    *vm_info_zone;
                     95: 
                     96: /*
                     97:  *     Private variables and macros.
                     98:  */
                     99: 
                    100: queue_head_t           vm_info_queue;          /* lru list of structures */
                    101: decl_simple_lock_data(,        vm_info_lock_data)      /* lock for lru list */
                    102: int                    vm_info_version = 0;    /* version number */
                    103: 
                    104: #define        vm_info_lock()          simple_lock(&vm_info_lock_data)
                    105: #define        vm_info_unlock()        simple_unlock(&vm_info_lock_data)
                    106: 
                    107: 
                    108: 
                    109: 
                    110: /*
                    111:  *     mapfs_init:
                    112:  *
                    113:  *     Initialize the mapped FS module.
                    114:  */
                    115: int
                    116: mapfs_init()
                    117: {
                    118:        int                     i;
                    119: 
                    120:        queue_init(&vm_info_queue);
                    121:        simple_lock_init(&vm_info_lock_data);
                    122: 
                    123:        i = (vm_size_t) sizeof (struct vm_info);
                    124:        vm_info_zone = zinit (i, 10000*i, 8192, "vm_info zone");
                    125:        return(0);
                    126: }
                    127: 
                    128: /*
                    129:  *     vm_info_init:
                    130:  *
                    131:  *     Initialize a vm_info structure for a vnode.
                    132:  */
                    133: int
                    134: vm_info_init(vp)
                    135:        struct vnode *vp;
                    136: {
                    137:        register struct vm_info *vmp;
                    138: 
                    139:        vmp = vp->v_vm_info;
                    140:        if (vmp == VM_INFO_NULL)
                    141:                vmp = (struct vm_info *) zalloc(vm_info_zone);
                    142:        vmp->pager = 0;
                    143:        vmp->map_count = 0;
                    144:        vmp->use_count = 0;
                    145:        vmp->va = 0;
                    146:        vmp->size = 0;
                    147:        vmp->offset = 0;
                    148:        vmp->cred = (struct ucred *) NULL;
                    149:        vmp->error = 0;
                    150:        vmp->queued = FALSE;
                    151:        vmp->dirty = FALSE;
                    152:        vmp->close_flush = TRUE;        /* for safety, reconsider later */
                    153:        vmp->mapped = FALSE;
                    154:        vmp->invalidate = FALSE;
                    155:        vmp->vnode_size = 0;
                    156: #if FIXME
                    157:        lock_init(&vmp->lock, TRUE);    /* sleep lock */
                    158: #endif /* FIXME */
                    159:        vmp->object = VM_OBJECT_NULL;
                    160:        vp->v_vm_info = vmp;
                    161:        return(0);
                    162: }
                    163: 
                    164: /*
                    165:  * Loadable file system support to avoid exporting struct vm_info.
                    166:  */
                    167: void vm_info_free(struct vnode *vp)
                    168: {
                    169:        zfree(vm_info_zone, (vm_offset_t)vp->v_vm_info);
                    170: }
                    171: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.