biodone(D3DK) —
NAME
biodone − release buffer after block I/O and wakeup processes .IX \f4biodone\fP(D3DK)
SYNOPSIS
#include <sys/types.h>
#include <sys/buf.h>
void biodone(buf_t ∗bp);
ARGUMENTS
bpPointer to the buffer header structure.
DESCRIPTION
The biodone function is called by the driver when a block I/O request is complete. It is usually called from the driver’s strategy(D2DK) routine or I/O completion handler [usually intr(D2DK)].
If the driver had specified an iodone handler by initializing the b_iodone field of the buf(D4DK) structure to the address of a function, that function is called with the single parameter, bp. Then biodone returns.
If the driver had not specified an iodone handler, biodone will release the buffer back to the system. If there were any processes waiting for the I/O to complete, or for the buffer to be released, one is awakened.
RETURN VALUE
None.
LEVEL
Base or Interrupt.
NOTES
Does not sleep.
Driver-defined basic locks, read/write locks, and sleep locks may be held across calls to this function.
If the buffer was allocated via getrbuf(D3DK), the driver must have specified an iodone handler.
SEE ALSO
intr(D2DK), strategy(D2DK), biowait(D3DK), brelse(D3DK), freerbuf(D3DK), getrbuf(D3DK), buf(D4DK)
EXAMPLE
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)
5register struct buf ∗bp;
6 {
7register daddr_t blkno = bp->b_blkno;
8if ((blkno < 0) || (blkno >= RAMDNBLK)) {
9if ((blkno == RAMDNBLK) && (bp->b_flags & B_READ)) {
10bp->b_resid = bp->b_bcount;/∗ nothing read ∗/
11} else {
12bioerror(bp, ENXIO);
13}
14biodone(bp);
15return;
16}
. . .
DDI/DKI