-/* vfs_cluster.c 4.42 83/04/04 */
-
-#include "../machine/pte.h"
-
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/buf.h"
-#include "../h/conf.h"
-#include "../h/proc.h"
-#include "../h/seg.h"
-#include "../h/vm.h"
-#include "../h/trace.h"
-
-/*
- * Read in (if necessary) the block and return a buffer pointer.
- */
-struct buf *
-bread(dev, blkno, size)
- dev_t dev;
- daddr_t blkno;
- int size;
-{
- register struct buf *bp;
-
- if (size == 0)
- panic("bread: size 0");
- bp = getblk(dev, blkno, size);
- if (bp->b_flags&B_DONE) {
- trace(TR_BREADHIT, dev, blkno);
- return(bp);
- }
- bp->b_flags |= B_READ;
- if (bp->b_bcount > bp->b_bufsize)
- panic("bread");
- (*bdevsw[major(dev)].d_strategy)(bp);
- trace(TR_BREADMISS, dev, blkno);
- u.u_ru.ru_inblock++; /* pay for read */
- biowait(bp);
- return(bp);
-}
-
-/*
- * Read in the block, like bread, but also start I/O on the
- * read-ahead block (which is not allocated to the caller)
- */
-struct buf *
-breada(dev, blkno, size, rablkno, rabsize)
- dev_t dev;
- daddr_t blkno; int size;
- daddr_t rablkno; int rabsize;
-{
- register struct buf *bp, *rabp;
-
- bp = NULL;
- /*
- * If the block isn't in core, then allocate
- * a buffer and initiate i/o (getblk checks
- * for a cache hit).
- */
- if (!incore(dev, blkno)) {
- bp = getblk(dev, blkno, size);
- if ((bp->b_flags&B_DONE) == 0) {
- bp->b_flags |= B_READ;
- if (bp->b_bcount > bp->b_bufsize)
- panic("breada");
- (*bdevsw[major(dev)].d_strategy)(bp);
- trace(TR_BREADMISS, dev, blkno);
- u.u_ru.ru_inblock++; /* pay for read */
- } else
- trace(TR_BREADHIT, dev, blkno);
- }
-
- /*
- * If there's a read-ahead block, start i/o
- * on it also (as above).
- */
- if (rablkno && !incore(dev, rablkno)) {
- rabp = getblk(dev, rablkno, rabsize);
- if (rabp->b_flags & B_DONE) {
- brelse(rabp);
- trace(TR_BREADHITRA, dev, blkno);
- } else {
- rabp->b_flags |= B_READ|B_ASYNC;
- if (rabp->b_bcount > rabp->b_bufsize)
- panic("breadrabp");
- (*bdevsw[major(dev)].d_strategy)(rabp);
- trace(TR_BREADMISSRA, dev, rablock);
- u.u_ru.ru_inblock++; /* pay in advance */
- }
- }
-
- /*
- * If block was in core, let bread get it.
- * If block wasn't in core, then the read was started
- * above, and just wait for it.
- */
- if (bp == NULL)
- return (bread(dev, blkno, size));
- biowait(bp);
- return (bp);
-}
-
-/*
- * Write the buffer, waiting for completion.
- * Then release the buffer.