hjfs: Clear all refs to zero when reaming.

And a couple clarity/formatting changes
This commit is contained in:
spew 2017-03-21 14:07:18 -05:00
parent 1e2d95a803
commit 8dd9f0e970
2 changed files with 7 additions and 8 deletions

View file

@ -80,7 +80,8 @@ enum {
DENTRYSIZ = NAMELEN + 4 * sizeof(ushort) + 13 + (3 + NDIRECT + NINDIRECT) * sizeof(uvlong), DENTRYSIZ = NAMELEN + 4 * sizeof(ushort) + 13 + (3 + NDIRECT + NINDIRECT) * sizeof(uvlong),
DEPERBLK = RBLOCK / DENTRYSIZ, DEPERBLK = RBLOCK / DENTRYSIZ,
OFFPERBLK = RBLOCK / 12, OFFPERBLK = RBLOCK / 12,
REFPERBLK = RBLOCK / 3, REFSIZ = 3,
REFPERBLK = RBLOCK / REFSIZ,
}; };
struct BufReq { struct BufReq {
@ -232,5 +233,4 @@ enum { /* getblk modes */
GBOVERWR = 3, GBOVERWR = 3,
}; };
#define HOWMANY(a, b) (((a)+((b)-1))/(b)) #define HOWMANY(a) (((a)+(RBLOCK-1))/RBLOCK)
#define ROUNDUP(a, b) (HOWMANY(a,b)*(b))

View file

@ -106,8 +106,7 @@ getfree(Fs *fs, uvlong *r)
b->refs[j] = 1; b->refs[j] = 1;
*r = l; *r = l;
have = 1; have = 1;
} }else if(nbsend(fs->freelist, &l) <= 0)
else if(nbsend(fs->freelist, &l) <= 0)
goto found; goto found;
} }
if(have) if(have)
@ -259,7 +258,7 @@ ream(Fs *fs)
b->sb.size = d->size; b->sb.size = d->size;
b->sb.fstart = SUPERBLK + 1; b->sb.fstart = SUPERBLK + 1;
fs->fstart = b->sb.fstart; fs->fstart = b->sb.fstart;
b->sb.fend = b->sb.fstart + HOWMANY(b->sb.size * 3, RBLOCK); b->sb.fend = b->sb.fstart + HOWMANY(b->sb.size * REFSIZ);
b->sb.qidpath = DUMPROOTQID + 1; b->sb.qidpath = DUMPROOTQID + 1;
firsti = b->sb.fstart + SUPERBLK / REFPERBLK; firsti = b->sb.fstart + SUPERBLK / REFPERBLK;
lasti = b->sb.fstart + b->sb.fend / REFPERBLK; lasti = b->sb.fstart + b->sb.fend / REFPERBLK;
@ -267,7 +266,7 @@ ream(Fs *fs)
c = getbuf(d, i, TREF, 1); c = getbuf(d, i, TREF, 1);
if(c == nil) if(c == nil)
goto err; goto err;
memset(c->refs, 0, sizeof(b->data)); memset(c->refs, 0, sizeof(c->refs));
if(i >= firsti && i <= lasti){ if(i >= firsti && i <= lasti){
j = 0; j = 0;
je = REFPERBLK; je = REFPERBLK;
@ -760,7 +759,7 @@ trunc(Fs *fs, FLoc *ll, Buf *bd, uvlong size)
return -1; return -1;
if(size >= d->size) if(size >= d->size)
goto done; goto done;
blk = HOWMANY(size, RBLOCK); blk = HOWMANY(size);
while(blk < NDIRECT){ while(blk < NDIRECT){
if(d->db[blk] != 0){ if(d->db[blk] != 0){
putfree(fs, d->db[blk]); putfree(fs, d->db[blk]);