biodone(D3)
biodone - release buffer after block I/O and wakeup processes
As shipped in IRIX 6.5.7. Unchanged since IRIX 6.5.
NAME biodone - release buffer after block I/O and wakeup processes SYNOPSIS #include <sys/types.h> #include <sys/buf.h> #include <sys/ddi.h> void biodone(buf_t *bp); Arguments bp Pointer to the buffer header structure. DESCRIPTION The biodone function is called by the driver to indicate that block I/O associated with the buffer header fp is complete, and that it can be reused. Return Values None USAGE biodone is usually called from the driver's strategy(D2) routine or I/O completion handler [usually intr(D2)]. If the driver (or the kernel) had specified an iodone handler by initializing the b_iodone field of the buf(D4) structure to the address of a function, that function is called with the single argument, bp. Then biodone returns. If an iodone handler had not been specified, biodone sets the B_DONE flag in the b_flags field of the buffer header. Then, if the B_ASYNC flag is set, the buffer is released back to the system. If the B_ASYNC flag is not set, any processes waiting for the I/O to complete are awakened. If the buffer was allocated via getrbuf(D3), the driver must have specified an iodone handler. Level Base or Interrupt. Synchronization Constraints Does not sleep. Driver-defined basic locks, read/write locks, and sleep locks may be held across calls to this function. Examples Generally, the first validation test performed by any block device strategy routine is a check to verify the bounds of the I/O request. If a read request is made for one block beyond the limits of the device (line 8), it will report an end-of-media condition (line 10). Otherwise, if the request is outside the limits of the device, the routine will report an error condition (line 12). In either case, the I/O operation is completed by calling biodone (line 14) and the driver returns. 1 #define RAMDNBLK 1000 /* Number of blocks in RAM disk */ 2 #define RAMDBSIZ 512 /* Number of bytes per block */ 3 char ramdblks[RAMDNBLK][RAMDBSIZ]; /* Array containing RAM disk */ 4 ramdstrategy(bp) 5 struct buf *bp; 6 { 7 daddr_t blkno = bp->b_blkno; 8 if ((blkno < 0) || (blkno >= RAMDNBLK)) { 9 if ((blkno == RAMDNBLK) && (bp->b_flags & B_READ)) { 10 bp->b_resid = bp->b_bcount; /* nothing read */ 11 } else { 12 bioerror(bp, ENXIO); 13 } 14 biodone(bp); 15 return; 16 } . . . On systems where the function bioerror(D3) is not available, line 12 could read: bp->b_error = ENXIO; bp->b_flags |= B_ERROR; REFERENCES bioerror(D3), biowait(D3), brelse(D3), buf(D4), freerbuf(D3), getrbuf(D3), intr(D2), strategy(D2)