--- ray/src/hd/holofile.c 1999/01/09 09:16:14 3.33 +++ ray/src/hd/holofile.c 1999/02/10 17:09:20 3.37 @@ -13,8 +13,12 @@ static char SCCSid[] = "$SunId$ SGI"; #include "holo.h" #ifndef CACHESIZE -#define CACHESIZE 16 /* default cache size (Mbytes, 0==inf) */ +#ifdef BIGMEM +#define CACHESIZE 32 /* default cache size (Mbytes, 0==inf) */ +#else +#define CACHESIZE 12 #endif +#endif #ifndef FREEBEAMS #define FREEBEAMS 1500 /* maximum beams to free at a time */ #endif @@ -187,7 +191,7 @@ memerr: } -markdirty(hp, i) /* mark holodeck directory position dirty */ +hdmarkdirty(hp, i) /* mark holodeck directory position dirty */ register HOLO *hp; int i; { @@ -199,7 +203,7 @@ int i; if (lseek(hp->fd, biglob(hp)->fo+(i-1)*sizeof(BEAMI), 0) < 0 || write(hp->fd, (char *)&smudge, sizeof(BEAMI)) != sizeof(BEAMI)) - error(SYSTEM, "seek/write error in markdirty"); + error(SYSTEM, "seek/write error in hdmarkdirty"); hp->dirseg[0].s = i; hp->dirseg[0].n = 1; return; @@ -554,7 +558,7 @@ int i; } biglob(hp)->nrd -= bi->nrd; /* tell fragment it's free */ bi->nrd = 0; - bi->fo = 0; + bi->fo = 0L; return(1); } @@ -644,8 +648,9 @@ register int i; hp->bi[i].fo = nfo; } else hp->bi[i].fo = 0L; - biglob(hp)->nrd += hp->bi[i].nrd = nrays; - markdirty(hp, i); /* section directory now out of date */ + biglob(hp)->nrd += nrays - hp->bi[i].nrd; + hp->bi[i].nrd = nrays; + hdmarkdirty(hp, i); /* section directory now out of date */ return(1); } @@ -666,10 +671,14 @@ register int i; if (hdfragl[hp->fd].writerr) /* check for file error */ return(0); if (i == 0) { /* clear entire holodeck */ + if (blglob(hp)->nrm == 0) + return(0); /* already clear */ nchanged = 0; for (i = nbeams(hp); i > 0; i--) if (hp->bl[i] != NULL) nchanged += hdfreebeam(hp, i); + DCHECK(blglob(hp)->nrm != 0, + CONSISTENCY, "bad beam count in hdfreebeam"); return(nchanged); } DCHECK(i < 1 | i > nbeams(hp), @@ -701,7 +710,10 @@ register int i; return(nchanged); } if (i == 0) { /* clobber entire holodeck */ + if (biglob(hp)->nrd == 0 & blglob(hp)->nrm == 0) + return(0); /* already empty */ nchanged = 0; + nchanged = 0; for (i = nbeams(hp); i > 0; i--) if (hp->bi[i].nrd > 0 || hp->bl[i] != NULL) nchanged += hdkillbeam(hp, i); @@ -719,6 +731,7 @@ register int i; if (hp->bi[i].nrd) { if (hdfragflags&FF_KILL) hdfreefrag(hp, i); + biglob(hp)->nrd -= hp->bi[i].nrd; hp->bi[i].nrd = 0; /* make sure it's gone */ hp->bi[i].fo = 0L; } @@ -816,8 +829,7 @@ register HOLO *hp; /* NULL means clean up all */ return; } /* flush all data and free memory */ - hdfreebeam(hp, 0); - hdsync(hp, 0); + hdflush(hp); /* release fragment resources */ hdrelease(hp->fd); /* remove hp from active list */