From 16413e9598efb10f70872d60c3658e05cda5497a Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Tue, 22 Feb 1994 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1994-02-22 --- pc/devhard.c | 30 ++++++++++++++++---------- port/alloc.c | 4 ++-- port/portdat.h | 2 ++ port/portfns.h | 2 +- port/qio.c | 57 +++++++++++++++++++++++++++++++------------------- 5 files changed, 59 insertions(+), 36 deletions(-) diff --git a/pc/devhard.c b/pc/devhard.c index a147643089a90dbffe4d45def7b82dd84235c050..193474ccf6052503f7b716ce884f9ebc2d756628 100644 --- a/pc/devhard.c +++ b/pc/devhard.c @@ -99,6 +99,7 @@ struct Drive Repl repl; ulong usetime; int state; + char vol[NAMELEN]; ulong cap; /* total bytes */ int bytes; /* bytes/sector */ @@ -165,7 +166,7 @@ hardgen(Chan *c, Dirtab *tab, long ntab, long s, Dir *dirp) return 0; pp = &dp->p[s]; - sprint(name, "hd%d%s", drive, pp->name); + sprint(name, "%s%s", dp->vol, pp->name); name[NAMELEN] = 0; qid.path = MKQID(drive, s); l = (pp->end - pp->start) * dp->bytes; @@ -854,6 +855,8 @@ hardpart(Drive *dp) int i; char *buf; + sprint(dp->vol, "hd%d", dp - hard); + /* * we always have a partition for the whole disk * and one for the partition table @@ -907,16 +910,21 @@ hardpart(Drive *dp) if(n && strncmp(line[0], PARTMAGIC, sizeof(PARTMAGIC)-1) == 0){ for(i = 1; i < n; i++){ pp++; - if(getfields(line[i], field, 3, ' ') != 3) - break; - strncpy(pp->name, field[0], NAMELEN); - if(strncmp(pp->name, "repl", NAMELEN) == 0) - dp->repl.p = pp; - pp->start = strtoul(field[1], 0, 0); - pp->end = strtoul(field[2], 0, 0); - if(pp->start > pp->end || pp->start >= dp->p[0].end) - break; - dp->npart++; + switch(getfields(line[i], field, 3, ' ')) { + case 2: + if(strcmp(field[0], "unit") == 0) + strncpy(dp->vol, field[1], NAMELEN); + break; + case 3: + strncpy(pp->name, field[0], NAMELEN); + if(strncmp(pp->name, "repl", NAMELEN) == 0) + dp->repl.p = pp; + pp->start = strtoul(field[1], 0, 0); + pp->end = strtoul(field[2], 0, 0); + if(pp->start > pp->end || pp->start >= dp->p[0].end) + break; + dp->npart++; + } } } free(buf); diff --git a/port/alloc.c b/port/alloc.c index ae8975f42e2405ceb109a082b9e991dad7df059b..c81c1f620813aaada7a0d6b7f0f6e3ada20202c1 100644 --- a/port/alloc.c +++ b/port/alloc.c @@ -274,7 +274,7 @@ good: unlock(&arena); if(bp->magic != 0) - panic("malloc"); + panic("malloc %lux %lux", bp->magic, bp->pc); bp->magic = Magic2n; bp->pc = getcallerpc(((uchar*)&size) - sizeof(size)); @@ -368,7 +368,7 @@ free(void *ptr) bp = (Bucket*)((ulong)ptr - bdatoff); if(bp->magic != Magic2n) - panic("free"); + panic("free %lux %lux", bp->magic, bp->pc); bp->magic = 0; lock(&arena); diff --git a/port/portdat.h b/port/portdat.h index b7084a5a68a828425f66593efdef150217af7cd3..b7280027f996df7fc40b470f3c07edf177077af4 100644 --- a/port/portdat.h +++ b/port/portdat.h @@ -657,6 +657,8 @@ enum SCSIread = 0, SCSIwrite, + + SCSImaxxfer = 1024*1024, }; /* diff --git a/port/portfns.h b/port/portfns.h index 68ad0e3ec5735db1a32129e5670c9dfcb61830a6..7c4937f27ad6f8e5928045f1481159a9e4a3ce72 100644 --- a/port/portfns.h +++ b/port/portfns.h @@ -214,7 +214,7 @@ void schedinit(void); int screenbits(void); void screenupdate(void); int scsiexec(Target*, int, uchar*, int, void*, int); -int scsiinv(int, int, Target**, uchar**, int*, int*); +int scsiinv(int, int, Target**, uchar**, char*); long seconds(void); ulong segattach(Proc*, ulong, char *, ulong, ulong); void segpage(Segment*, Page*); diff --git a/port/qio.c b/port/qio.c index 491faa4b387b17ee833fe41e8608bd720d39e1a0..ed61333d924012a98f118c033c330462363a4f2d 100644 --- a/port/qio.c +++ b/port/qio.c @@ -96,6 +96,21 @@ enum Qflow= (1<<3), }; +void +checkb(Block *b, char *msg) +{ + if(b->base > b->lim) + panic("checkb 0 %s %lux %lux", msg, b->base, b->lim); + if(b->rp < b->base) + panic("checkb 1 %s %lux %lux", msg, b->base, b->rp); + if(b->wp < b->base) + panic("checkb 2 %s %lux %lux", msg, b->base, b->wp); + if(b->rp > b->lim) + panic("checkb 3 %s %lux %lux", msg, b->rp, b->lim); + if(b->wp > b->lim) + panic("checkb 4 %s %lux %lux", msg, b->wp, b->lim); +} + void poison(Block *b) { @@ -310,7 +325,6 @@ allocb(int size) b->rp = b->base; b->wp = b->base; b->lim = ((uchar*)b) + size; - b->flag = 0; return b; } @@ -335,6 +349,7 @@ qconsume(Queue *q, void *vp, int len) unlock(q); return -1; } +checkb(b, "qconsume 1"); n = BLEN(b); if(n < len) @@ -342,8 +357,7 @@ qconsume(Queue *q, void *vp, int len) memmove(p, b->rp, len); if((q->state & Qmsg) || len == n) q->bfirst = b->next; - else - b->rp += len; + b->rp += len; q->len -= len; /* if writer flow controlled, restart */ @@ -358,6 +372,7 @@ qconsume(Queue *q, void *vp, int len) if(dowakeup) wakeup(&q->wr); +checkb(b, "qconsume 2"); /* discard the block if we're done with it */ if((q->state & Qmsg) || len == n) { poison(b); @@ -403,26 +418,21 @@ qproduce(Queue *q, void *vp, int len) } /* save in buffer */ - b = q->bfirst; - if((q->state & Qmsg) == 0 && b && b->lim - b->wp <= len){ - memmove(b->wp, p, len); - b->wp += len; - b->flag |= Bfilled; - } else { - b = iallocb(len); - if(b == 0){ - unlock(q); - return -2; - } - memmove(b->wp, p, len); - b->wp += len; - if(q->bfirst) - q->blast->next = b; - else - q->bfirst = b; - q->blast = b; + b = iallocb(len); + if(b == 0){ + unlock(q); + return -2; } + memmove(b->wp, p, len); + b->wp += len; + if(q->bfirst) + q->blast->next = b; + else + q->bfirst = b; + q->blast = b; q->len += len; +checkb(b, "qproduce"); + if(q->state & Qstarve){ q->state &= ~Qstarve; dowakeup = 1; @@ -542,6 +552,7 @@ qread(Queue *q, void *vp, int len) sleep(&q->rr, notempty, q); } } +checkb(b, "qread 1"); /* remove a buffered block */ q->bfirst = b->next; @@ -563,6 +574,7 @@ qread(Queue *q, void *vp, int len) memmove(p, b->rp, n); b->rp += n; +checkb(b, "qread 2"); /* free it or put what's left on the queue */ if(b->rp >= b->wp || (q->state&Qmsg)) { poison(b); @@ -663,7 +675,8 @@ qwrite(Queue *q, void *vp, int len, int nowait) splx(x); error(Ehungup); } - + +checkb(b, "qwrite"); if(q->syncbuf){ /* we guessed wrong and did an extra copy */ if(n > q->synclen)