xref: /csrg-svn/sys/vm/swap_pager.h (revision 63379)
145749Smckusick /*
245749Smckusick  * Copyright (c) 1990 University of Utah.
3*63379Sbostic  * Copyright (c) 1991, 1993
4*63379Sbostic  *	The Regents of the University of California.  All rights reserved.
545749Smckusick  *
645749Smckusick  * This code is derived from software contributed to Berkeley by
745749Smckusick  * the Systems Programming Group of the University of Utah Computer
845749Smckusick  * Science Department.
945749Smckusick  *
1045749Smckusick  * %sccs.include.redist.c%
1145749Smckusick  *
12*63379Sbostic  *	@(#)swap_pager.h	8.1 (Berkeley) 06/11/93
1345749Smckusick  */
1445749Smckusick 
1545749Smckusick #ifndef	_SWAP_PAGER_
1645749Smckusick #define	_SWAP_PAGER_	1
1745749Smckusick 
1845749Smckusick /*
1945749Smckusick  * In the swap pager, the backing store for an object is organized as an
2045749Smckusick  * array of some number of "swap blocks".  A swap block consists of a bitmask
2145749Smckusick  * and some number of contiguous DEV_BSIZE disk blocks.  The minimum size
2245749Smckusick  * of a swap block is:
2345749Smckusick  *
2445749Smckusick  *	max(PAGE_SIZE, dmmin*DEV_BSIZE)			[ 32k currently ]
2545749Smckusick  *
2645749Smckusick  * bytes (since the pager interface is page oriented), the maximum size is:
2745749Smckusick  *
2845749Smckusick  *	min(#bits(swb_mask)*PAGE_SIZE, dmmax*DEV_BSIZE)	[ 128k currently ]
2945749Smckusick  *
3045749Smckusick  * where dmmin and dmmax are left over from the old VM interface.  The bitmask
3145749Smckusick  * (swb_mask) is used by swap_pager_haspage() to determine if a particular
3245749Smckusick  * page has actually been written; i.e. the pager copy of the page is valid.
3345749Smckusick  * All swap blocks in the backing store of an object will be the same size.
3445749Smckusick  *
3545749Smckusick  * The reason for variable sized swap blocks is to reduce fragmentation of
3645749Smckusick  * swap resources.  Whenever possible we allocate smaller swap blocks to
3745749Smckusick  * smaller objects.  The swap block size is determined from a table of
3845749Smckusick  * object-size vs. swap-block-size computed at boot time.
3945749Smckusick  */
4045749Smckusick typedef	int	sw_bm_t;	/* pager bitmask */
4145749Smckusick 
4245749Smckusick struct	swblock {
4345749Smckusick 	sw_bm_t	 swb_mask;	/* bitmask of valid pages in this block */
4445749Smckusick 	daddr_t	 swb_block;	/* starting disk block for this block */
4545749Smckusick };
4645749Smckusick typedef struct swblock	*sw_blk_t;
4745749Smckusick 
4845749Smckusick /*
4945749Smckusick  * Swap pager private data.
5045749Smckusick  */
5145749Smckusick struct swpager {
5245749Smckusick 	vm_size_t    sw_osize;	/* size of object we are backing (bytes) */
5345749Smckusick 	int	     sw_bsize;	/* size of swap blocks (DEV_BSIZE units) */
5445749Smckusick 	int	     sw_nblocks;/* number of blocks in list (sw_blk_t units) */
5545749Smckusick 	sw_blk_t     sw_blocks;	/* pointer to list of swap blocks */
5645749Smckusick 	short	     sw_flags;	/* flags */
5745749Smckusick 	short	     sw_poip;	/* pageouts in progress */
5845749Smckusick };
5945749Smckusick typedef struct swpager	*sw_pager_t;
6045749Smckusick 
6145749Smckusick #define	SW_WANTED	0x01
6245749Smckusick #define SW_NAMED	0x02
6345749Smckusick 
6445749Smckusick #endif	/* _SWAP_PAGER_ */
65