|
|
1.1 ! root 1: /* ! 2: * The header for buffers in the buffer pool and otherwise used ! 3: * to describe a block i/o request is given here. The routines ! 4: * which manipulate these things are given in bio.c. ! 5: * ! 6: * Each buffer in the pool is usually doubly linked into 2 lists: ! 7: * hashed into a chain by <dev,blkno> so it can be located in the cache, ! 8: * and (usually) on (one of several) queues. These lists are circular and ! 9: * doubly linked for easy removal. ! 10: * ! 11: * There are currently three queues for buffers: ! 12: * one for buffers which must be kept permanently (super blocks) ! 13: * one for buffers containing ``useful'' information (the cache) ! 14: * one for buffers containing ``non-useful'' information ! 15: * (and empty buffers, pushed onto the front) ! 16: * The latter two queues contain the buffers which are available for ! 17: * reallocation, are kept in lru order. When not on one of these queues, ! 18: * the buffers are ``checked out'' to drivers which use the available list ! 19: * pointers to keep track of them in their i/o active queues. ! 20: */ ! 21: ! 22: /* ! 23: * Bufhd structures used at the head of the hashed buffer queues. ! 24: * We only need three words for these, so this abbreviated ! 25: * definition saves some space. ! 26: */ ! 27: struct bufhd ! 28: { ! 29: long b_flags; /* see defines below */ ! 30: struct buf *b_forw, *b_back; /* fwd/bkwd pointer in chain */ ! 31: }; ! 32: struct buf ! 33: { ! 34: long b_flags; /* too much goes here to describe */ ! 35: struct buf *b_forw, *b_back; /* hash chain (2 way street) */ ! 36: struct buf *av_forw, *av_back; /* position on free list if not BUSY */ ! 37: #define b_actf av_forw /* alternate names for driver queue */ ! 38: #define b_actl av_back /* head - isn't history wonderful */ ! 39: long b_bcount; /* transfer count */ ! 40: #define b_active b_bcount /* driver queue head: drive active */ ! 41: short b_error; /* returned after I/O */ ! 42: dev_t b_dev; /* major+minor device name */ ! 43: union { ! 44: caddr_t b_addr; /* low order core address */ ! 45: int *b_words; /* words for clearing */ ! 46: struct filsys *b_filsys; /* superblocks */ ! 47: struct dinode *b_dino; /* ilist */ ! 48: daddr_t *b_daddr; /* indirect block */ ! 49: } b_un; ! 50: daddr_t b_blkno; /* block # on device */ ! 51: long b_resid; /* words not transferred after error */ ! 52: #define b_errcnt b_resid /* while i/o in progress: # retries */ ! 53: #define b_pfcent b_resid /* garbage: don't ask */ ! 54: struct proc *b_proc; /* proc doing physical or swap I/O */ ! 55: }; ! 56: ! 57: #define BQUEUES 3 /* number of free buffer queues */ ! 58: #define BQ_LOCKED 0 /* super-blocks &c */ ! 59: #define BQ_LRU 1 /* lru, useful buffers */ ! 60: #define BQ_AGE 2 /* rubbish */ ! 61: ! 62: #ifdef KERNEL ! 63: struct buf *buf; /* the buffer pool itself */ ! 64: char *buffers; ! 65: int nbuf; ! 66: struct buf *swbuf; /* swap I/O headers */ ! 67: int nswbuf; ! 68: short *swsize; ! 69: int *swpf; ! 70: struct buf bfreelist[BQUEUES]; /* heads of available lists */ ! 71: struct buf bswlist; /* head of free swap header list */ ! 72: struct buf *bclnlist; /* head of cleaned page list */ ! 73: ! 74: struct buf *alloc(); ! 75: struct buf *baddr(); ! 76: struct buf *getblk(); ! 77: struct buf *geteblk(); ! 78: struct buf *bread(); ! 79: struct buf *breada(); ! 80: ! 81: unsigned minphys(); ! 82: #endif ! 83: ! 84: /* ! 85: * These flags are kept in b_flags. ! 86: */ ! 87: #define B_WRITE 0x000000 /* non-read pseudo-flag */ ! 88: #define B_READ 0x000001 /* read when I/O occurs */ ! 89: #define B_DONE 0x000002 /* transaction finished */ ! 90: #define B_ERROR 0x000004 /* transaction aborted */ ! 91: #define B_BUSY 0x000008 /* not on av_forw/back list */ ! 92: #define B_PHYS 0x000010 /* physical IO */ ! 93: #define B_HDR 0x000020 /* was B_MAP, now ioctl */ ! 94: #define B_WANTED 0x000040 /* issue wakeup when BUSY goes off */ ! 95: #define B_AGE 0x000080 /* delayed write for correct aging */ ! 96: #define B_ASYNC 0x000100 /* don't wait for I/O completion */ ! 97: #define B_DELWRI 0x000200 /* write at exit of avail list */ ! 98: #define B_TAPE 0x000400 /* this is a magtape (no bdwrite) */ ! 99: #define B_UAREA 0x000800 /* add u-area to a swap operation */ ! 100: #define B_PAGET 0x001000 /* page in/out of page table space */ ! 101: #define B_DIRTY 0x002000 /* dirty page to be pushed out async */ ! 102: #define B_PGIN 0x004000 /* pagein op, so swap() can count it */ ! 103: #define B_CACHE 0x008000 /* did bread find us in the cache ? */ ! 104: #define B_INVAL 0x010000 /* does not contain valid info */ ! 105: #define B_LOCKED 0x020000 /* locked in core (not reusable) */ ! 106: #define B_HEAD 0x040000 /* a buffer header, not a buffer */ ! 107: #define B_SPARE1 0x080000 ! 108: #define B_BAD 0x100000 /* bad block revectoring in progress */ ! 109: #define B_SPARE2 0xe00000 ! 110: #define B_PRI 0xff000000 /* i/o priority */ ! 111: ! 112: #define B_PRISHIFT 24
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.