Annotation of Net2/vm/swap_pager.h, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1990 University of Utah.
                      3:  * Copyright (c) 1991 The Regents of the University of California.
                      4:  * All rights reserved.
                      5:  *
                      6:  * This code is derived from software contributed to Berkeley by
                      7:  * the Systems Programming Group of the University of Utah Computer
                      8:  * Science Department.
                      9:  *
                     10:  * Redistribution and use in source and binary forms, with or without
                     11:  * modification, are permitted provided that the following conditions
                     12:  * are met:
                     13:  * 1. Redistributions of source code must retain the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer.
                     15:  * 2. Redistributions in binary form must reproduce the above copyright
                     16:  *    notice, this list of conditions and the following disclaimer in the
                     17:  *    documentation and/or other materials provided with the distribution.
                     18:  * 3. All advertising materials mentioning features or use of this software
                     19:  *    must display the following acknowledgement:
                     20:  *     This product includes software developed by the University of
                     21:  *     California, Berkeley and its contributors.
                     22:  * 4. Neither the name of the University nor the names of its contributors
                     23:  *    may be used to endorse or promote products derived from this software
                     24:  *    without specific prior written permission.
                     25:  *
                     26:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     27:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     28:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     29:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     30:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     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:  *     @(#)swap_pager.h        7.1 (Berkeley) 12/5/90
                     39:  */
                     40: 
                     41: #ifndef        _SWAP_PAGER_
                     42: #define        _SWAP_PAGER_    1
                     43: 
                     44: /*
                     45:  * In the swap pager, the backing store for an object is organized as an
                     46:  * array of some number of "swap blocks".  A swap block consists of a bitmask
                     47:  * and some number of contiguous DEV_BSIZE disk blocks.  The minimum size
                     48:  * of a swap block is:
                     49:  *
                     50:  *     max(PAGE_SIZE, dmmin*DEV_BSIZE)                 [ 32k currently ]
                     51:  *
                     52:  * bytes (since the pager interface is page oriented), the maximum size is:
                     53:  *
                     54:  *     min(#bits(swb_mask)*PAGE_SIZE, dmmax*DEV_BSIZE) [ 128k currently ]
                     55:  *
                     56:  * where dmmin and dmmax are left over from the old VM interface.  The bitmask
                     57:  * (swb_mask) is used by swap_pager_haspage() to determine if a particular
                     58:  * page has actually been written; i.e. the pager copy of the page is valid.
                     59:  * All swap blocks in the backing store of an object will be the same size.
                     60:  *
                     61:  * The reason for variable sized swap blocks is to reduce fragmentation of
                     62:  * swap resources.  Whenever possible we allocate smaller swap blocks to
                     63:  * smaller objects.  The swap block size is determined from a table of
                     64:  * object-size vs. swap-block-size computed at boot time.
                     65:  */
                     66: typedef        int     sw_bm_t;        /* pager bitmask */
                     67: 
                     68: struct swblock {
                     69:        sw_bm_t  swb_mask;      /* bitmask of valid pages in this block */
                     70:        daddr_t  swb_block;     /* starting disk block for this block */
                     71: };
                     72: typedef struct swblock *sw_blk_t;
                     73: 
                     74: /*
                     75:  * Swap pager private data.
                     76:  */
                     77: struct swpager {
                     78:        vm_size_t    sw_osize;  /* size of object we are backing (bytes) */
                     79:        int          sw_bsize;  /* size of swap blocks (DEV_BSIZE units) */
                     80:        int          sw_nblocks;/* number of blocks in list (sw_blk_t units) */
                     81:        sw_blk_t     sw_blocks; /* pointer to list of swap blocks */
                     82:        short        sw_flags;  /* flags */
                     83:        short        sw_poip;   /* pageouts in progress */
                     84: };
                     85: typedef struct swpager *sw_pager_t;
                     86: 
                     87: #define        SW_WANTED       0x01
                     88: #define SW_NAMED       0x02
                     89: 
                     90: #ifdef KERNEL
                     91: 
                     92: void           swap_pager_init();
                     93: vm_pager_t     swap_pager_alloc();
                     94: void           swap_pager_dealloc();
                     95: boolean_t      swap_pager_getpage(), swap_pager_putpage();
                     96: boolean_t      swap_pager_haspage();
                     97: 
                     98: struct pagerops swappagerops = {
                     99:        swap_pager_init,
                    100:        swap_pager_alloc,
                    101:        swap_pager_dealloc,
                    102:        swap_pager_getpage,
                    103:        swap_pager_putpage,
                    104:        swap_pager_haspage
                    105: };
                    106: 
                    107: int            swap_pager_iodone();
                    108: boolean_t      swap_pager_clean();
                    109: 
                    110: #endif
                    111: 
                    112: #endif /* _SWAP_PAGER_ */

unix.superglobalmegacorp.com

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