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 4540 * state stuff and 2 list heads: the b_forw/b_back list, 4541 * which is doubly linked and has all the buffers currently 4542 * associated with that major device; 4543 * and the d_actf/d_actl list, which is private to the 4544 * device but in fact is always used for the head and tail 4545 * of the I/O queue for the device. 4546 * Various routines in bio.c look at b_forw/b_back 4547 * (notice they are the same as in the buf structure) 4548 * but the rest is private to each device driver. 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 4567 struct buf bfreelist; 4568 4569 /* 4570 * These flags are kept in b_flags. 4571 */ 4572 #define B_WRITE 0 /* non-read pseudo-flag */ 4573 #define B_READ 01 /* read when I/O occurs */ 4574 #define B_DONE 02 /* transaction finished */ 4575 #define B_ERROR 04 /* transaction aborted */ 4576 #define B_BUSY 010 /* not on av_forw/back list */ 4577 #define B_PHYS 020 /* Physical IO potentially using UNIBUS map */ 4578 4579 #define B_MAP 040 /* This block has the UNIBUS map allocated */ 4580 4581 #define B_WANTED 0100 /* issue wakeup when BUSY goes off */ 4582 4583 #define B_RELOC 0200 /* no longer used */ 4584 #define B_ASYNC 0400 /* don't wait for I/O completion */ 4585 4586 #define B_DELWRI 01000 /* don't write till block leaves available list */ 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599