xref: /illumos-gate/usr/src/uts/common/sys/fs/ufs_bio.h (revision 9164a50bf932130cbb5097a16f6986873ce0e6e5)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 1997,2001 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef _SYS_FS_UFS_BIO_H
28 #define	_SYS_FS_UFS_BIO_H
29 
30 #include <sys/t_lock.h>
31 #include <sys/kstat.h>
32 
33 #ifdef	__cplusplus
34 extern "C" {
35 #endif
36 
37 /*
38  * Statistics on ufs buffer cache
39  * Not protected by locks
40  */
41 struct ufsbiostats {
42 	kstat_named_t ub_breads;	/* ufs_bread */
43 	kstat_named_t ub_bwrites;	/* ufs_bwrite and ufs_bwrite2 */
44 	kstat_named_t ub_fbiwrites;	/* ufs_fbiwrite */
45 	kstat_named_t ub_getpages;	/* ufs_getpage_miss */
46 	kstat_named_t ub_getras;	/* ufs_getpage_ra */
47 	kstat_named_t ub_putsyncs;	/* ufs_putapage (B_SYNC) */
48 	kstat_named_t ub_putasyncs;	/* ufs_putapage (B_ASYNC) */
49 	kstat_named_t ub_pageios;	/* ufs_pageios (swap) */
50 };
51 
52 extern struct ufsbiostats ub;
53 
54 #if defined(_KERNEL)
55 
56 /*
57  * let's define macros for the ufs_bio calls (as they were originally
58  * defined name-wise).  using these macros to access the appropriate
59  * *_common routines to minimize subroutine calls.
60  */
61 extern struct buf *bread_common(void *arg, dev_t dev,
62 					daddr_t blkno, long bsize);
63 extern void bwrite_common(void *arg, struct buf *bp, int force_wait,
64 					int do_relse, int clear_flags);
65 extern struct buf *getblk_common(void * arg, dev_t dev,
66 					daddr_t blkno, long bsize, int flag);
67 
68 #define	UFS_BREAD(ufsvfsp, dev, blkno, bsize)	\
69 	bread_common(ufsvfsp, dev, blkno, bsize)
70 #define	UFS_BWRITE(ufsvfsp, bp)	\
71 	bwrite_common(ufsvfsp, bp, /* force_wait */ 0, /* do_relse */ 1, \
72 	/* clear_flags */ (B_READ | B_DONE | B_ERROR | B_DELWRI))
73 #define	UFS_BRWRITE(ufsvfsp, bp)	\
74 	(bp)->b_flags |= B_RETRYWRI; \
75 	bwrite_common(ufsvfsp, bp, /* force_wait */ 0, /* do_relse */ 1, \
76 	/* clear_flags */ (B_READ | B_DONE | B_ERROR | B_DELWRI))
77 #define	UFS_BWRITE2(ufsvfsp, bp) \
78 	bwrite_common(ufsvfsp, bp, /* force_wait */ 1, /* do_relse */ 0, \
79 	/* clear_flags */ (B_READ | B_DONE | B_ERROR | B_DELWRI))
80 #define	UFS_GETBLK(ufsvfsp, dev, blkno, bsize)	\
81 	getblk_common(ufsvfsp, dev, blkno, bsize, /* errflg */ 0)
82 
83 #endif	/* defined(_KERNEL) */
84 
85 #ifdef	__cplusplus
86 }
87 #endif
88 
89 #endif	/* _SYS_FS_UFS_BIO_H */
90