shithub: riscv

Download patch

ref: 8dd9f0e97096abb6ad42c8751b336d8be6dba969
parent: 1e2d95a8038346d38f1cebeabe0ad64ea874b7fe
author: spew <devnull@localhost>
date: Tue Mar 21 10:07:18 EDT 2017

hjfs: Clear all refs to zero when reaming.
And a couple clarity/formatting changes

--- a/sys/src/cmd/hjfs/dat.h
+++ b/sys/src/cmd/hjfs/dat.h
@@ -80,7 +80,8 @@
 	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 @@
 	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)
--- a/sys/src/cmd/hjfs/fs1.c
+++ b/sys/src/cmd/hjfs/fs1.c
@@ -106,8 +106,7 @@
 					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 @@
 	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 @@
 		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 @@
 		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]);