diff options
Diffstat (limited to 'src/cmd')
-rw-r--r-- | src/cmd/vac/file.c | 34 | ||||
-rw-r--r-- | src/cmd/vac/pack.c | 2 | ||||
-rw-r--r-- | src/cmd/vac/unvac.c | 2 | ||||
-rw-r--r-- | src/cmd/vac/vac.c | 14 | ||||
-rw-r--r-- | src/cmd/vac/vac.h | 6 | ||||
-rw-r--r-- | src/cmd/vac/vacfs.c | 37 | ||||
-rw-r--r-- | src/cmd/venti/copy.c | 6 | ||||
-rw-r--r-- | src/cmd/venti/dump.c | 6 | ||||
-rw-r--r-- | src/cmd/venti/read.c | 6 | ||||
-rw-r--r-- | src/cmd/venti/root.c | 4 | ||||
-rw-r--r-- | src/cmd/venti/srv/dat.h | 6 | ||||
-rw-r--r-- | src/cmd/venti/write.c | 6 |
12 files changed, 98 insertions, 31 deletions
diff --git a/src/cmd/vac/file.c b/src/cmd/vac/file.c index faa558f3..bf17ea38 100644 --- a/src/cmd/vac/file.c +++ b/src/cmd/vac/file.c @@ -1730,7 +1730,7 @@ Err1: static char EBadVacFormat[] = "bad format for vac file"; static VacFs * -vacfsalloc(VtConn *z, int bsize, int ncache, int mode) +vacfsalloc(VtConn *z, int bsize, ulong cachemem, int mode) { VacFs *fs; @@ -1738,7 +1738,7 @@ vacfsalloc(VtConn *z, int bsize, int ncache, int mode) fs->z = z; fs->bsize = bsize; fs->mode = mode; - fs->cache = vtcachealloc(z, bsize, ncache); + fs->cache = vtcachealloc(z, cachemem); return fs; } @@ -1767,7 +1767,7 @@ readscore(int fd, uchar score[VtScoreSize]) } VacFs* -vacfsopen(VtConn *z, char *file, int mode, int ncache) +vacfsopen(VtConn *z, char *file, int mode, ulong cachemem) { int fd; uchar score[VtScoreSize]; @@ -1788,11 +1788,11 @@ vacfsopen(VtConn *z, char *file, int mode, int ncache) } close(fd); } - return vacfsopenscore(z, score, mode, ncache); + return vacfsopenscore(z, score, mode, cachemem); } VacFs* -vacfsopenscore(VtConn *z, u8int *score, int mode, int ncache) +vacfsopenscore(VtConn *z, u8int *score, int mode, ulong cachemem) { VacFs *fs; int n; @@ -1818,13 +1818,19 @@ vacfsopenscore(VtConn *z, u8int *score, int mode, int ncache) return nil; } - fs = vacfsalloc(z, rt.blocksize, ncache, mode); + fs = vacfsalloc(z, rt.blocksize, cachemem, mode); memmove(fs->score, score, VtScoreSize); fs->mode = mode; memmove(e.score, rt.score, VtScoreSize); e.gen = 0; + + // Don't waste cache memory on directories + // when rt.blocksize is large. e.psize = (rt.blocksize/VtEntrySize)*VtEntrySize; + if(e.psize > 60000) + e.psize = (60000/VtEntrySize)*VtEntrySize; + e.dsize = rt.blocksize; e.type = VtDirType; e.flags = VtEntryActive; @@ -1925,7 +1931,7 @@ vacfsclose(VacFs *fs) * Create a fresh vac fs. */ VacFs * -vacfscreate(VtConn *z, int bsize, int ncache) +vacfscreate(VtConn *z, int bsize, ulong cachemem) { VacFs *fs; VtFile *f; @@ -1937,18 +1943,24 @@ vacfscreate(VtConn *z, int bsize, int ncache) MetaEntry me; int psize; - if((fs = vacfsalloc(z, bsize, ncache, VtORDWR)) == nil) + if((fs = vacfsalloc(z, bsize, cachemem, VtORDWR)) == nil) return nil; - + /* * Fake up an empty vac fs. */ psize = bsize/VtEntrySize*VtEntrySize; + if(psize > 60000) + psize = 60000/VtEntrySize*VtEntrySize; +fprint(2, "create bsize %d psize %d\n", bsize, psize); + f = vtfilecreateroot(fs->cache, psize, bsize, VtDirType); + if(f == nil) + sysfatal("vtfilecreateroot: %r"); vtfilelock(f, VtORDWR); - + /* Write metablock containing root directory VacDir. */ - b = vtcacheallocblock(fs->cache, VtDataType); + b = vtcacheallocblock(fs->cache, VtDataType, bsize); mbinit(&mb, b->data, bsize, bsize/BytesPerEntry); memset(&vd, 0, sizeof vd); vd.elem = "/"; diff --git a/src/cmd/vac/pack.c b/src/cmd/vac/pack.c index 9777464f..5555cc0e 100644 --- a/src/cmd/vac/pack.c +++ b/src/cmd/vac/pack.c @@ -77,7 +77,7 @@ mbunpack(MetaBlock *mb, uchar *p, int n) magic = U32GET(p); if(magic != MetaMagic && magic != MetaMagic+1) { - werrstr("bad meta block magic"); + werrstr("bad meta block magic %#08ux", magic); return -1; } mb->size = U16GET(p+4); diff --git a/src/cmd/vac/unvac.c b/src/cmd/vac/unvac.c index ab799cb0..8b2b290d 100644 --- a/src/cmd/vac/unvac.c +++ b/src/cmd/vac/unvac.c @@ -94,7 +94,7 @@ threadmain(int argc, char *argv[]) if(vtconnect(conn) < 0) sysfatal("vtconnect: %r"); - fs = vacfsopen(conn, argv[0], VtOREAD, 128); + fs = vacfsopen(conn, argv[0], VtOREAD, 4<<20); if(fs == nil) sysfatal("vacfsopen: %r"); diff --git a/src/cmd/vac/vac.c b/src/cmd/vac/vac.c index d6c17b4b..bf5118b4 100644 --- a/src/cmd/vac/vac.c +++ b/src/cmd/vac/vac.c @@ -100,8 +100,6 @@ threadmain(int argc, char **argv) u = unittoull(EARGF(usage())); if(u < 512) u = 512; - if(u > VtMaxLumpSize) - u = VtMaxLumpSize; blocksize = u; break; case 'd': @@ -170,10 +168,10 @@ threadmain(int argc, char **argv) if((outfd = create(archivefile, OWRITE, 0666)) < 0) sysfatal("create %s: %r", archivefile); atexit(removevacfile); // because it is new - if((fs = vacfscreate(z, blocksize, 512)) == nil) + if((fs = vacfscreate(z, blocksize, 4<<20)) == nil) sysfatal("vacfscreate: %r"); }else{ - if((fs = vacfsopen(z, archivefile, VtORDWR, 512)) == nil) + if((fs = vacfsopen(z, archivefile, VtORDWR, 4<<20)) == nil) sysfatal("vacfsopen %s: %r", archivefile); if((fdiff = recentarchive(fs, oldpath)) != nil){ if(verbose) @@ -213,7 +211,7 @@ threadmain(int argc, char **argv) else if((outfd = create(vacfile, OWRITE, 0666)) < 0) sysfatal("create %s: %r", vacfile); atexit(removevacfile); - if((fs = vacfscreate(z, blocksize, 512)) == nil) + if((fs = vacfscreate(z, blocksize, 4<<20)) == nil) sysfatal("vacfscreate: %r"); f = vacfsgetroot(fs); @@ -450,7 +448,7 @@ void vac(VacFile *fp, VacFile *diffp, char *name, Dir *d) { char *elem, *s; - static char buf[65536]; + static char *buf; int fd, i, n, bsize; vlong off; Dir *dk; // kids @@ -541,6 +539,8 @@ vac(VacFile *fp, VacFile *diffp, char *name, Dir *d) }else{ off = 0; bsize = fs->bsize; + if(buf == nil) + buf = vtmallocz(bsize); if(fdiff){ /* * Copy fdiff's contents into f by moving the score. @@ -708,7 +708,7 @@ vacmerge(VacFile *fp, char *name) if(strlen(name) < 4 || strcmp(name+strlen(name)-4, ".vac") != 0) return -1; - if((mfs = vacfsopen(z, name, VtOREAD, 100)) == nil) + if((mfs = vacfsopen(z, name, VtOREAD, 4<<20)) == nil) return -1; if(verbose) fprint(2, "merging %s\n", name); diff --git a/src/cmd/vac/vac.h b/src/cmd/vac/vac.h index cb599a9c..0edd41e4 100644 --- a/src/cmd/vac/vac.h +++ b/src/cmd/vac/vac.h @@ -97,9 +97,9 @@ struct VacFs VtCache *cache; }; -VacFs *vacfsopen(VtConn *z, char *file, int mode, int ncache); -VacFs *vacfsopenscore(VtConn *z, u8int *score, int mode, int ncache); -VacFs *vacfscreate(VtConn *z, int bsize, int ncache); +VacFs *vacfsopen(VtConn *z, char *file, int mode, ulong cachemem); +VacFs *vacfsopenscore(VtConn *z, u8int *score, int mode, ulong cachemem); +VacFs *vacfscreate(VtConn *z, int bsize, ulong cachemem); void vacfsclose(VacFs *fs); int vacfssync(VacFs *fs); int vacfssnapshot(VacFs *fs, char *src, char *dst); diff --git a/src/cmd/vac/vacfs.c b/src/cmd/vac/vacfs.c index 5c65cf3b..ad72098f 100644 --- a/src/cmd/vac/vacfs.c +++ b/src/cmd/vac/vacfs.c @@ -118,6 +118,31 @@ notifyf(void *a, char *s) noted(NDFLT); } +#define TWID64 ~(u64int)0 +static u64int +unittoull(char *s) +{ + char *es; + u64int n; + + if(s == nil) + return TWID64; + n = strtoul(s, &es, 0); + if(*es == 'k' || *es == 'K'){ + n *= 1024; + es++; + }else if(*es == 'm' || *es == 'M'){ + n *= 1024*1024; + es++; + }else if(*es == 'g' || *es == 'G'){ + n *= 1024*1024*1024; + es++; + } + if(*es != '\0') + return TWID64; + return n; +} + void threadmain(int argc, char *argv[]) { @@ -125,10 +150,10 @@ threadmain(int argc, char *argv[]) int p[2], fd; int stdio; char *host = nil; - long ncache; + ulong mem; + mem = 16<<20; stdio = 0; - ncache = 256; fmtinstall('H', encodefmt); fmtinstall('V', vtscorefmt); fmtinstall('F', vtfcallfmt); @@ -140,9 +165,6 @@ threadmain(int argc, char *argv[]) fmtinstall('F', fcallfmt); dflag = 1; break; - case 'c': - ncache = atoi(EARGF(usage())); - break; case 'i': defmnt = nil; stdio = 1; @@ -158,6 +180,9 @@ threadmain(int argc, char *argv[]) case 's': defsrv = "vacfs"; break; + case 'M': + mem = unittoull(EARGF(usage())); + break; case 'm': defmnt = EARGF(usage()); break; @@ -206,7 +231,7 @@ threadmain(int argc, char *argv[]) if(vtconnect(conn) < 0) sysfatal("vtconnect: %r"); - fs = vacfsopen(conn, argv[0], VtOREAD, ncache); + fs = vacfsopen(conn, argv[0], VtOREAD, mem); if(fs == nil) sysfatal("vacfsopen: %r"); diff --git a/src/cmd/venti/copy.c b/src/cmd/venti/copy.c index 7e03b56c..4a05e053 100644 --- a/src/cmd/venti/copy.c +++ b/src/cmd/venti/copy.c @@ -4,6 +4,12 @@ #include <libsec.h> #include <thread.h> +enum +{ + // XXX What to do here? + VtMaxLumpSize = 65536, +}; + int changes; int rewrite; int ignoreerrors; diff --git a/src/cmd/venti/dump.c b/src/cmd/venti/dump.c index 8481303a..c148b866 100644 --- a/src/cmd/venti/dump.c +++ b/src/cmd/venti/dump.c @@ -5,6 +5,12 @@ #include <libsec.h> #include <thread.h> +enum +{ + // XXX What to do here? + VtMaxLumpSize = 65536, +}; + VtConn *z; char *host; diff --git a/src/cmd/venti/read.c b/src/cmd/venti/read.c index a48e62e6..4883c1d7 100644 --- a/src/cmd/venti/read.c +++ b/src/cmd/venti/read.c @@ -4,6 +4,12 @@ #include <libsec.h> #include <thread.h> +enum +{ + // XXX What to do here? + VtMaxLumpSize = 65536, +}; + void usage(void) { diff --git a/src/cmd/venti/root.c b/src/cmd/venti/root.c index 5d67ad31..d41d44bc 100644 --- a/src/cmd/venti/root.c +++ b/src/cmd/venti/root.c @@ -38,7 +38,7 @@ threadmain(int argc, char *argv[]) if(argc == 0) usage(); - buf = vtmallocz(VtMaxLumpSize); + buf = vtmallocz(8192); z = vtdial(host); if(z == nil) @@ -52,7 +52,7 @@ threadmain(int argc, char *argv[]) fprint(2, "cannot parse score '%s': %r\n", argv[i]); continue; } - n = vtread(z, score, VtRootType, buf, VtMaxLumpSize); + n = vtread(z, score, VtRootType, buf, 8192); if(n < 0){ fprint(2, "could not read block %V: %r\n", score); continue; diff --git a/src/cmd/venti/srv/dat.h b/src/cmd/venti/srv/dat.h index b0b942b8..7b2bf49d 100644 --- a/src/cmd/venti/srv/dat.h +++ b/src/cmd/venti/srv/dat.h @@ -37,6 +37,12 @@ typedef struct Bloom Bloom; enum { + /* + * formerly fundamental constant, + * now a server-imposed limitation. + */ + VtMaxLumpSize = 56*1024, + ABlockLog = 9, /* log2(512), the quantum for reading arenas */ ANameSize = 64, MaxDiskBlock = 64*1024, /* max. allowed size for a disk block */ diff --git a/src/cmd/venti/write.c b/src/cmd/venti/write.c index c11a5a31..d627cae7 100644 --- a/src/cmd/venti/write.c +++ b/src/cmd/venti/write.c @@ -4,6 +4,12 @@ #include <libsec.h> #include <thread.h> +enum +{ + // XXX What to do here? + VtMaxLumpSize = 65536, +}; + void usage(void) { |