--- Net2/sys/buf.h 2018/04/24 18:03:58 1.1 +++ Net2/sys/buf.h 2018/04/24 18:16:55 1.1.1.3 @@ -30,9 +30,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)buf.h 7.11 (Berkeley) 5/9/90 + * from: @(#)buf.h 7.11 (Berkeley) 5/9/90 + * buf.h,v 1.9 1993/07/19 16:39:23 cgd Exp */ +#ifndef _SYS_BUF_H_ +#define _SYS_BUF_H_ + /* * The header for buffers in the buffer pool and otherwise used * to describe a block i/o request is given here. @@ -110,30 +114,43 @@ struct buf #ifdef KERNEL #define BUFHSZ 512 #define RND (MAXBSIZE/DEV_BSIZE) +/* 20 Aug 92 BUFHASH*/ #if ((BUFHSZ&(BUFHSZ-1)) == 0) #define BUFHASH(dvp, dblkno) \ - ((struct buf *)&bufhash[((int)(dvp)+(((int)(dblkno))/RND))&(BUFHSZ-1)]) + ((struct buf *)&bufhash[((int)(dvp)/sizeof(struct vnode)+(int)(dblkno))&(BUFHSZ-1)]) #else #define BUFHASH(dvp, dblkno) \ - ((struct buf *)&bufhash[((int)(dvp)+(((int)(dblkno))/RND)) % BUFHSZ]) + ((struct buf *)&bufhash[((int)(dvp)/sizeof(struct vnode)+(int)(dblkno)) % BUFHSZ]) #endif -struct buf *buf; /* the buffer pool itself */ -char *buffers; -int nbuf; /* number of buffer headers */ -int bufpages; /* number of memory pages in the buffer pool */ -struct buf *swbuf; /* swap I/O headers */ -int nswbuf; -struct bufhd bufhash[BUFHSZ]; /* heads of hash lists */ -struct buf bfreelist[BQUEUES]; /* heads of available lists */ -struct buf bswlist; /* head of free swap header list */ -struct buf *bclnlist; /* head of cleaned page list */ - -struct buf *getblk(); -struct buf *geteblk(); -struct buf *getnewbuf(); +extern struct buf *buf; /* the buffer pool itself */ +extern char *buffers; +extern int nbuf; /* number of buffer headers */ +extern int bufpages; /* number of memory pages in the buffer pool */ +extern struct buf *swbuf; /* swap I/O headers */ +extern int nswbuf; +extern struct bufhd bufhash[BUFHSZ]; /* heads of hash lists */ +extern struct buf bfreelist[BQUEUES]; /* heads of available lists */ +extern struct buf bswlist; /* head of free swap header list */ +extern struct buf *bclnlist; /* head of cleaned page list */ + +void bufinit __P((void)); +int bread __P((struct vnode *, daddr_t, int, struct ucred *, + struct buf **)); +int breada __P((struct vnode *, daddr_t, int, daddr_t, int, + struct ucred *, struct buf **)); +int bwrite __P((struct buf *)); +void bdwrite __P((struct buf *)); +void bawrite __P((struct buf *)); +void brelse __P((struct buf *)); +struct buf *incore __P((struct vnode *, daddr_t)); +struct buf *getblk __P((struct vnode *, daddr_t, int)); +struct buf *geteblk __P((int)); +void allocbuf __P((struct buf *, int)); +int biowait __P((struct buf *)); +void biodone __P((struct buf *)); -unsigned minphys(); +u_int minphys __P((struct buf *)); #endif /* @@ -151,8 +168,8 @@ unsigned minphys(); #define B_ASYNC 0x000100 /* don't wait for I/O completion */ #define B_DELWRI 0x000200 /* write at exit of avail list */ #define B_TAPE 0x000400 /* this is a magtape (no bdwrite) */ -#define B_UAREA 0x000800 /* add u-area to a swap operation */ -#define B_PAGET 0x001000 /* page in/out of page table space */ +#define B_VMPAGE 0x000800 /* buffer from virtual memory */ +#define B_MALLOC 0x001000 /* buffer from malloc space */ #define B_DIRTY 0x002000 /* dirty page to be pushed out async */ #define B_PGIN 0x004000 /* pagein op, so swap() can count it */ #define B_CACHE 0x008000 /* did bread find us in the cache ? */ @@ -205,8 +222,10 @@ unsigned minphys(); * Zero out a buffer's data portion. */ #define clrbuf(bp) { \ - blkclr((bp)->b_un.b_addr, (unsigned)(bp)->b_bcount); \ + bzero((bp)->b_un.b_addr, (unsigned)(bp)->b_bcount); \ (bp)->b_resid = 0; \ } #define B_CLRBUF 0x1 /* request allocated buffer be cleared */ #define B_SYNC 0x2 /* do all allocations synchronously */ + +#endif /* !_SYS_BUF_H_ */