Annotation of kernel/vm/vnode_pager.h, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
                      3:  *
                      4:  * @APPLE_LICENSE_HEADER_START@
                      5:  * 
                      6:  * Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
                      7:  * Reserved.  This file contains Original Code and/or Modifications of
                      8:  * Original Code as defined in and that are subject to the Apple Public
                      9:  * Source License Version 1.1 (the "License").  You may not use this file
                     10:  * except in compliance with the License.  Please obtain a copy of the
                     11:  * License at http://www.apple.com/publicsource and read it before using
                     12:  * this file.
                     13:  * 
                     14:  * The Original Code and all software distributed under the License are
                     15:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
                     16:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
                     17:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
                     18:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
                     19:  * License for the specific language governing rights and limitations
                     20:  * under the License.
                     21:  * 
                     22:  * @APPLE_LICENSE_HEADER_END@
                     23:  */
                     24: 
                     25: /* 
                     26:  * Mach Operating System
                     27:  * Copyright (c) 1987 Carnegie-Mellon University
                     28:  * All rights reserved.  The CMU software License Agreement specifies
                     29:  * the terms and conditions for use and redistribution.
                     30:  */
                     31: 
                     32: #ifndef        _VNODE_PAGER_
                     33: #define        _VNODE_PAGER_   1
                     34: 
                     35: #import <mach/kern_return.h>
                     36: #import <sys/types.h>
                     37: #import <kern/lock.h>
                     38: #import <kern/queue.h>
                     39: 
                     40: kern_return_t  mach_swapon();
                     41: 
                     42: #ifdef KERNEL
                     43: 
                     44: #import <mach/boolean.h>
                     45: #import <vm/vm_pager.h>
                     46: 
                     47: void           vnode_pager_init();
                     48: 
                     49: vm_pager_t     vnode_pager_setup();
                     50: boolean_t      vnode_has_page();
                     51: boolean_t      vnode_pager_active();
                     52: 
                     53: /*
                     54:  *  Vstructs are the internal (to us) description of a unit of backing store.
                     55:  *  The are the link between memory objects and the backing store they represent.
                     56:  *  For the vnode pager, backing store comes in two flavors: normal files and
                     57:  *  swap files.
                     58:  *
                     59:  *  For objects that page to and from normal files (e.g. objects that represent
                     60:  *  program text segments), we maintain some simple parameters that allow us to
                     61:  *  access the file's contents directly through the vnode interface.
                     62:  *
                     63:  *  Data for objects without associated vnodes is maintained in the swap files.
                     64:  *  Each object that uses one of these as backing store has a vstruct indicating
                     65:  *  the swap file of preference (vs_pf) and a mapping between contiguous object
                     66:  *  offsets and swap file offsets (vs_pmap).  Each entry in this mapping specifies
                     67:  *  the pager file to use, and the offset of the page in that pager file.  These
                     68:  *  mapping entries are of type pfMapEntry.
                     69:  */
                     70: 
                     71: /*
                     72:  * Pager file structure.  One per swap file.
                     73:  */
                     74: typedef struct pager_file {
                     75:        queue_chain_t   pf_chain;       /* link to other paging files */
                     76:        struct  vnode   *pf_vp;         /* vnode of paging file */
                     77:        u_int           pf_count;       /* Number of vstruct using this file */
                     78:        u_char          *pf_bmap;       /* Map of used blocks */
                     79:        long            pf_npgs;        /* Size of file in pages */
                     80:        long            pf_pfree;       /* Number of unused pages */
                     81:        long            pf_lowat;       /* Low water page */
                     82:        long            pf_hipage;      /* Highest page allocated */
                     83:        long            pf_hint;        /* Lowest page unallocated */
                     84:        char            *pf_name;       /* Filename of this file */
                     85:        boolean_t       pf_prefer;
                     86:        int             pf_index;       /* index into the pager_file array */
                     87:        lock_data_t     pf_lock;        /* Lock for alloc and dealloc */
                     88: } *pager_file_t;
                     89: 
                     90: #define        PAGER_FILE_NULL (pager_file_t) 0
                     91: 
                     92: #define        MAXPAGERFILES 16
                     93: 
                     94: 
                     95: /*
                     96:  * Pager file data structures.
                     97:  */
                     98: #define        INDEX_NULL      0
                     99: typedef struct {
                    100:        unsigned int index:8;   /* paging file this block is in */
                    101:        unsigned int offset:24; /* page number where block resides */
                    102: } pf_entry;
                    103: 
                    104: typedef enum {
                    105:                IS_INODE,       /* Local disk */
                    106:                IS_RNODE        /* NFS */
                    107:        } vpager_fstype;
                    108: 
                    109: /*
                    110:  *  Basic vnode pager structure.  One per object, backing-store pair.
                    111:  */
                    112: typedef struct vstruct {
                    113:        boolean_t       is_device;      /* Must be first - see vm_pager.h */
                    114:        pager_file_t    vs_pf;          /* Pager file this uses */
                    115:        pf_entry        **vs_pmap;      /* Map of pages into paging file */
                    116:        unsigned int
                    117:        /* boolean_t */ vs_swapfile:1;  /* vnode is a swapfile */
                    118:        short           vs_count;       /* use count */
                    119:        int             vs_size;        /* size of this chunk in pages*/
                    120:        struct vnode    *vs_vp;         /* vnode to page to */
                    121: } *vnode_pager_t;
                    122: 
                    123: #define        VNODE_PAGER_NULL        ((vnode_pager_t) 0)
                    124: 
                    125: 
                    126: 
                    127: pager_return_t vnode_pagein();
                    128: pager_return_t vnode_pageout();
                    129: void           vnode_dealloc();
                    130: vm_pager_t     vnode_alloc();
                    131: int            vnode_uncache();
                    132: 
                    133: #endif /* KERNEL */
                    134: 
                    135: #endif /* _VNODE_PAGER_ */

unix.superglobalmegacorp.com

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