| 1 | /* |
| 2 | * Copyright (c) 1990 University of Utah. |
| 3 | * Copyright (c) 1991, 1993 |
| 4 | * The Regents of the University of California. 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 | * %sccs.include.redist.c% |
| 11 | * |
| 12 | * @(#)swap_pager.h 8.1 (Berkeley) %G% |
| 13 | */ |
| 14 | |
| 15 | #ifndef _SWAP_PAGER_ |
| 16 | #define _SWAP_PAGER_ 1 |
| 17 | |
| 18 | /* |
| 19 | * In the swap pager, the backing store for an object is organized as an |
| 20 | * array of some number of "swap blocks". A swap block consists of a bitmask |
| 21 | * and some number of contiguous DEV_BSIZE disk blocks. The minimum size |
| 22 | * of a swap block is: |
| 23 | * |
| 24 | * max(PAGE_SIZE, dmmin*DEV_BSIZE) [ 32k currently ] |
| 25 | * |
| 26 | * bytes (since the pager interface is page oriented), the maximum size is: |
| 27 | * |
| 28 | * min(#bits(swb_mask)*PAGE_SIZE, dmmax*DEV_BSIZE) [ 128k currently ] |
| 29 | * |
| 30 | * where dmmin and dmmax are left over from the old VM interface. The bitmask |
| 31 | * (swb_mask) is used by swap_pager_haspage() to determine if a particular |
| 32 | * page has actually been written; i.e. the pager copy of the page is valid. |
| 33 | * All swap blocks in the backing store of an object will be the same size. |
| 34 | * |
| 35 | * The reason for variable sized swap blocks is to reduce fragmentation of |
| 36 | * swap resources. Whenever possible we allocate smaller swap blocks to |
| 37 | * smaller objects. The swap block size is determined from a table of |
| 38 | * object-size vs. swap-block-size computed at boot time. |
| 39 | */ |
| 40 | typedef int sw_bm_t; /* pager bitmask */ |
| 41 | |
| 42 | struct swblock { |
| 43 | sw_bm_t swb_mask; /* bitmask of valid pages in this block */ |
| 44 | daddr_t swb_block; /* starting disk block for this block */ |
| 45 | }; |
| 46 | typedef struct swblock *sw_blk_t; |
| 47 | |
| 48 | /* |
| 49 | * Swap pager private data. |
| 50 | */ |
| 51 | struct swpager { |
| 52 | vm_size_t sw_osize; /* size of object we are backing (bytes) */ |
| 53 | int sw_bsize; /* size of swap blocks (DEV_BSIZE units) */ |
| 54 | int sw_nblocks;/* number of blocks in list (sw_blk_t units) */ |
| 55 | sw_blk_t sw_blocks; /* pointer to list of swap blocks */ |
| 56 | short sw_flags; /* flags */ |
| 57 | short sw_poip; /* pageouts in progress */ |
| 58 | }; |
| 59 | typedef struct swpager *sw_pager_t; |
| 60 | |
| 61 | #define SW_WANTED 0x01 |
| 62 | #define SW_NAMED 0x02 |
| 63 | |
| 64 | #endif /* _SWAP_PAGER_ */ |