From: Sean Hinchee <henesy.dev@gmail.com>
To: 9front@9front.org
Subject: [9front] Patch to bring 9front venti libventi up to date with 9legacy
Date: Mon, 17 Sep 2018 15:54:55 -0500 [thread overview]
Message-ID: <CADmmOS-QUQJha_wD+rG1V7gj3pUURGrzdM8RrW=1QtDkm2VnTA@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 194 bytes --]
All,
Attached is a patch to bring venti, libventi, and the affected manual
up to date with some changes in 9legacy.
This should not break anything existing as far as I can tell.
Cheers,
Sean
[-- Attachment #2: ventiupdate.diff --]
[-- Type: text/x-patch, Size: 8856 bytes --]
diff -r 6223c291c7b7 sys/include/venti.h
--- a/sys/include/venti.h Mon Sep 17 18:09:33 2018 +0200
+++ b/sys/include/venti.h Mon Sep 17 15:51:53 2018 -0500
@@ -134,7 +134,8 @@
_VtEntryDir = 1<<1, /* a directory */
_VtEntryDepthShift = 2, /* shift for pointer depth */
_VtEntryDepthMask = 7<<2, /* mask for pointer depth */
- VtEntryLocal = 1<<5 /* for local storage only */
+ VtEntryLocal = 1<<5, /* for local storage only */
+ VtEntryNoArchive = 1<<6 /* for local storage only */
};
enum
{
@@ -334,7 +335,9 @@
};
VtConn* vtconn(int infd, int outfd);
+int vtreconn(VtConn*, int, int);
VtConn* vtdial(char*);
+int vtredial(VtConn*, char*);
void vtfreeconn(VtConn*);
int vtsend(VtConn*, Packet*);
Packet* vtrecv(VtConn*);
@@ -378,6 +381,10 @@
int vtsync(VtConn*);
int vtping(VtConn*);
+/* sha1 */
+void vtsha1(uchar score[VtScoreSize], uchar*, int);
+int vtsha1check(uchar score[VtScoreSize], uchar*, int);
+
/*
* Data blocks and block cache.
*/
diff -r 6223c291c7b7 sys/man/2/venti-conn
--- a/sys/man/2/venti-conn Mon Sep 17 18:09:33 2018 +0200
+++ b/sys/man/2/venti-conn Mon Sep 17 15:51:53 2018 -0500
@@ -28,9 +28,15 @@
VtConn* vtconn(int infd, int outfd)
.PP
.B
+int vtreconn(VtConn *z, int infd, int outfd)
+.PP
+.B
VtConn* vtdial(char *addr)
.PP
.B
+int vtredial(VtConn *z, char *addr)
+.PP
+.B
int vtversion(VtConn *z)
.PP
.B
diff -r 6223c291c7b7 sys/src/cmd/venti/copy.c
--- a/sys/src/cmd/venti/copy.c Mon Sep 17 18:09:33 2018 +0200
+++ b/sys/src/cmd/venti/copy.c Mon Sep 17 15:51:53 2018 -0500
@@ -122,7 +122,7 @@
break;
case VtDirType:
- for(i=0; i<n/VtEntrySize; i++){
+ for(i=0; i*VtEntrySize<n; i++){
if(vtentryunpack(&e, buf, i) < 0){
fprint(2, "warning: could not unpack entry #%d in %V %d\n", i, score, type);
continue;
diff -r 6223c291c7b7 sys/src/cmd/venti/srv/arenas.c
--- a/sys/src/cmd/venti/srv/arenas.c Mon Sep 17 18:09:33 2018 +0200
+++ b/sys/src/cmd/venti/srv/arenas.c Mon Sep 17 15:51:53 2018 -0500
@@ -15,7 +15,8 @@
enum
{
- AHashSize = 512
+ AHashSize = 512,
+ Emergency = 0, /* flag: performing emergency surgery */
};
static AHash *ahash[AHashSize];
@@ -142,8 +143,11 @@
ap->narenas = amn.n;
ap->map = amn.map;
if(okamap(ap->map, ap->narenas, ap->arenabase, ap->size, "arena table") < 0){
- freearenapart(ap, 0);
- return nil;
+ if(!Emergency){
+ freearenapart(ap, 0);
+ return nil;
+ }
+ /* else keep on, for emergency use */
}
ap->arenas = MKNZ(Arena*, ap->narenas);
@@ -152,8 +156,14 @@
ap->arenas[i] = initarena(part, ap->map[i].start, ap->map[i].stop - ap->map[i].start, ap->blocksize);
if(ap->arenas[i] == nil){
seterr(ECorrupt, "%s: %r", ap->map[i].name);
- freearenapart(ap, 1);
- return nil;
+ if(!Emergency){
+ freearenapart(ap, 1);
+ return nil;
+ }else{
+ /* keep on, for emergency use */
+ ap->narenas = i;
+ break;
+ }
}
if(namecmp(ap->map[i].name, ap->arenas[i]->name) != 0){
seterr(ECorrupt, "arena name mismatches with expected name: %s vs. %s",
diff -r 6223c291c7b7 sys/src/cmd/venti/srv/buildindex.c
--- a/sys/src/cmd/venti/srv/buildindex.c Mon Sep 17 18:09:33 2018 +0200
+++ b/sys/src/cmd/venti/srv/buildindex.c Mon Sep 17 15:51:53 2018 -0500
@@ -813,7 +813,7 @@
}
if (nbuf == 0) {
fprint(2, "%s: brand-new index, no work to do\n", argv0);
- exits(0);
+ threadexitsall(0);
}
/* size buffer to use extra memory */
diff -r 6223c291c7b7 sys/src/cmd/venti/srv/conf.rc
--- a/sys/src/cmd/venti/srv/conf.rc Mon Sep 17 18:09:33 2018 +0200
+++ b/sys/src/cmd/venti/srv/conf.rc Mon Sep 17 15:51:53 2018 -0500
@@ -49,7 +49,7 @@
}
dd -quiet 1 -bs 1024 -count 8 -if $disk -iseek 248 \
>/tmp/_venticonf.old || exit backup
- dd -quiet 1 -bs 1024 -count 8 </dev/zero >> /tmp/venticonf.$pid || exit dd
+ dd -quiet 1 -count 2 </dev/zero >> /tmp/venticonf.$pid || exit dd
dd -quiet 1 -bs 1024 -count 8 -if /tmp/venticonf.$pid \
-of $disk -trunc 0 -oseek 248 || exit dd2
exit 0
diff -r 6223c291c7b7 sys/src/cmd/venti/srv/config.c
--- a/sys/src/cmd/venti/srv/config.c Mon Sep 17 18:09:33 2018 +0200
+++ b/sys/src/cmd/venti/srv/config.c Mon Sep 17 15:51:53 2018 -0500
@@ -177,6 +177,10 @@
}
config->vaddr = estrdup(flds[1]);
}else{
+ /*
+ * this is insanely paranoid. a single typo should not
+ * prevent venti from starting.
+ */
seterr(EAdmin, "illegal line '%s' in configuration file %s", line, file);
break;
}
diff -r 6223c291c7b7 sys/src/cmd/venti/srv/dat.h
--- a/sys/src/cmd/venti/srv/dat.h Mon Sep 17 18:09:33 2018 +0200
+++ b/sys/src/cmd/venti/srv/dat.h Mon Sep 17 15:51:53 2018 -0500
@@ -48,7 +48,7 @@
MaxIo = 64*1024, /* max size of a single read or write operation */
ICacheBits = 16, /* default bits for indexing icache */
MaxAMap = 31*1024, /* max. allowed arenas in an address mapping; must be < 32*1024 */
- Unspecified = ~0ul,
+ Unspecified = TWID32,
/*
* return codes from syncarena
diff -r 6223c291c7b7 sys/src/cmd/venti/srv/fixarenas.c
--- a/sys/src/cmd/venti/srv/fixarenas.c Mon Sep 17 18:09:33 2018 +0200
+++ b/sys/src/cmd/venti/srv/fixarenas.c Mon Sep 17 15:51:53 2018 -0500
@@ -61,7 +61,7 @@
* Format number in simplest way that is okay with unittoull.
*/
static int
-Zfmt(Fmt *fmt)
+zfmt(Fmt *fmt)
{
vlong x;
@@ -130,12 +130,12 @@
int i, j, k, n;
if(offset >= partend){
- memset(buf, 0xFB, sizeof buf);
+ memset(buf, 0xFB, len);
return buf;
}
if(offset+len > partend){
- memset(buf, 0xFB, sizeof buf);
+ memset(buf, 0xFB, len);
len = partend - offset;
}
@@ -1894,7 +1894,7 @@
file = argv[0];
ventifmtinstall();
- fmtinstall('Z', Zfmt);
+ fmtinstall('z', zfmt);
fmtinstall('t', tfmt);
quotefmtinstall();
diff -r 6223c291c7b7 sys/src/cmd/venti/srv/unwhack.c
--- a/sys/src/cmd/venti/srv/unwhack.c Mon Sep 17 18:09:33 2018 +0200
+++ b/sys/src/cmd/venti/srv/unwhack.c Mon Sep 17 15:51:53 2018 -0500
@@ -156,8 +156,7 @@
off++;
if(off > d - dst){
- snprint(uw->err, WhackErrLen, "offset out of range: off=%d d=%zd len=%d nbits=%d",
- off, d - dst, len, uwnbits);
+ snprint(uw->err, WhackErrLen, "offset out of range: off=%d d=%zd len=%d nbits=%d", off, d - dst, len, uwnbits);
return -1;
}
if(d + len > dmax){
diff -r 6223c291c7b7 sys/src/libventi/conn.c
--- a/sys/src/libventi/conn.c Mon Sep 17 18:09:33 2018 +0200
+++ b/sys/src/libventi/conn.c Mon Sep 17 15:51:53 2018 -0500
@@ -27,6 +27,28 @@
return z;
}
+int
+vtreconn(VtConn *z, int infd, int outfd)
+{
+ NetConnInfo *nci;
+
+ z->state = VtStateAlloc;
+ if(z->infd >= 0)
+ close(z->infd);
+ z->infd = infd;
+ if(z->outfd >= 0)
+ close(z->outfd);
+ z->outfd = outfd;
+ nci = getnetconninfo(nil, infd);
+ if(nci == nil)
+ snprint(z->addr, sizeof z->addr, "/dev/fd/%d", infd);
+ else{
+ strecpy(z->addr, z->addr+sizeof z->addr, nci->raddr);
+ freenetconninfo(nci);
+ }
+ return 0;
+}
+
void
vtfreeconn(VtConn *z)
{
diff -r 6223c291c7b7 sys/src/libventi/dial.c
--- a/sys/src/libventi/dial.c Mon Sep 17 18:09:33 2018 +0200
+++ b/sys/src/libventi/dial.c Mon Sep 17 15:51:53 2018 -0500
@@ -23,3 +23,21 @@
strecpy(z->addr, z->addr+sizeof z->addr, na);
return z;
}
+
+int
+vtredial(VtConn *z, char *addr)
+{
+ char *na;
+ int fd;
+
+ if(addr == nil)
+ addr = getenv("venti");
+ if(addr == nil)
+ addr = "$venti";
+
+ na = netmkaddr(addr, "tcp", "venti");
+ if((fd = dial(na, nil, nil, nil)) < 0)
+ return fd;
+
+ return vtreconn(z, fd, fd);
+}
diff -r 6223c291c7b7 sys/src/libventi/file.c
--- a/sys/src/libventi/file.c Mon Sep 17 18:09:33 2018 +0200
+++ b/sys/src/libventi/file.c Mon Sep 17 15:51:53 2018 -0500
@@ -503,6 +503,7 @@
VtBlock *b;
int type;
uchar *score;
+ VtEntry oe;
switch(p->type){
case VtDataType:
@@ -530,6 +531,8 @@
if(vtglobaltolocal(b->score) != NilBlock)
return b;
+
+ oe = *e;
/*
* Copy on write.
@@ -597,6 +600,7 @@
shrinkdepth(VtFile *r, VtBlock *p, VtEntry *e, int depth)
{
VtBlock *b, *nb, *ob, *rb;
+ VtEntry oe;
assert(ISLOCKED(r));
assert(depth <= VtPointerDepth);
@@ -604,6 +608,12 @@
rb = vtcacheglobal(r->c, e->score, e->type);
if(rb == nil)
return -1;
+
+ /*
+ * Walk down to the new root block.
+ * We may stop early, but something is better than nothing.
+ */
+ oe = *e;
ob = nil;
b = rb;
diff -r 6223c291c7b7 sys/src/libventi/mkfile
--- a/sys/src/libventi/mkfile Mon Sep 17 18:09:33 2018 +0200
+++ b/sys/src/libventi/mkfile Mon Sep 17 15:51:53 2018 -0500
@@ -24,6 +24,7 @@
scorefmt.$O\
send.$O\
server.$O\
+ sha1.$O\
srvhello.$O\
strdup.$O\
string.$O\
diff -r 6223c291c7b7 sys/src/libventi/rpc.c
--- a/sys/src/libventi/rpc.c Mon Sep 17 18:09:33 2018 +0200
+++ b/sys/src/libventi/rpc.c Mon Sep 17 15:51:53 2018 -0500
@@ -37,7 +37,6 @@
uchar tag, buf[2], *top;
Rwait *r, *rr;
-
if(z == nil){
werrstr("not connected");
packetfree(p);
next reply other threads:[~2018-09-17 20:55 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-17 20:54 Sean Hinchee [this message]
2018-09-17 21:49 cinap_lenrek
2018-09-18 23:22 ` Sean Hinchee
2018-09-18 23:36 cinap_lenrek
2018-09-19 0:34 ` Sean Hinchee
2018-09-19 6:55 ` hiro
2018-09-19 7:00 ` hiro
2018-09-18 23:41 cinap_lenrek
2018-09-19 9:08 cinap_lenrek
2018-09-19 9:11 cinap_lenrek
2018-09-19 10:26 ` hiro
2018-09-19 12:29 cinap_lenrek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CADmmOS-QUQJha_wD+rG1V7gj3pUURGrzdM8RrW=1QtDkm2VnTA@mail.gmail.com' \
--to=henesy.dev@gmail.com \
--cc=9front@9front.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).