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),
DEPERBLK = RBLOCK / DENTRYSIZ,
OFFPERBLK = RBLOCK / 12,
REFPERBLK = RBLOCK / 3,
REFSIZ = 3,
REFPERBLK = RBLOCK / REFSIZ,
};
struct BufReq {
@ -232,5 +233,4 @@ enum { /* getblk modes */
GBOVERWR = 3,
};
#define HOWMANY(a, b) (((a)+((b)-1))/(b))
#define ROUNDUP(a, b) (HOWMANY(a,b)*(b))
#define HOWMANY(a) (((a)+(RBLOCK-1))/RBLOCK)

View file

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