swap_pager.h revision 1549
11541Srgrimes/*
21541Srgrimes * Copyright (c) 1990 University of Utah.
31549Srgrimes * Copyright (c) 1991 The Regents of the University of California.
41549Srgrimes * All rights reserved.
51541Srgrimes *
61541Srgrimes * This code is derived from software contributed to Berkeley by
71541Srgrimes * the Systems Programming Group of the University of Utah Computer
81541Srgrimes * Science Department.
91541Srgrimes *
101541Srgrimes * Redistribution and use in source and binary forms, with or without
111541Srgrimes * modification, are permitted provided that the following conditions
121541Srgrimes * are met:
131541Srgrimes * 1. Redistributions of source code must retain the above copyright
141541Srgrimes *    notice, this list of conditions and the following disclaimer.
151541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
161541Srgrimes *    notice, this list of conditions and the following disclaimer in the
171541Srgrimes *    documentation and/or other materials provided with the distribution.
181541Srgrimes * 3. All advertising materials mentioning features or use of this software
191541Srgrimes *    must display the following acknowledgement:
201541Srgrimes *	This product includes software developed by the University of
211541Srgrimes *	California, Berkeley and its contributors.
221541Srgrimes * 4. Neither the name of the University nor the names of its contributors
231541Srgrimes *    may be used to endorse or promote products derived from this software
241541Srgrimes *    without specific prior written permission.
251541Srgrimes *
261541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
271541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
281541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
291541Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
301541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
311541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
321541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
331541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
341541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
351541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
361541Srgrimes * SUCH DAMAGE.
371541Srgrimes *
381549Srgrimes *	from: @(#)swap_pager.h	7.1 (Berkeley) 12/5/90
391549Srgrimes *	$Id: swap_pager.h,v 1.9 1994/03/14 21:54:23 davidg Exp $
401541Srgrimes */
411541Srgrimes
421549Srgrimes/*
431549Srgrimes * Modifications to the block allocation data structure by John S. Dyson
441549Srgrimes * 18 Dec 93.
451549Srgrimes */
461549Srgrimes
471541Srgrimes#ifndef	_SWAP_PAGER_
481541Srgrimes#define	_SWAP_PAGER_	1
491541Srgrimes
501541Srgrimes/*
511549Srgrimes * SWB_NPAGES can be set to any value from 1 to 16 pages per allocation,
521549Srgrimes * however, due to the allocation spilling into non-swap pager backed memory,
531549Srgrimes * suggest keeping SWB_NPAGES small (1-4).  If high performance is manditory
541549Srgrimes * perhaps up to 8 pages might be in order????
551549Srgrimes * Above problem has been fixed, now we support 16 pages per block.  Unused
561549Srgrimes * space is recovered by the swap pager now...
571541Srgrimes */
581549Srgrimes#define SWB_NPAGES 8
591541Srgrimesstruct	swblock {
601549Srgrimes	unsigned short swb_valid;	/* bitmask for valid pages */
611549Srgrimes	unsigned short swb_locked;	/* block locked */
621549Srgrimes	int	 swb_block[SWB_NPAGES];	/* unfortunately int instead of daddr_t */
631541Srgrimes};
641541Srgrimestypedef struct swblock	*sw_blk_t;
651541Srgrimes
661541Srgrimes/*
671541Srgrimes * Swap pager private data.
681541Srgrimes */
691541Srgrimesstruct swpager {
701541Srgrimes	vm_size_t    sw_osize;	/* size of object we are backing (bytes) */
711541Srgrimes	int	     sw_nblocks;/* number of blocks in list (sw_blk_t units) */
721541Srgrimes	sw_blk_t     sw_blocks;	/* pointer to list of swap blocks */
731541Srgrimes	short	     sw_flags;	/* flags */
741541Srgrimes	short	     sw_poip;	/* pageouts in progress */
751549Srgrimes	short	     sw_piip;	/* pageins in progress */
761541Srgrimes};
771541Srgrimestypedef struct swpager	*sw_pager_t;
781541Srgrimes
791541Srgrimes#define	SW_WANTED	0x01
801541Srgrimes#define SW_NAMED	0x02
811541Srgrimes
821549Srgrimes#ifdef KERNEL
831549Srgrimes
841549Srgrimesvoid		swap_pager_init(void);
851549Srgrimesvm_pager_t	swap_pager_alloc(caddr_t, vm_size_t, vm_prot_t, vm_offset_t);
861549Srgrimesvoid		swap_pager_dealloc(vm_pager_t);
871549Srgrimesboolean_t	swap_pager_getpage(vm_pager_t, vm_page_t, boolean_t);
881549Srgrimesboolean_t	swap_pager_putpage(vm_pager_t, vm_page_t, boolean_t);
891549Srgrimesboolean_t	swap_pager_getmulti(vm_pager_t, vm_page_t *, int, int, boolean_t);
901549Srgrimesboolean_t	swap_pager_haspage(vm_pager_t, vm_offset_t);
911549Srgrimesint		swap_pager_io(sw_pager_t, vm_page_t *, int, int, int);
921549Srgrimesvoid		swap_pager_iodone(struct buf *);
931549Srgrimesboolean_t	swap_pager_clean();
941549Srgrimes
951549Srgrimesextern struct pagerops swappagerops;
961549Srgrimes
971549Srgrimes#endif
981549Srgrimes
991541Srgrimes#endif	/* _SWAP_PAGER_ */
100