Kernel Functions for Drivers biodone(9F)
NAME
biodone - release buffer after buffer I/O transfer and
notify blocked threads
SYNOPSIS
#include
#include
void biodone(struct buf *bp);
INTERFACE LEVEL
Architecture independent level 1 (DI/DKI).
PARAMETERS
bp Pointer to a buf(9S) structure.
DESCRIPTION
The biodone() function notifies blocked processes waiting
for the I/O to complete, sets the BDONE flag in the bflags
field of the buf(9S) structure, and releases the buffer if
the I/O is asynchronous. biodone() is called by either the
driver interrupt or strategy(9E) routines when a buffer I/O
request is complete.
The biodone() function provides the capability to call a
completion routine if bp describes a kernel buffer. The
address of the routine is specified in the biodone field of
the buf(9S) structure. If such a routine is specified,
biodone() calls it and returns without performing any other
actions. Otherwise, it performs the steps above.
CONTEXT
The biodone() function can be called from user, interrupt,
or kernel context.
EXAMPLES
Generally, the first validation test performed by any block
device strategy(9E) routine is a check for an end-of-file
(EOF) condition. The strategy(9E) routine is responsible for
determining an EOF condition when the device is accessed
directly. If a read(2) request is made for one block beyond
the limits of the device (line 10), it will report an EOF
condition. Otherwise, if the request is outside the limits
of the device, the routine will report an error condition.
In either case, report the I/O operation as complete (line
27).
SunOS 5.11 Last change: 16 Jan 2006 1
Kernel Functions for Drivers biodone(9F)
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
5 static int
6 ramdstrategy(struct buf *bp)
7 {
8 daddrt blkno = bp->bblkno; /* get block number */
9
10 if ((blkno < 0) (blkno >= RAMDNBLK)) {
11 /*
12 * If requested block is outside RAM disk
13 * limits, test for EOF which could result
14 * from a direct (physio) request.
15 */
16 if ((blkno == RAMDNBLK) && (bp->bflags & BREAD)) {
17 /*
18 * If read is for block beyond RAM disk
19 * limits, mark EOF condition.
20 */
21 bp->bresid = bp->bbcount; /* compute return value */
22
23 } else { /* I/O attempt is beyond */
24 bp->berror = ENXIO; /* limits of RAM disk */
25 bp->bflags = BEROR; /* return error */
26 }
27 biodone(bp); /* mark I/O complete (BDONE) */
28 /*
29 * Wake any processes awaiting this I/O
30 * or release buffer for asynchronous
31 * (BASYNC) request.
32 */
33 return (0);
34 }
...
SEE ALSO
read(2), strategy(9E), biowait(9F), ddiaddintr(9F),
delay(9F), timeout(9F), untimeout(9F), buf(9S)
Writing Device Drivers
WARNINGS
After calling biodone(), bp is no longer available to be
referred to by the driver. If the driver makes any reference
to bp after calling biodone(), a panic may result.
NOTES
Drivers that use the biodone field of the buf(9S) structure
to specify a substitute completion routine should save the
SunOS 5.11 Last change: 16 Jan 2006 2
Kernel Functions for Drivers biodone(9F)
value of biodone before changing it, and then restore the
old value before calling biodone() to release the buffer.
SunOS 5.11 Last change: 16 Jan 2006 3
|