cwfs: store newcache format option in config

This commit is contained in:
cinap_lenrek 2011-06-11 14:19:07 +00:00
parent 54e72f3e9c
commit 67bb0a2c7a
4 changed files with 16 additions and 14 deletions

View file

@ -451,6 +451,8 @@ mergeconf(Iobuf *p)
} else if(strcmp(word, "readonly") == 0){
if(!readonlyset)
readonly = 1;
} else if(strcmp(word, "newcache") == 0){
conf.newcache = 1;
} else if(strcmp(word, "ipauth") == 0) /* obsolete */
cp = getwrd(word, cp);
else if(astrcmp(word, "ip") == 0) /* obsolete */
@ -595,6 +597,8 @@ start:
cp = seprint(cp, ep, "noauth\n");
if(readonly)
cp = seprint(cp, ep, "readonly\n");
if(conf.newcache)
cp = seprint(cp, ep, "newcache\n");
for (fsp = fspar; fsp->name != nil; fsp++)
cp = seprint(cp, ep, "%s %ld\n",
fsp->name, fsp->declared);

View file

@ -84,8 +84,6 @@ static char* cwnames[] =
[Orele] "rele",
};
int oldcachefmt = 1;
Centry* getcentry(Bucket*, Off);
int cwio(Device*, Off, void*, int);
void cmd_cwcmd(int, char*[]);
@ -302,10 +300,10 @@ dumpblock(Device *dev)
return 0;
found:
if (oldcachefmt)
a = a*CEPERBK + (c - b->entry) + caddr;
else
if (conf.newcache)
a += (c - b->entry)*msize + caddr;
else
a = a*CEPERBK + (c - b->entry) + caddr;
p1 = getbuf(devnone, Cwdump1, 0);
count = 0;
@ -562,10 +560,10 @@ cwio(Device *dev, Off addr, void *buf, int opcode)
bn = addr % h->msize;
a1 = h->maddr + bn/BKPERBLK;
if (oldcachefmt)
a2 = bn*CEPERBK + h->caddr;
else
if (conf.newcache)
a2 = bn + h->caddr;
else
a2 = bn*CEPERBK + h->caddr;
max = h->wmax;
putbuf(cb);
@ -583,10 +581,10 @@ cwio(Device *dev, Off addr, void *buf, int opcode)
cw->cdev, (Wideoff)a1);
return Cerror;
}
if (oldcachefmt)
a2 += c - b->entry;
else
if (conf.newcache)
a2 += (c - b->entry) * h->msize;
else
a2 += c - b->entry;
state = c->state;
switch(opcode) {

View file

@ -3,8 +3,6 @@
#include "io.h"
#include "9p1.h"
extern int oldcachefmt;
Map *devmap;
Biobuf bin;
@ -293,6 +291,7 @@ main(int argc, char **argv)
formatinit();
machinit();
conf.confdev = "/dev/sdC0/fscache";
conf.newcache = 0;
ARGBEGIN{
case 'a': /* announce on this net */
@ -318,7 +317,7 @@ main(int argc, char **argv)
open("#c/cons", OWRITE);
break;
case 'C': /* use new, faster cache layout */
oldcachefmt = 0;
conf.newcache = 1;
break;
case 'c':
conf.configfirst++;

View file

@ -436,6 +436,7 @@ struct Conf
uchar nodump; /* no periodic dumps */
uchar dumpreread; /* read and compare in dump copy */
uchar newcache;
};
enum {