Home | History | Annotate | Line # | Download | only in fsck_lfs
bufcache.h revision 1.8
      1  1.8        ad /*	$NetBSD: bufcache.h,v 1.8 2007/10/08 21:39:49 ad Exp $	*/
      2  1.1  perseant 
      3  1.1  perseant /*-
      4  1.1  perseant  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
      5  1.1  perseant  * All rights reserved.
      6  1.1  perseant  *
      7  1.1  perseant  * This code is derived from software contributed to The NetBSD Foundation
      8  1.1  perseant  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
      9  1.1  perseant  * NASA Ames Research Center.
     10  1.1  perseant  *
     11  1.1  perseant  * Redistribution and use in source and binary forms, with or without
     12  1.1  perseant  * modification, are permitted provided that the following conditions
     13  1.1  perseant  * are met:
     14  1.1  perseant  * 1. Redistributions of source code must retain the above copyright
     15  1.1  perseant  *    notice, this list of conditions and the following disclaimer.
     16  1.1  perseant  * 2. Redistributions in binary form must reproduce the above copyright
     17  1.1  perseant  *    notice, this list of conditions and the following disclaimer in the
     18  1.1  perseant  *    documentation and/or other materials provided with the distribution.
     19  1.1  perseant  * 3. All advertising materials mentioning features or use of this software
     20  1.1  perseant  *    must display the following acknowledgement:
     21  1.1  perseant  *	This product includes software developed by the NetBSD
     22  1.1  perseant  *	Foundation, Inc. and its contributors.
     23  1.1  perseant  * 4. Neither the name of The NetBSD Foundation nor the names of its
     24  1.1  perseant  *    contributors may be used to endorse or promote products derived
     25  1.1  perseant  *    from this software without specific prior written permission.
     26  1.1  perseant  *
     27  1.1  perseant  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     28  1.1  perseant  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     29  1.1  perseant  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     30  1.1  perseant  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     31  1.1  perseant  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     32  1.1  perseant  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     33  1.1  perseant  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     34  1.1  perseant  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     35  1.1  perseant  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     36  1.1  perseant  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     37  1.1  perseant  * POSSIBILITY OF SUCH DAMAGE.
     38  1.1  perseant  */
     39  1.1  perseant 
     40  1.1  perseant /*
     41  1.1  perseant  * Copyright (c) 1982, 1986, 1989, 1993
     42  1.1  perseant  *	The Regents of the University of California.  All rights reserved.
     43  1.1  perseant  * (c) UNIX System Laboratories, Inc.
     44  1.1  perseant  * All or some portions of this file are derived from material licensed
     45  1.1  perseant  * to the University of California by American Telephone and Telegraph
     46  1.1  perseant  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
     47  1.1  perseant  * the permission of UNIX System Laboratories, Inc.
     48  1.1  perseant  *
     49  1.1  perseant  * Redistribution and use in source and binary forms, with or without
     50  1.1  perseant  * modification, are permitted provided that the following conditions
     51  1.1  perseant  * are met:
     52  1.1  perseant  * 1. Redistributions of source code must retain the above copyright
     53  1.1  perseant  *    notice, this list of conditions and the following disclaimer.
     54  1.1  perseant  * 2. Redistributions in binary form must reproduce the above copyright
     55  1.1  perseant  *    notice, this list of conditions and the following disclaimer in the
     56  1.1  perseant  *    documentation and/or other materials provided with the distribution.
     57  1.2       agc  * 3. Neither the name of the University nor the names of its contributors
     58  1.1  perseant  *    may be used to endorse or promote products derived from this software
     59  1.1  perseant  *    without specific prior written permission.
     60  1.1  perseant  *
     61  1.1  perseant  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     62  1.1  perseant  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     63  1.1  perseant  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     64  1.1  perseant  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     65  1.1  perseant  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     66  1.1  perseant  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     67  1.1  perseant  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     68  1.1  perseant  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     69  1.1  perseant  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     70  1.1  perseant  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     71  1.1  perseant  * SUCH DAMAGE.
     72  1.1  perseant  *
     73  1.1  perseant  *	@(#)buf.h	8.9 (Berkeley) 3/30/95
     74  1.1  perseant  */
     75  1.1  perseant 
     76  1.1  perseant #define BUF_CACHE_SIZE 1000
     77  1.1  perseant 
     78  1.1  perseant /*
     79  1.1  perseant  * The buffer header describes an I/O operation.
     80  1.1  perseant  */
     81  1.1  perseant struct ubuf {
     82  1.1  perseant 	LIST_ENTRY(ubuf) b_hash;	/* Hash chain. */
     83  1.1  perseant 	LIST_ENTRY(ubuf) b_vnbufs;	/* Buffer's associated vnode. */
     84  1.1  perseant 	TAILQ_ENTRY(ubuf) b_freelist;	/* Free list position if not active. */
     85  1.1  perseant 	volatile long	b_flags;	/* B_* flags. */
     86  1.1  perseant 	long	b_bcount;		/* Valid bytes in buffer. */
     87  1.1  perseant #undef b_data
     88  1.1  perseant 	char	*b_data;		/* Data in buffer */
     89  1.1  perseant 	daddr_t	b_lblkno;		/* Logical block number. */
     90  1.1  perseant 	daddr_t	b_blkno;		/* Underlying physical block number */
     91  1.1  perseant 	struct	uvnode *b_vp;		/* File vnode. */
     92  1.4  perseant 	int	b_hashval;		/* Hash value */
     93  1.1  perseant };
     94  1.1  perseant 
     95  1.1  perseant #define b_bufsize b_bcount
     96  1.1  perseant 
     97  1.1  perseant /*
     98  1.1  perseant  * These flags are kept in b_flags.
     99  1.1  perseant  */
    100  1.1  perseant #define	B_AGE		0x00000001	/* Move to age queue when I/O done. */
    101  1.1  perseant #define	B_NEEDCOMMIT	0x00000002	/* Needs committing to stable storage */
    102  1.1  perseant #define	B_BUSY		0x00000010	/* I/O in progress. */
    103  1.1  perseant #define	B_DELWRI	0x00000080	/* Delay I/O until buffer reused. */
    104  1.1  perseant #define	B_DONE		0x00000200	/* I/O completed. */
    105  1.1  perseant #define	B_ERROR		0x00000800	/* I/O error occurred. */
    106  1.1  perseant #define	B_GATHERED	0x00001000	/* LFS: already in a segment. */
    107  1.1  perseant #define	B_INVAL		0x00002000	/* Does not contain valid info. */
    108  1.1  perseant #define	B_LOCKED	0x00004000	/* Locked in core (not reusable). */
    109  1.1  perseant #define	B_READ		0x00100000	/* Read buffer. */
    110  1.5  perseant #define	B_DONTFREE	0x00010000	/* b_data not managed by bufcache */
    111  1.1  perseant 
    112  1.1  perseant LIST_HEAD(bufhash_struct, ubuf);
    113  1.1  perseant 
    114  1.7      yamt #if !defined(NOCRED)
    115  1.7      yamt #define	NOCRED	((void *)-1)	/* dummy; not actually used */
    116  1.7      yamt #endif /* !defined(NOCRED) */
    117  1.7      yamt 
    118  1.4  perseant void bufinit(int);
    119  1.4  perseant void bufrehash(int);
    120  1.1  perseant void bufstats(void);
    121  1.1  perseant void buf_destroy(struct ubuf *);
    122  1.1  perseant void bremfree(struct ubuf *);
    123  1.1  perseant struct ubuf *incore(struct uvnode *, int);
    124  1.1  perseant struct ubuf *getblk(struct uvnode *, daddr_t, int);
    125  1.1  perseant void bwrite(struct ubuf *);
    126  1.8        ad void brelse(struct ubuf *, int);
    127  1.6  christos int bread(struct uvnode *, daddr_t, int, void *, struct ubuf **);
    128  1.1  perseant void reassignbuf(struct ubuf *, struct uvnode *);
    129  1.3  perseant void dump_free_lists(void);
    130