6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 * Copyright 2011 Joyent, Inc. All rights reserved.
25 */
26
27 /*
28 * Copyright (c) 2016 by Delphix. All rights reserved.
29 */
30
31 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
32 /* All Rights Reserved */
33
34 /*
35 * University Copyright- Copyright (c) 1982, 1986, 1988
36 * The Regents of the University of California
37 * All Rights Reserved
38 *
39 * University Acknowledgment- Portions of this document are derived from
40 * software developed by the University of California, Berkeley, and its
41 * contributors.
42 */
43
44 #include <sys/types.h>
45 #include <sys/t_lock.h>
144 static struct buf *bio_bhdr_alloc(void);
145 static void bio_recycle(int, long);
146 static void bio_pageio_done(struct buf *);
147 static int bio_incore(dev_t, daddr_t);
148
149 /*
150 * Buffer cache constants
151 */
152 #define BIO_BUF_PERCENT (100/2) /* default: 2% of memory */
153 #define BIO_MAX_PERCENT (100/20) /* max is 20% of real memory */
154 #define BIO_BHDR_POOL 100 /* Default bhdr pool size */
155 #define BIO_MIN_HDR 10 /* Minimum number of buffer headers */
156 #define BIO_MIN_HWM (BIO_MIN_HDR * MAXBSIZE / 1024)
157 #define BIO_HASHLEN 4 /* Target length of hash chains */
158
159
160 /* Flags for bio_recycle() */
161 #define BIO_HEADER 0x01
162 #define BIO_MEM 0x02
163
164 extern int bufhwm; /* User tunable - high water mark for mem */
165 extern int bufhwm_pct; /* ditto - given in % of physmem */
166
167 /*
168 * The following routines allocate and free
169 * buffers with various side effects. In general the
170 * arguments to an allocate routine are a device and
171 * a block number, and the value is a pointer to
172 * to the buffer header; the buffer returned is locked with a
173 * binary semaphore so that no one else can touch it. If the block was
174 * already in core, no I/O need be done; if it is
175 * already locked, the process waits until it becomes free.
176 * The following routines allocate a buffer:
177 * getblk
178 * bread/BREAD
179 * breada
180 * Eventually the buffer must be released, possibly with the
181 * side effect of writing it out, by using one of
182 * bwrite/BWRITE/brwrite
183 * bdwrite/bdrwrite
184 * bawrite
185 * brelse
|
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 * Copyright 2011 Joyent, Inc. All rights reserved.
25 */
26 /*
27 * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
28 */
29
30 /*
31 * Copyright (c) 2016 by Delphix. All rights reserved.
32 */
33
34 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
35 /* All Rights Reserved */
36
37 /*
38 * University Copyright- Copyright (c) 1982, 1986, 1988
39 * The Regents of the University of California
40 * All Rights Reserved
41 *
42 * University Acknowledgment- Portions of this document are derived from
43 * software developed by the University of California, Berkeley, and its
44 * contributors.
45 */
46
47 #include <sys/types.h>
48 #include <sys/t_lock.h>
147 static struct buf *bio_bhdr_alloc(void);
148 static void bio_recycle(int, long);
149 static void bio_pageio_done(struct buf *);
150 static int bio_incore(dev_t, daddr_t);
151
152 /*
153 * Buffer cache constants
154 */
155 #define BIO_BUF_PERCENT (100/2) /* default: 2% of memory */
156 #define BIO_MAX_PERCENT (100/20) /* max is 20% of real memory */
157 #define BIO_BHDR_POOL 100 /* Default bhdr pool size */
158 #define BIO_MIN_HDR 10 /* Minimum number of buffer headers */
159 #define BIO_MIN_HWM (BIO_MIN_HDR * MAXBSIZE / 1024)
160 #define BIO_HASHLEN 4 /* Target length of hash chains */
161
162
163 /* Flags for bio_recycle() */
164 #define BIO_HEADER 0x01
165 #define BIO_MEM 0x02
166
167 extern volatile int bufhwm; /* User tunable - high water mark for mem */
168 extern volatile int bufhwm_pct; /* ditto - given in % of physmem */
169
170 /*
171 * The following routines allocate and free
172 * buffers with various side effects. In general the
173 * arguments to an allocate routine are a device and
174 * a block number, and the value is a pointer to
175 * to the buffer header; the buffer returned is locked with a
176 * binary semaphore so that no one else can touch it. If the block was
177 * already in core, no I/O need be done; if it is
178 * already locked, the process waits until it becomes free.
179 * The following routines allocate a buffer:
180 * getblk
181 * bread/BREAD
182 * breada
183 * Eventually the buffer must be released, possibly with the
184 * side effect of writing it out, by using one of
185 * bwrite/BWRITE/brwrite
186 * bdwrite/bdrwrite
187 * bawrite
188 * brelse
|