xref: /titanic_51/usr/src/uts/common/sys/fs/ufs_bio.h (revision a31148363f598def767ac48c5d82e1572e44b935)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/t_lock.h>
33 #include <sys/kstat.h>
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 /*
40  * Statistics on ufs buffer cache
41  * Not protected by locks
42  */
43 struct ufsbiostats {
44 	kstat_named_t ub_breads;	/* ufs_bread */
45 	kstat_named_t ub_bwrites;	/* ufs_bwrite and ufs_bwrite2 */
46 	kstat_named_t ub_fbiwrites;	/* ufs_fbiwrite */
47 	kstat_named_t ub_getpages;	/* ufs_getpage_miss */
48 	kstat_named_t ub_getras;	/* ufs_getpage_ra */
49 	kstat_named_t ub_putsyncs;	/* ufs_putapage (B_SYNC) */
50 	kstat_named_t ub_putasyncs;	/* ufs_putapage (B_ASYNC) */
51 	kstat_named_t ub_pageios;	/* ufs_pageios (swap) */
52 };
53 
54 extern struct ufsbiostats ub;
55 
56 #if defined(_KERNEL)
57 
58 /*
59  * let's define macros for the ufs_bio calls (as they were originally
60  * defined name-wise).  using these macros to access the appropriate
61  * *_common routines to minimize subroutine calls.
62  */
63 extern struct buf *bread_common(void *arg, dev_t dev,
64 					daddr_t blkno, long bsize);
65 extern void bwrite_common(void *arg, struct buf *bp, int force_wait,
66 					int do_relse, int clear_flags);
67 extern struct buf *getblk_common(void * arg, dev_t dev,
68 					daddr_t blkno, long bsize, int flag);
69 
70 #define	UFS_BREAD(ufsvfsp, dev, blkno, bsize)	\
71 	bread_common(ufsvfsp, dev, blkno, bsize)
72 #define	UFS_BWRITE(ufsvfsp, bp)	\
73 	bwrite_common(ufsvfsp, bp, /* force_wait */ 0, /* do_relse */ 1, \
74 	/* clear_flags */ (B_READ | B_DONE | B_ERROR | B_DELWRI))
75 #define	UFS_BRWRITE(ufsvfsp, bp)	\
76 	(bp)->b_flags |= B_RETRYWRI; \
77 	bwrite_common(ufsvfsp, bp, /* force_wait */ 0, /* do_relse */ 1, \
78 	/* clear_flags */ (B_READ | B_DONE | B_ERROR | B_DELWRI))
79 #define	UFS_BWRITE2(ufsvfsp, bp) \
80 	bwrite_common(ufsvfsp, bp, /* force_wait */ 1, /* do_relse */ 0, \
81 	/* clear_flags */ (B_READ | B_DONE | B_ERROR | B_DELWRI))
82 #define	UFS_GETBLK(ufsvfsp, dev, blkno, bsize)	\
83 	getblk_common(ufsvfsp, dev, blkno, bsize, /* errflg */ 0)
84 
85 #endif	/* defined(_KERNEL) */
86 
87 #ifdef	__cplusplus
88 }
89 #endif
90 
91 #endif	/* _SYS_FS_UFS_BIO_H */
92