home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Trees / V7 / usr / sys / h / buf.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-03  |  2.6 KB  |  73 lines

  1. /*
  2.  * Each buffer in the pool is usually doubly linked into 2 lists:
  3.  * the device with which it is currently associated (always)
  4.  * and also on a list of blocks available for allocation
  5.  * for other use (usually).
  6.  * The latter list is kept in last-used order, and the two
  7.  * lists are doubly linked to make it easy to remove
  8.  * a buffer from one list when it was found by
  9.  * looking through the other.
  10.  * A buffer is on the available list, and is liable
  11.  * to be reassigned to another disk block, if and only
  12.  * if it is not marked BUSY.  When a buffer is busy, the
  13.  * available-list pointers can be used for other purposes.
  14.  * Most drivers use the forward ptr as a link in their I/O
  15.  * active queue.
  16.  * A buffer header contains all the information required
  17.  * to perform I/O.
  18.  * Most of the routines which manipulate these things
  19.  * are in bio.c.
  20.  */
  21. struct buf
  22. {
  23.     int    b_flags;        /* see defines below */
  24.     struct    buf *b_forw;        /* headed by d_tab of conf.c */
  25.     struct    buf *b_back;        /*  "  */
  26.     struct    buf *av_forw;        /* position on free list, */
  27.     struct    buf *av_back;        /*     if not BUSY*/
  28.     dev_t    b_dev;            /* major+minor device name */
  29.     unsigned b_bcount;        /* transfer count */
  30.     union {
  31.         caddr_t b_addr;        /* low order core address */
  32.         int    *b_words;        /* words for clearing */
  33.         struct filsys *b_filsys;    /* superblocks */
  34.         struct dinode *b_dino;    /* ilist */
  35.         daddr_t *b_daddr;        /* indirect block */
  36.     } b_un;
  37.     daddr_t    b_blkno;        /* block # on device */
  38.     char    b_xmem;            /* high order core address */
  39.     char    b_error;        /* returned after I/O */
  40.     unsigned int b_resid;        /* words not transferred after error */
  41. };
  42.  
  43. extern struct buf buf[];        /* The buffer pool itself */
  44. extern struct buf bfreelist;        /* head of available list */
  45.  
  46. /*
  47.  * These flags are kept in b_flags.
  48.  */
  49. #define    B_WRITE    0    /* non-read pseudo-flag */
  50. #define    B_READ    01    /* read when I/O occurs */
  51. #define    B_DONE    02    /* transaction finished */
  52. #define    B_ERROR    04    /* transaction aborted */
  53. #define    B_BUSY    010    /* not on av_forw/back list */
  54. #define    B_PHYS    020    /* Physical IO potentially using UNIBUS map */
  55. #define    B_MAP    040    /* This block has the UNIBUS map allocated */
  56. #define    B_WANTED 0100    /* issue wakeup when BUSY goes off */
  57. #define    B_AGE    0200    /* delayed write for correct aging */
  58. #define    B_ASYNC    0400    /* don't wait for I/O completion */
  59. #define    B_DELWRI 01000    /* don't write till block leaves available list */
  60. #define    B_TAPE 02000    /* this is a magtape (no bdwrite) */
  61. #define    B_PBUSY    04000
  62. #define    B_PACK    010000
  63.  
  64. /*
  65.  * special redeclarations for
  66.  * the head of the queue per
  67.  * device driver.
  68.  */
  69. #define    b_actf    av_forw
  70. #define    b_actl    av_back
  71. #define    b_active b_bcount
  72. #define    b_errcnt b_resid
  73.