1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 28*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate /* 31*7c478bd9Sstevel@tonic-gate * University Copyright- Copyright (c) 1982, 1986, 1988 32*7c478bd9Sstevel@tonic-gate * The Regents of the University of California 33*7c478bd9Sstevel@tonic-gate * All Rights Reserved 34*7c478bd9Sstevel@tonic-gate * 35*7c478bd9Sstevel@tonic-gate * University Acknowledgment- Portions of this document are derived from 36*7c478bd9Sstevel@tonic-gate * software developed by the University of California, Berkeley, and its 37*7c478bd9Sstevel@tonic-gate * contributors. 38*7c478bd9Sstevel@tonic-gate */ 39*7c478bd9Sstevel@tonic-gate 40*7c478bd9Sstevel@tonic-gate #ifndef _SYS_BUF_H 41*7c478bd9Sstevel@tonic-gate #define _SYS_BUF_H 42*7c478bd9Sstevel@tonic-gate 43*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 44*7c478bd9Sstevel@tonic-gate 45*7c478bd9Sstevel@tonic-gate #include <sys/types32.h> 46*7c478bd9Sstevel@tonic-gate #include <sys/t_lock.h> 47*7c478bd9Sstevel@tonic-gate #include <sys/kstat.h> 48*7c478bd9Sstevel@tonic-gate 49*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 50*7c478bd9Sstevel@tonic-gate extern "C" { 51*7c478bd9Sstevel@tonic-gate #endif 52*7c478bd9Sstevel@tonic-gate 53*7c478bd9Sstevel@tonic-gate /* 54*7c478bd9Sstevel@tonic-gate * Each buffer in the pool is usually doubly linked into 2 lists: 55*7c478bd9Sstevel@tonic-gate * the device with which it is currently associated (always) 56*7c478bd9Sstevel@tonic-gate * and also on a list of blocks available for allocation 57*7c478bd9Sstevel@tonic-gate * for other use (usually). 58*7c478bd9Sstevel@tonic-gate * The latter list is kept in last-used order, and the two 59*7c478bd9Sstevel@tonic-gate * lists are doubly linked to make it easy to remove 60*7c478bd9Sstevel@tonic-gate * a buffer from one list when it was found by 61*7c478bd9Sstevel@tonic-gate * looking through the other. 62*7c478bd9Sstevel@tonic-gate * A buffer is on the available list, and is liable 63*7c478bd9Sstevel@tonic-gate * to be reassigned to another disk block, if and only 64*7c478bd9Sstevel@tonic-gate * if it is not marked BUSY. When a buffer is busy, the 65*7c478bd9Sstevel@tonic-gate * available-list pointers can be used for other purposes. 66*7c478bd9Sstevel@tonic-gate * Most drivers use the forward ptr as a link in their I/O active queue. 67*7c478bd9Sstevel@tonic-gate * A buffer header contains all the information required to perform I/O. 68*7c478bd9Sstevel@tonic-gate * Most of the routines which manipulate these things are in bio.c. 69*7c478bd9Sstevel@tonic-gate * 70*7c478bd9Sstevel@tonic-gate * There are a number of locks associated with the buffer management 71*7c478bd9Sstevel@tonic-gate * system. 72*7c478bd9Sstevel@tonic-gate * hbuf.b_lock: protects hash chains, buffer hdr freelists 73*7c478bd9Sstevel@tonic-gate * and delayed write freelist 74*7c478bd9Sstevel@tonic-gate * bfree_lock; protects the bfreelist structure 75*7c478bd9Sstevel@tonic-gate * bhdr_lock: protects the free header list 76*7c478bd9Sstevel@tonic-gate * blist_lock: protects b_list fields 77*7c478bd9Sstevel@tonic-gate * buf.b_sem: protects all remaining members in the buf struct 78*7c478bd9Sstevel@tonic-gate * buf.b_io: I/O synchronization variable 79*7c478bd9Sstevel@tonic-gate * 80*7c478bd9Sstevel@tonic-gate * A buffer header is never "locked" (b_sem) when it is on 81*7c478bd9Sstevel@tonic-gate * a "freelist" (bhdrlist or bfreelist avail lists). 82*7c478bd9Sstevel@tonic-gate */ 83*7c478bd9Sstevel@tonic-gate typedef struct buf { 84*7c478bd9Sstevel@tonic-gate int b_flags; /* see defines below */ 85*7c478bd9Sstevel@tonic-gate struct buf *b_forw; /* headed by d_tab of conf.c */ 86*7c478bd9Sstevel@tonic-gate struct buf *b_back; /* " */ 87*7c478bd9Sstevel@tonic-gate struct buf *av_forw; /* position on free list, */ 88*7c478bd9Sstevel@tonic-gate struct buf *av_back; /* if not BUSY */ 89*7c478bd9Sstevel@tonic-gate o_dev_t b_dev; /* OLD major+minor device name */ 90*7c478bd9Sstevel@tonic-gate size_t b_bcount; /* transfer count */ 91*7c478bd9Sstevel@tonic-gate union { 92*7c478bd9Sstevel@tonic-gate caddr_t b_addr; /* low order core address */ 93*7c478bd9Sstevel@tonic-gate struct fs *b_fs; /* superblocks */ 94*7c478bd9Sstevel@tonic-gate struct cg *b_cg; /* UFS cylinder group block */ 95*7c478bd9Sstevel@tonic-gate struct dinode *b_dino; /* UFS ilist */ 96*7c478bd9Sstevel@tonic-gate daddr32_t *b_daddr; /* disk blocks */ 97*7c478bd9Sstevel@tonic-gate } b_un; 98*7c478bd9Sstevel@tonic-gate 99*7c478bd9Sstevel@tonic-gate lldaddr_t _b_blkno; /* block # on device (union) */ 100*7c478bd9Sstevel@tonic-gate #define b_lblkno _b_blkno._f 101*7c478bd9Sstevel@tonic-gate #ifdef _LP64 102*7c478bd9Sstevel@tonic-gate #define b_blkno _b_blkno._f 103*7c478bd9Sstevel@tonic-gate #else 104*7c478bd9Sstevel@tonic-gate #define b_blkno _b_blkno._p._l 105*7c478bd9Sstevel@tonic-gate #endif /* _LP64 */ 106*7c478bd9Sstevel@tonic-gate 107*7c478bd9Sstevel@tonic-gate char b_obs1; /* obsolete */ 108*7c478bd9Sstevel@tonic-gate size_t b_resid; /* words not transferred after error */ 109*7c478bd9Sstevel@tonic-gate clock_t b_start; /* request start time */ 110*7c478bd9Sstevel@tonic-gate struct proc *b_proc; /* process doing physical or swap I/O */ 111*7c478bd9Sstevel@tonic-gate struct page *b_pages; /* page list for PAGEIO */ 112*7c478bd9Sstevel@tonic-gate clock_t b_obs2; /* obsolete */ 113*7c478bd9Sstevel@tonic-gate /* Begin new stuff */ 114*7c478bd9Sstevel@tonic-gate #define b_actf av_forw 115*7c478bd9Sstevel@tonic-gate #define b_actl av_back 116*7c478bd9Sstevel@tonic-gate #define b_active b_bcount 117*7c478bd9Sstevel@tonic-gate #define b_errcnt b_resid 118*7c478bd9Sstevel@tonic-gate size_t b_bufsize; /* size of allocated buffer */ 119*7c478bd9Sstevel@tonic-gate int (*b_iodone)(struct buf *); /* function called by iodone */ 120*7c478bd9Sstevel@tonic-gate struct vnode *b_vp; /* vnode associated with block */ 121*7c478bd9Sstevel@tonic-gate struct buf *b_chain; /* chain together all buffers here */ 122*7c478bd9Sstevel@tonic-gate int b_obs3; /* obsolete */ 123*7c478bd9Sstevel@tonic-gate int b_error; /* expanded error field */ 124*7c478bd9Sstevel@tonic-gate void *b_private; /* "opaque" driver private area */ 125*7c478bd9Sstevel@tonic-gate dev_t b_edev; /* expanded dev field */ 126*7c478bd9Sstevel@tonic-gate ksema_t b_sem; /* Exclusive access to buf */ 127*7c478bd9Sstevel@tonic-gate ksema_t b_io; /* I/O Synchronization */ 128*7c478bd9Sstevel@tonic-gate struct buf *b_list; /* List of potential B_DELWRI bufs */ 129*7c478bd9Sstevel@tonic-gate struct page **b_shadow; /* shadow page list */ 130*7c478bd9Sstevel@tonic-gate void *b_dip; /* device info pointer */ 131*7c478bd9Sstevel@tonic-gate struct vnode *b_file; /* file associated with this buffer */ 132*7c478bd9Sstevel@tonic-gate offset_t b_offset; /* offset in file assoc. with buffer */ 133*7c478bd9Sstevel@tonic-gate } buf_t; 134*7c478bd9Sstevel@tonic-gate 135*7c478bd9Sstevel@tonic-gate /* 136*7c478bd9Sstevel@tonic-gate * Bufhd structures used at the head of the hashed buffer queues. 137*7c478bd9Sstevel@tonic-gate * We only need seven words for this, so this abbreviated 138*7c478bd9Sstevel@tonic-gate * definition saves some space. 139*7c478bd9Sstevel@tonic-gate */ 140*7c478bd9Sstevel@tonic-gate struct diskhd { 141*7c478bd9Sstevel@tonic-gate int b_flags; /* not used, needed for consistency */ 142*7c478bd9Sstevel@tonic-gate struct buf *b_forw, *b_back; /* queue of unit queues */ 143*7c478bd9Sstevel@tonic-gate struct buf *av_forw, *av_back; /* queue of bufs for this unit */ 144*7c478bd9Sstevel@tonic-gate o_dev_t b_dev; /* OLD major+minor device name */ 145*7c478bd9Sstevel@tonic-gate size_t b_bcount; /* transfer count */ 146*7c478bd9Sstevel@tonic-gate }; 147*7c478bd9Sstevel@tonic-gate 148*7c478bd9Sstevel@tonic-gate 149*7c478bd9Sstevel@tonic-gate /* 150*7c478bd9Sstevel@tonic-gate * Statistics on the buffer cache 151*7c478bd9Sstevel@tonic-gate */ 152*7c478bd9Sstevel@tonic-gate struct biostats { 153*7c478bd9Sstevel@tonic-gate kstat_named_t bio_lookup; /* requests to assign buffer */ 154*7c478bd9Sstevel@tonic-gate kstat_named_t bio_hit; /* buffer already associated with blk */ 155*7c478bd9Sstevel@tonic-gate kstat_named_t bio_bufwant; /* kmem_allocs NOSLEEP failed new buf */ 156*7c478bd9Sstevel@tonic-gate kstat_named_t bio_bufwait; /* kmem_allocs with KM_SLEEP for buf */ 157*7c478bd9Sstevel@tonic-gate kstat_named_t bio_bufbusy; /* buffer locked by someone else */ 158*7c478bd9Sstevel@tonic-gate kstat_named_t bio_bufdup; /* duplicate buffer found for block */ 159*7c478bd9Sstevel@tonic-gate }; 160*7c478bd9Sstevel@tonic-gate 161*7c478bd9Sstevel@tonic-gate /* 162*7c478bd9Sstevel@tonic-gate * These flags are kept in b_flags. 163*7c478bd9Sstevel@tonic-gate * The first group is part of the DDI 164*7c478bd9Sstevel@tonic-gate */ 165*7c478bd9Sstevel@tonic-gate #define B_BUSY 0x0001 /* not on av_forw/back list */ 166*7c478bd9Sstevel@tonic-gate #define B_DONE 0x0002 /* transaction finished */ 167*7c478bd9Sstevel@tonic-gate #define B_ERROR 0x0004 /* transaction aborted */ 168*7c478bd9Sstevel@tonic-gate #define B_PAGEIO 0x0010 /* do I/O to pages on bp->p_pages */ 169*7c478bd9Sstevel@tonic-gate #define B_PHYS 0x0020 /* Physical IO potentially using UNIBUS map */ 170*7c478bd9Sstevel@tonic-gate #define B_READ 0x0040 /* read when I/O occurs */ 171*7c478bd9Sstevel@tonic-gate #define B_WRITE 0x0100 /* non-read pseudo-flag */ 172*7c478bd9Sstevel@tonic-gate 173*7c478bd9Sstevel@tonic-gate /* Not part of the DDI */ 174*7c478bd9Sstevel@tonic-gate #define B_WANTED 0x0080 /* issue wakeup when BUSY goes off */ 175*7c478bd9Sstevel@tonic-gate #define B_AGE 0x000200 /* delayed write for correct aging */ 176*7c478bd9Sstevel@tonic-gate #define B_ASYNC 0x000400 /* don't wait for I/O completion */ 177*7c478bd9Sstevel@tonic-gate #define B_DELWRI 0x000800 /* delayed write-wait til buf needed */ 178*7c478bd9Sstevel@tonic-gate #define B_STALE 0x001000 /* on av_* list; invalid contents */ 179*7c478bd9Sstevel@tonic-gate #define B_DONTNEED 0x002000 /* after write, need not be cached */ 180*7c478bd9Sstevel@tonic-gate #define B_REMAPPED 0x004000 /* buffer is kernel addressable */ 181*7c478bd9Sstevel@tonic-gate #define B_FREE 0x008000 /* free page when done */ 182*7c478bd9Sstevel@tonic-gate #define B_INVAL 0x010000 /* does not contain valid info */ 183*7c478bd9Sstevel@tonic-gate #define B_FORCE 0x020000 /* semi-permanent removal from cache */ 184*7c478bd9Sstevel@tonic-gate #define B_NOCACHE 0x080000 /* don't cache block when released */ 185*7c478bd9Sstevel@tonic-gate #define B_TRUNC 0x100000 /* truncate page without I/O */ 186*7c478bd9Sstevel@tonic-gate #define B_SHADOW 0x200000 /* is b_shadow field valid? */ 187*7c478bd9Sstevel@tonic-gate #define B_RETRYWRI 0x400000 /* retry write til works or bfinval */ 188*7c478bd9Sstevel@tonic-gate #define B_FAILFAST 0x1000000 /* Fail promptly if device goes away */ 189*7c478bd9Sstevel@tonic-gate #define B_STARTED 0x2000000 /* io:::start probe called for buf */ 190*7c478bd9Sstevel@tonic-gate #define B_ABRWRITE 0x4000000 /* Application based recovery active */ 191*7c478bd9Sstevel@tonic-gate 192*7c478bd9Sstevel@tonic-gate /* 193*7c478bd9Sstevel@tonic-gate * Insq/Remq for the buffer hash lists. 194*7c478bd9Sstevel@tonic-gate */ 195*7c478bd9Sstevel@tonic-gate #define bremhash(bp) { \ 196*7c478bd9Sstevel@tonic-gate ASSERT((bp)->b_forw != NULL); \ 197*7c478bd9Sstevel@tonic-gate ASSERT((bp)->b_back != NULL); \ 198*7c478bd9Sstevel@tonic-gate (bp)->b_back->b_forw = (bp)->b_forw; \ 199*7c478bd9Sstevel@tonic-gate (bp)->b_forw->b_back = (bp)->b_back; \ 200*7c478bd9Sstevel@tonic-gate (bp)->b_forw = (bp)->b_back = NULL; \ 201*7c478bd9Sstevel@tonic-gate } 202*7c478bd9Sstevel@tonic-gate #define binshash(bp, dp) { \ 203*7c478bd9Sstevel@tonic-gate ASSERT((bp)->b_forw == NULL); \ 204*7c478bd9Sstevel@tonic-gate ASSERT((bp)->b_back == NULL); \ 205*7c478bd9Sstevel@tonic-gate ASSERT((dp)->b_forw != NULL); \ 206*7c478bd9Sstevel@tonic-gate ASSERT((dp)->b_back != NULL); \ 207*7c478bd9Sstevel@tonic-gate (bp)->b_forw = (dp)->b_forw; \ 208*7c478bd9Sstevel@tonic-gate (bp)->b_back = (dp); \ 209*7c478bd9Sstevel@tonic-gate (dp)->b_forw->b_back = (bp); \ 210*7c478bd9Sstevel@tonic-gate (dp)->b_forw = (bp); \ 211*7c478bd9Sstevel@tonic-gate } 212*7c478bd9Sstevel@tonic-gate 213*7c478bd9Sstevel@tonic-gate 214*7c478bd9Sstevel@tonic-gate /* 215*7c478bd9Sstevel@tonic-gate * The hash structure maintains two lists: 216*7c478bd9Sstevel@tonic-gate * 217*7c478bd9Sstevel@tonic-gate * 1) The hash list of buffers (b_forw & b_back) 218*7c478bd9Sstevel@tonic-gate * 2) The LRU free list of buffers on this hash bucket (av_forw & av_back) 219*7c478bd9Sstevel@tonic-gate * 220*7c478bd9Sstevel@tonic-gate * The dwbuf structure keeps a list of delayed write buffers per hash bucket 221*7c478bd9Sstevel@tonic-gate * hence there are exactly the same number of dwbuf structures as there are 222*7c478bd9Sstevel@tonic-gate * the hash buckets (hbuf structures) in the system. 223*7c478bd9Sstevel@tonic-gate * 224*7c478bd9Sstevel@tonic-gate * The number of buffers on the freelist may not be equal to the number of 225*7c478bd9Sstevel@tonic-gate * buffers on the hash list. That is because when buffers are busy they are 226*7c478bd9Sstevel@tonic-gate * taken off the freelist but not off the hash list. "b_length" field keeps 227*7c478bd9Sstevel@tonic-gate * track of the number of free buffers (including delayed writes ones) on 228*7c478bd9Sstevel@tonic-gate * the hash bucket. The "b_lock" mutex protects the free list as well as 229*7c478bd9Sstevel@tonic-gate * the hash list. It also protects the counter "b_length". 230*7c478bd9Sstevel@tonic-gate * 231*7c478bd9Sstevel@tonic-gate * Enties b_forw, b_back, av_forw & av_back must be at the same offset 232*7c478bd9Sstevel@tonic-gate * as the ones in buf structure. 233*7c478bd9Sstevel@tonic-gate */ 234*7c478bd9Sstevel@tonic-gate struct hbuf { 235*7c478bd9Sstevel@tonic-gate int b_flags; 236*7c478bd9Sstevel@tonic-gate 237*7c478bd9Sstevel@tonic-gate struct buf *b_forw; /* hash list forw pointer */ 238*7c478bd9Sstevel@tonic-gate struct buf *b_back; /* hash list back pointer */ 239*7c478bd9Sstevel@tonic-gate 240*7c478bd9Sstevel@tonic-gate struct buf *av_forw; /* free list forw pointer */ 241*7c478bd9Sstevel@tonic-gate struct buf *av_back; /* free list back pointer */ 242*7c478bd9Sstevel@tonic-gate 243*7c478bd9Sstevel@tonic-gate int b_length; /* # of entries on free list */ 244*7c478bd9Sstevel@tonic-gate kmutex_t b_lock; /* lock to protect this structure */ 245*7c478bd9Sstevel@tonic-gate }; 246*7c478bd9Sstevel@tonic-gate 247*7c478bd9Sstevel@tonic-gate 248*7c478bd9Sstevel@tonic-gate /* 249*7c478bd9Sstevel@tonic-gate * The delayed list pointer entries should match with the buf strcuture. 250*7c478bd9Sstevel@tonic-gate */ 251*7c478bd9Sstevel@tonic-gate struct dwbuf { 252*7c478bd9Sstevel@tonic-gate int b_flags; /* not used */ 253*7c478bd9Sstevel@tonic-gate 254*7c478bd9Sstevel@tonic-gate struct buf *b_forw; /* not used */ 255*7c478bd9Sstevel@tonic-gate struct buf *b_back; /* not used */ 256*7c478bd9Sstevel@tonic-gate 257*7c478bd9Sstevel@tonic-gate struct buf *av_forw; /* delayed write forw pointer */ 258*7c478bd9Sstevel@tonic-gate struct buf *av_back; /* delayed write back pointer */ 259*7c478bd9Sstevel@tonic-gate }; 260*7c478bd9Sstevel@tonic-gate 261*7c478bd9Sstevel@tonic-gate 262*7c478bd9Sstevel@tonic-gate /* 263*7c478bd9Sstevel@tonic-gate * Unlink a buffer from the available (free or delayed write) list and mark 264*7c478bd9Sstevel@tonic-gate * it busy (internal interface). 265*7c478bd9Sstevel@tonic-gate */ 266*7c478bd9Sstevel@tonic-gate #define notavail(bp) \ 267*7c478bd9Sstevel@tonic-gate {\ 268*7c478bd9Sstevel@tonic-gate ASSERT(SEMA_HELD(&bp->b_sem)); \ 269*7c478bd9Sstevel@tonic-gate ASSERT((bp)->av_forw != NULL); \ 270*7c478bd9Sstevel@tonic-gate ASSERT((bp)->av_back != NULL); \ 271*7c478bd9Sstevel@tonic-gate ASSERT((bp)->av_forw != (bp)); \ 272*7c478bd9Sstevel@tonic-gate ASSERT((bp)->av_back != (bp)); \ 273*7c478bd9Sstevel@tonic-gate (bp)->av_back->av_forw = (bp)->av_forw; \ 274*7c478bd9Sstevel@tonic-gate (bp)->av_forw->av_back = (bp)->av_back; \ 275*7c478bd9Sstevel@tonic-gate (bp)->b_flags |= B_BUSY; \ 276*7c478bd9Sstevel@tonic-gate (bp)->av_forw = (bp)->av_back = NULL; \ 277*7c478bd9Sstevel@tonic-gate } 278*7c478bd9Sstevel@tonic-gate 279*7c478bd9Sstevel@tonic-gate #if defined(_KERNEL) 280*7c478bd9Sstevel@tonic-gate /* 281*7c478bd9Sstevel@tonic-gate * Macros to avoid the extra function call needed for binary compat. 282*7c478bd9Sstevel@tonic-gate * 283*7c478bd9Sstevel@tonic-gate * B_RETRYWRI is not included in clear_flags for BWRITE(), BWRITE2(), 284*7c478bd9Sstevel@tonic-gate * or brwrite() so that the retry operation is persistent until the 285*7c478bd9Sstevel@tonic-gate * write either succeeds or the buffer is bfinval()'d. 286*7c478bd9Sstevel@tonic-gate * 287*7c478bd9Sstevel@tonic-gate */ 288*7c478bd9Sstevel@tonic-gate #define BREAD(dev, blkno, bsize) \ 289*7c478bd9Sstevel@tonic-gate bread_common(/* ufsvfsp */ NULL, dev, blkno, bsize) 290*7c478bd9Sstevel@tonic-gate 291*7c478bd9Sstevel@tonic-gate #define BWRITE(bp) \ 292*7c478bd9Sstevel@tonic-gate bwrite_common(/* ufsvfsp */ NULL, bp, /* force_wait */ 0, \ 293*7c478bd9Sstevel@tonic-gate /* do_relse */ 1, \ 294*7c478bd9Sstevel@tonic-gate /* clear_flags */ (B_READ | B_DONE | B_ERROR | B_DELWRI)) 295*7c478bd9Sstevel@tonic-gate 296*7c478bd9Sstevel@tonic-gate #define BWRITE2(bp) \ 297*7c478bd9Sstevel@tonic-gate bwrite_common(/* ufsvfsp */ NULL, bp, /* force_wait */ 1, \ 298*7c478bd9Sstevel@tonic-gate /* do_relse */ 0, \ 299*7c478bd9Sstevel@tonic-gate /* clear_flags */ (B_READ | B_DONE | B_ERROR | B_DELWRI)) 300*7c478bd9Sstevel@tonic-gate 301*7c478bd9Sstevel@tonic-gate #define GETBLK(dev, blkno, bsize) \ 302*7c478bd9Sstevel@tonic-gate getblk_common(/* ufsvfsp */ NULL, dev, blkno, bsize, /* errflg */ 0) 303*7c478bd9Sstevel@tonic-gate 304*7c478bd9Sstevel@tonic-gate 305*7c478bd9Sstevel@tonic-gate /* 306*7c478bd9Sstevel@tonic-gate * Macros for new retry write interfaces. 307*7c478bd9Sstevel@tonic-gate */ 308*7c478bd9Sstevel@tonic-gate 309*7c478bd9Sstevel@tonic-gate /* 310*7c478bd9Sstevel@tonic-gate * Same as bdwrite() except write failures are retried. 311*7c478bd9Sstevel@tonic-gate */ 312*7c478bd9Sstevel@tonic-gate #define bdrwrite(bp) { \ 313*7c478bd9Sstevel@tonic-gate (bp)->b_flags |= B_RETRYWRI; \ 314*7c478bd9Sstevel@tonic-gate bdwrite((bp)); \ 315*7c478bd9Sstevel@tonic-gate } 316*7c478bd9Sstevel@tonic-gate 317*7c478bd9Sstevel@tonic-gate /* 318*7c478bd9Sstevel@tonic-gate * Same as bwrite() except write failures are retried. 319*7c478bd9Sstevel@tonic-gate */ 320*7c478bd9Sstevel@tonic-gate #define brwrite(bp) { \ 321*7c478bd9Sstevel@tonic-gate (bp)->b_flags |= B_RETRYWRI; \ 322*7c478bd9Sstevel@tonic-gate bwrite_common((bp), /* force_wait */ 0, /* do_relse */ 1, \ 323*7c478bd9Sstevel@tonic-gate /* clear_flags */ (B_READ | B_DONE | B_ERROR | B_DELWRI)); \ 324*7c478bd9Sstevel@tonic-gate } 325*7c478bd9Sstevel@tonic-gate 326*7c478bd9Sstevel@tonic-gate extern struct hbuf *hbuf; /* Hash table */ 327*7c478bd9Sstevel@tonic-gate extern struct dwbuf *dwbuf; /* delayed write hash table */ 328*7c478bd9Sstevel@tonic-gate extern struct buf *buf; /* The buffer pool itself */ 329*7c478bd9Sstevel@tonic-gate extern struct buf bfreelist; /* head of available list */ 330*7c478bd9Sstevel@tonic-gate 331*7c478bd9Sstevel@tonic-gate extern void (*bio_lufs_strategy)(void *, buf_t *); /* UFS Logging */ 332*7c478bd9Sstevel@tonic-gate extern void (*bio_snapshot_strategy)(void *, buf_t *); /* UFS snapshots */ 333*7c478bd9Sstevel@tonic-gate 334*7c478bd9Sstevel@tonic-gate int bcheck(dev_t, struct buf *); 335*7c478bd9Sstevel@tonic-gate int iowait(struct buf *); 336*7c478bd9Sstevel@tonic-gate int hash2ints(int x, int y); 337*7c478bd9Sstevel@tonic-gate int bio_busy(int); 338*7c478bd9Sstevel@tonic-gate int biowait(struct buf *); 339*7c478bd9Sstevel@tonic-gate int biomodified(struct buf *); 340*7c478bd9Sstevel@tonic-gate int geterror(struct buf *); 341*7c478bd9Sstevel@tonic-gate void minphys(struct buf *); 342*7c478bd9Sstevel@tonic-gate /* 343*7c478bd9Sstevel@tonic-gate * ufsvfsp is declared as a void * to avoid having everyone that uses 344*7c478bd9Sstevel@tonic-gate * this header file include sys/fs/ufs_inode.h. 345*7c478bd9Sstevel@tonic-gate */ 346*7c478bd9Sstevel@tonic-gate void bwrite_common(void *ufsvfsp, struct buf *, int force_wait, 347*7c478bd9Sstevel@tonic-gate int do_relse, int clear_flags); 348*7c478bd9Sstevel@tonic-gate void bwrite(struct buf *); 349*7c478bd9Sstevel@tonic-gate void bwrite2(struct buf *); 350*7c478bd9Sstevel@tonic-gate void bdwrite(struct buf *); 351*7c478bd9Sstevel@tonic-gate void bawrite(struct buf *); 352*7c478bd9Sstevel@tonic-gate void brelse(struct buf *); 353*7c478bd9Sstevel@tonic-gate void iodone(struct buf *); 354*7c478bd9Sstevel@tonic-gate void clrbuf(struct buf *); 355*7c478bd9Sstevel@tonic-gate void bflush(dev_t); 356*7c478bd9Sstevel@tonic-gate void blkflush(dev_t, daddr_t); 357*7c478bd9Sstevel@tonic-gate void binval(dev_t); 358*7c478bd9Sstevel@tonic-gate int bfinval(dev_t, int); 359*7c478bd9Sstevel@tonic-gate void binit(void); 360*7c478bd9Sstevel@tonic-gate void biodone(struct buf *); 361*7c478bd9Sstevel@tonic-gate void bioinit(struct buf *); 362*7c478bd9Sstevel@tonic-gate void biofini(struct buf *); 363*7c478bd9Sstevel@tonic-gate void bp_mapin(struct buf *); 364*7c478bd9Sstevel@tonic-gate void *bp_mapin_common(struct buf *, int); 365*7c478bd9Sstevel@tonic-gate void bp_mapout(struct buf *); 366*7c478bd9Sstevel@tonic-gate void bp_init(size_t, uint_t); 367*7c478bd9Sstevel@tonic-gate int bp_color(struct buf *); 368*7c478bd9Sstevel@tonic-gate void pageio_done(struct buf *); 369*7c478bd9Sstevel@tonic-gate struct buf *bread(dev_t, daddr_t, long); 370*7c478bd9Sstevel@tonic-gate struct buf *bread_common(void *, dev_t, daddr_t, long); 371*7c478bd9Sstevel@tonic-gate struct buf *breada(dev_t, daddr_t, daddr_t, long); 372*7c478bd9Sstevel@tonic-gate struct buf *getblk(dev_t, daddr_t, long); 373*7c478bd9Sstevel@tonic-gate struct buf *getblk_common(void *, dev_t, daddr_t, long, int); 374*7c478bd9Sstevel@tonic-gate struct buf *ngeteblk(long); 375*7c478bd9Sstevel@tonic-gate struct buf *geteblk(void); 376*7c478bd9Sstevel@tonic-gate struct buf *pageio_setup(struct page *, size_t, struct vnode *, int); 377*7c478bd9Sstevel@tonic-gate void bioerror(struct buf *bp, int error); 378*7c478bd9Sstevel@tonic-gate void bioreset(struct buf *bp); 379*7c478bd9Sstevel@tonic-gate struct buf *bioclone(struct buf *, off_t, size_t, dev_t, daddr_t, 380*7c478bd9Sstevel@tonic-gate int (*)(struct buf *), struct buf *, int); 381*7c478bd9Sstevel@tonic-gate size_t biosize(void); 382*7c478bd9Sstevel@tonic-gate #endif /* defined(_KERNEL) */ 383*7c478bd9Sstevel@tonic-gate 384*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 385*7c478bd9Sstevel@tonic-gate } 386*7c478bd9Sstevel@tonic-gate #endif 387*7c478bd9Sstevel@tonic-gate 388*7c478bd9Sstevel@tonic-gate #endif /* _SYS_BUF_H */ 389