fix a `bug' actually just an interface issue, cache last indirect block

to avoid geometrically increasing access time when reading files.
This commit is contained in:
chopps 1994-07-11 05:07:38 +00:00
parent 72d730bdc9
commit 183bffdf36
3 changed files with 33 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: adosfs.h,v 1.4 1994/06/29 06:29:27 cgd Exp $ */
/* $NetBSD: adosfs.h,v 1.5 1994/07/11 05:07:38 chopps Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
@ -65,6 +65,8 @@ struct anode {
u_long extb; /* (f/e) extension block number */
u_long linkto; /* (hd/hf) header this link points at */
u_long linknext; /* (d/f/hd/hf) next link (or head) in chain */
u_long lastlindblk; /* (f/hf) last logical indirect block */
u_long lastindblk; /* (f/hf) last indirect block read */
u_long *tab; /* (r/d) hash table */
int *tabi; /* (r/d) table info */
int ntabent; /* (r/d) number of entries in table */

View File

@ -1,4 +1,4 @@
/* $NetBSD: advfsops.c,v 1.4 1994/06/29 06:29:30 cgd Exp $ */
/* $NetBSD: advfsops.c,v 1.5 1994/07/11 05:07:40 chopps Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
@ -409,6 +409,16 @@ adosfs_vget(mp, an, vpp)
ap->hashf = adoswordn(bp, ap->nwords - 4);
ap->linknext = adoswordn(bp, ap->nwords - 10);
ap->linkto = adoswordn(bp, ap->nwords - 11);
/*
* setup last indirect block cache.
*/
ap->lastlindblk = 0;
if (ap->type == AFILE)
ap->lastindblk = ap->block;
else if (ap->type == ALFILE)
ap->lastindblk = ap->linkto;
if (ap->type == AROOT)
ap->adprot = 0;
else

View File

@ -1,4 +1,4 @@
/* $NetBSD: advnops.c,v 1.8 1994/06/29 06:29:32 cgd Exp $ */
/* $NetBSD: advnops.c,v 1.9 1994/07/11 05:07:41 chopps Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
@ -401,7 +401,7 @@ adosfs_bmap(sp)
{
struct anode *ap;
struct buf *flbp;
long nb, flblk, flblkoff;
long nb, flblk, flblkoff, fcnt;
daddr_t *bnp;
daddr_t bn;
int error;
@ -442,6 +442,17 @@ adosfs_bmap(sp)
flblk = bn / ANODENDATBLKENT(ap);
flbp = NULL;
/*
* check last indirect block cache
*/
if (flblk > ap->lastlindblk)
fcnt = 0;
else {
flblk -= ap->lastlindblk;
fcnt = ap->lastlindblk;
nb = ap->lastindblk;
}
while (flblk >= 0) {
if (flbp)
brelse(flbp);
@ -463,6 +474,12 @@ adosfs_bmap(sp)
error = EINVAL;
goto reterr;
}
/*
* update last indirect block cache
*/
ap->lastlindblk = fcnt++;
ap->lastindblk = nb;
nb = adoswordn(flbp, ap->nwords - 2);
flblk--;
}