|
|
1.1 ! root 1: /* buf.h 4.1 11/9/80 */ ! 2: ! 3: /* ! 4: * Each buffer in the pool is usually doubly linked into 2 lists: ! 5: * the device with which it is currently associated (always) ! 6: * and also on a list of blocks available for allocation ! 7: * for other use (usually). ! 8: * The latter list is kept in last-used order, and the two ! 9: * lists are doubly linked to make it easy to remove ! 10: * a buffer from one list when it was found by ! 11: * looking through the other. ! 12: * A buffer is on the available list, and is liable ! 13: * to be reassigned to another disk block, if and only ! 14: * if it is not marked BUSY. When a buffer is busy, the ! 15: * available-list pointers can be used for other purposes. ! 16: * Most drivers use the forward ptr as a link in their I/O ! 17: * active queue. ! 18: * A buffer header contains all the information required ! 19: * to perform I/O. ! 20: * Most of the routines which manipulate these things ! 21: * are in bio.c. ! 22: */ ! 23: struct buf ! 24: { ! 25: int b_flags; /* see defines below */ ! 26: struct buf *b_forw; /* headed by d_tab of conf.c */ ! 27: struct buf *b_back; /* " */ ! 28: struct buf *av_forw; /* position on free list, */ ! 29: struct buf *av_back; /* if not BUSY*/ ! 30: dev_t b_dev; /* major+minor device name */ ! 31: unsigned b_bcount; /* transfer count */ ! 32: union { ! 33: caddr_t b_addr; /* low order core address */ ! 34: int *b_words; /* words for clearing */ ! 35: struct filsys *b_filsys; /* superblocks */ ! 36: struct dinode *b_dino; /* ilist */ ! 37: daddr_t *b_daddr; /* indirect block */ ! 38: } b_un; ! 39: daddr_t b_blkno; /* block # on device */ ! 40: char b_xmem; /* high order core address */ ! 41: char b_error; /* returned after I/O */ ! 42: short b_hlink; /* hash links for buffer cache */ ! 43: unsigned int b_resid; /* words not transferred after error */ ! 44: struct proc *b_proc; /* process doing physical or swap I/O */ ! 45: }; ! 46: ! 47: #ifdef KERNEL ! 48: extern struct buf buf[]; /* The buffer pool itself */ ! 49: extern struct buf swbuf[]; /* swap I/O headers */ ! 50: extern struct buf bfreelist; /* head of available list */ ! 51: extern struct buf bswlist; /* head of free swap header list */ ! 52: extern struct buf *bclnlist; /* head of cleaned page list */ ! 53: ! 54: struct buf *alloc(); ! 55: struct buf *baddr(); ! 56: struct buf *getblk(); ! 57: struct buf *geteblk(); ! 58: struct buf *bread(); ! 59: struct buf *breada(); ! 60: ! 61: unsigned minphys(); ! 62: #endif ! 63: ! 64: #define NSWBUF 48 /* number of swap I/O headers */ ! 65: ! 66: /* ! 67: * These flags are kept in b_flags. ! 68: */ ! 69: #define B_WRITE 0x0000 /* non-read pseudo-flag */ ! 70: #define B_READ 0x0001 /* read when I/O occurs */ ! 71: #define B_DONE 0x0002 /* transaction finished */ ! 72: #define B_ERROR 0x0004 /* transaction aborted */ ! 73: #define B_BUSY 0x0008 /* not on av_forw/back list */ ! 74: #define B_PHYS 0x0010 /* physical IO */ ! 75: #define B_MAP 0x0020 /* UNIBUS map allocated */ ! 76: #define B_WANTED 0x0040 /* issue wakeup when BUSY goes off */ ! 77: #define B_AGE 0x0080 /* delayed write for correct aging */ ! 78: #define B_ASYNC 0x0100 /* don't wait for I/O completion */ ! 79: #define B_DELWRI 0x0200 /* write at exit of avail list */ ! 80: #define B_TAPE 0x0400 /* this is a magtape (no bdwrite) */ ! 81: #define B_UAREA 0x0800 /* add u-area to a swap operation */ ! 82: #define B_PAGET 0x1000 /* page in/out of page table space */ ! 83: #define B_DIRTY 0x2000 /* dirty page to be pushed out async */ ! 84: #define B_PGIN 0x4000 /* pagein op, so swap() can count it */ ! 85: #define B_CACHE 0x8000 /* did bread find us in the cache ? */ ! 86: ! 87: /* ! 88: * special redeclarations for ! 89: * the head of the queue per ! 90: * device driver. ! 91: */ ! 92: #define b_actf av_forw ! 93: #define b_actl av_back ! 94: #define b_active b_bcount ! 95: #define b_errcnt b_resid ! 96: #define b_pfcent b_resid
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.