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

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:  *
1.1.1.2 ! root       38:  *     from: @(#)swap_pager.h  7.1 (Berkeley) 12/5/90
        !            39:  *     swap_pager.h,v 1.3 1993/05/20 03:59:17 cgd Exp
1.1       root       40:  */
                     41: 
1.1.1.2 ! root       42: #ifndef _VM_SWAP_PAGER_H_
        !            43: #define _VM_SWAP_PAGER_H_
1.1       root       44: 
                     45: /*
                     46:  * In the swap pager, the backing store for an object is organized as an
                     47:  * array of some number of "swap blocks".  A swap block consists of a bitmask
                     48:  * and some number of contiguous DEV_BSIZE disk blocks.  The minimum size
                     49:  * of a swap block is:
                     50:  *
                     51:  *     max(PAGE_SIZE, dmmin*DEV_BSIZE)                 [ 32k currently ]
                     52:  *
                     53:  * bytes (since the pager interface is page oriented), the maximum size is:
                     54:  *
                     55:  *     min(#bits(swb_mask)*PAGE_SIZE, dmmax*DEV_BSIZE) [ 128k currently ]
                     56:  *
                     57:  * where dmmin and dmmax are left over from the old VM interface.  The bitmask
                     58:  * (swb_mask) is used by swap_pager_haspage() to determine if a particular
                     59:  * page has actually been written; i.e. the pager copy of the page is valid.
                     60:  * All swap blocks in the backing store of an object will be the same size.
                     61:  *
                     62:  * The reason for variable sized swap blocks is to reduce fragmentation of
                     63:  * swap resources.  Whenever possible we allocate smaller swap blocks to
                     64:  * smaller objects.  The swap block size is determined from a table of
                     65:  * object-size vs. swap-block-size computed at boot time.
                     66:  */
                     67: typedef        int     sw_bm_t;        /* pager bitmask */
                     68: 
                     69: struct swblock {
                     70:        sw_bm_t  swb_mask;      /* bitmask of valid pages in this block */
                     71:        daddr_t  swb_block;     /* starting disk block for this block */
                     72: };
                     73: typedef struct swblock *sw_blk_t;
                     74: 
                     75: /*
                     76:  * Swap pager private data.
                     77:  */
                     78: struct swpager {
                     79:        vm_size_t    sw_osize;  /* size of object we are backing (bytes) */
                     80:        int          sw_bsize;  /* size of swap blocks (DEV_BSIZE units) */
                     81:        int          sw_nblocks;/* number of blocks in list (sw_blk_t units) */
                     82:        sw_blk_t     sw_blocks; /* pointer to list of swap blocks */
                     83:        short        sw_flags;  /* flags */
                     84:        short        sw_poip;   /* pageouts in progress */
                     85: };
                     86: typedef struct swpager *sw_pager_t;
                     87: 
                     88: #define        SW_WANTED       0x01
                     89: #define SW_NAMED       0x02
                     90: 
                     91: #ifdef KERNEL
                     92: 
                     93: void           swap_pager_init();
                     94: vm_pager_t     swap_pager_alloc();
                     95: void           swap_pager_dealloc();
                     96: boolean_t      swap_pager_getpage(), swap_pager_putpage();
                     97: boolean_t      swap_pager_haspage();
                     98: 
                     99: struct pagerops swappagerops = {
                    100:        swap_pager_init,
                    101:        swap_pager_alloc,
                    102:        swap_pager_dealloc,
                    103:        swap_pager_getpage,
                    104:        swap_pager_putpage,
                    105:        swap_pager_haspage
                    106: };
                    107: 
                    108: int            swap_pager_iodone();
                    109: boolean_t      swap_pager_clean();
                    110: 
                    111: #endif
                    112: 
1.1.1.2 ! root      113: #endif /* !_VM_SWAP_PAGER_H_ */

unix.superglobalmegacorp.com

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