4500: /* 4501: * Each buffer in the pool is usually doubly linked into 2 lists: 4502: * the device with which it is currently associated (always) 4503: * and also on a list of blocks available for allocation 4504: * for other use (usually). 4505: * The latter list is kept in last-used order, and the two 4506: * lists are doubly linked to make it easy to remove 4507: * a buffer from one list when it was found by 4508: * looking through the other. 4509: * A buffer is on the available list, and is liable 4510: * to be reassigned to another disk block, if and only 4511: * if it is not marked BUSY. When a buffer is busy, the 4512: * available-list pointers can be used for other purposes. 4513: * Most drivers use the forward ptr as a link in their I/O 4514: * active queue. 4515: * A buffer header contains all the information required 4516: * to perform I/O. 4517: * Most of the routines which manipulate these things 4518: * are in bio.c. 4519: */ 4520: struct buf 4521: { 4522: int b_flags; /* see defines below */ 4523: struct buf *b_forw; /* headed by devtab of b_dev */ 4524: struct buf *b_back; /* " */ 4525: struct buf *av_forw; /* position on free list, */ 4526: struct buf *av_back; /* if not BUSY*/ 4527: int b_dev; /* major+minor device name */ 4528: int b_wcount; /* transfer count (usu. words) */ 4529: char *b_addr; /* low order core address */ 4530: char *b_xmem; /* high order core address */ 4531: char *b_blkno; /* block # on device */ 4532: char b_error; /* returned after I/O */ 4533: char *b_resid; /* words not transferred after error */ 4534: 4535: } buf[NBUF]; 4536: /* --------------------------- */ 4537: 4538: /* 4539: * Each block device has a devtab, which contains private state stuff 4540: * and 2 list heads: the b_forw/b_back list, which is doubly linked 4541: * and has all the buffers currently associated with that major 4542: * device; and the d_actf/d_actl list, which is private to the 4543: * device but in fact is always used for the head and tail 4544: * of the I/O queue for the device. 4545: * Various routines in bio.c look at b_forw/b_back 4546: * (notice they are the same as in the buf structure) 4547: * but the rest is private to each device driver. 4548: * 4549: */ 4550: 4551: struct devtab 4552: { 4553: char d_active; /* busy flag */ 4554: char d_errcnt; /* error count (for recovery) */ 4555: struct buf *b_forw; /* first buffer for this dev */ 4556: struct buf *b_back; /* last buffer for this dev */ 4557: struct buf *d_actf; /* head of I/O queue */ 4558: struct buf *d_actl; /* tail of I/O queue */ 4559: }; 4560: /* --------------------------- */ 4561: 4562: /* 4563: * This is the head of the queue of available 4564: * buffers-- all unused except for the 2 list heads. 4565: */ 4566: struct buf bfreelist; 4567: 4568: /* 4569: * These flags are kept in b_flags. 4570: */ 4571: #define B_WRITE 0 /* non-read pseudo-flag */ 4572: #define B_READ 01 /* read when I/O occurs */ 4573: #define B_DONE 02 /* transaction finished */ 4574: #define B_ERROR 04 /* transaction aborted */ 4575: #define B_BUSY 010 /* not on av_forw/back list */ 4576: #define B_PHYS 020 /* Physical IO potentially using UNIBUS map */ 4577: 4578: #define B_MAP 040 /* This block has the UNIBUS map allocated */ 4579: 4580: #define B_WANTED 0100 /* issue wakeup when BUSY goes off */ 4581: 4582: #define B_RELOC 0200 /* no longer used */ 4583: #define B_ASYNC 0400 /* don't wait for I/O completion */ 4584: 4585: #define B_DELWRI 01000 /* don't write till block leaves available list */