1*45749Smckusick /* 2*45749Smckusick * Copyright (c) 1990 University of Utah. 3*45749Smckusick * Copyright (c) 1991 The Regents of the University of California. 4*45749Smckusick * All rights reserved. 5*45749Smckusick * 6*45749Smckusick * This code is derived from software contributed to Berkeley by 7*45749Smckusick * the Systems Programming Group of the University of Utah Computer 8*45749Smckusick * Science Department. 9*45749Smckusick * 10*45749Smckusick * %sccs.include.redist.c% 11*45749Smckusick * 12*45749Smckusick * @(#)swap_pager.h 7.1 (Berkeley) 12/05/90 13*45749Smckusick */ 14*45749Smckusick 15*45749Smckusick #ifndef _SWAP_PAGER_ 16*45749Smckusick #define _SWAP_PAGER_ 1 17*45749Smckusick 18*45749Smckusick /* 19*45749Smckusick * In the swap pager, the backing store for an object is organized as an 20*45749Smckusick * array of some number of "swap blocks". A swap block consists of a bitmask 21*45749Smckusick * and some number of contiguous DEV_BSIZE disk blocks. The minimum size 22*45749Smckusick * of a swap block is: 23*45749Smckusick * 24*45749Smckusick * max(PAGE_SIZE, dmmin*DEV_BSIZE) [ 32k currently ] 25*45749Smckusick * 26*45749Smckusick * bytes (since the pager interface is page oriented), the maximum size is: 27*45749Smckusick * 28*45749Smckusick * min(#bits(swb_mask)*PAGE_SIZE, dmmax*DEV_BSIZE) [ 128k currently ] 29*45749Smckusick * 30*45749Smckusick * where dmmin and dmmax are left over from the old VM interface. The bitmask 31*45749Smckusick * (swb_mask) is used by swap_pager_haspage() to determine if a particular 32*45749Smckusick * page has actually been written; i.e. the pager copy of the page is valid. 33*45749Smckusick * All swap blocks in the backing store of an object will be the same size. 34*45749Smckusick * 35*45749Smckusick * The reason for variable sized swap blocks is to reduce fragmentation of 36*45749Smckusick * swap resources. Whenever possible we allocate smaller swap blocks to 37*45749Smckusick * smaller objects. The swap block size is determined from a table of 38*45749Smckusick * object-size vs. swap-block-size computed at boot time. 39*45749Smckusick */ 40*45749Smckusick typedef int sw_bm_t; /* pager bitmask */ 41*45749Smckusick 42*45749Smckusick struct swblock { 43*45749Smckusick sw_bm_t swb_mask; /* bitmask of valid pages in this block */ 44*45749Smckusick daddr_t swb_block; /* starting disk block for this block */ 45*45749Smckusick }; 46*45749Smckusick typedef struct swblock *sw_blk_t; 47*45749Smckusick 48*45749Smckusick /* 49*45749Smckusick * Swap pager private data. 50*45749Smckusick */ 51*45749Smckusick struct swpager { 52*45749Smckusick vm_size_t sw_osize; /* size of object we are backing (bytes) */ 53*45749Smckusick int sw_bsize; /* size of swap blocks (DEV_BSIZE units) */ 54*45749Smckusick int sw_nblocks;/* number of blocks in list (sw_blk_t units) */ 55*45749Smckusick sw_blk_t sw_blocks; /* pointer to list of swap blocks */ 56*45749Smckusick short sw_flags; /* flags */ 57*45749Smckusick short sw_poip; /* pageouts in progress */ 58*45749Smckusick }; 59*45749Smckusick typedef struct swpager *sw_pager_t; 60*45749Smckusick 61*45749Smckusick #define SW_WANTED 0x01 62*45749Smckusick #define SW_NAMED 0x02 63*45749Smckusick 64*45749Smckusick #ifdef KERNEL 65*45749Smckusick 66*45749Smckusick void swap_pager_init(); 67*45749Smckusick vm_pager_t swap_pager_alloc(); 68*45749Smckusick void swap_pager_dealloc(); 69*45749Smckusick boolean_t swap_pager_getpage(), swap_pager_putpage(); 70*45749Smckusick boolean_t swap_pager_haspage(); 71*45749Smckusick 72*45749Smckusick struct pagerops swappagerops = { 73*45749Smckusick swap_pager_init, 74*45749Smckusick swap_pager_alloc, 75*45749Smckusick swap_pager_dealloc, 76*45749Smckusick swap_pager_getpage, 77*45749Smckusick swap_pager_putpage, 78*45749Smckusick swap_pager_haspage 79*45749Smckusick }; 80*45749Smckusick 81*45749Smckusick int swap_pager_iodone(); 82*45749Smckusick boolean_t swap_pager_clean(); 83*45749Smckusick 84*45749Smckusick #endif 85*45749Smckusick 86*45749Smckusick #endif /* _SWAP_PAGER_ */ 87