~kris/9p

9hist

c2555390a7adf239b7bf436567e1e8d330473daf — David du Colombier 28 years ago 726d181
Plan 9 from Bell Labs 1998-09-22
3 files changed, 45 insertions(+), 20 deletions(-)

M pc/devata.c
M port/qio.c
M port/sysfile.c
M pc/devata.c => pc/devata.c +5 -4
@@ 1825,7 1825,8 @@ atapiexec(Drive *dp)
		nexterror();

	if(cp->status & Serr){
		DPRINT("%s: Bad packet command %ux, error %ux\n", dp->vol, cp->cmdblk[0], cp->error);
		DPRINT("%s: Bad packet command 0x%ux, error 0x%ux\n",
			dp->vol, cp->cmdblk[0], cp->error);
		error(Eio);
	}
}


@@ 1985,7 1986,7 @@ atapipart(Drive *dp)
	retrycount = 2;
retry:
	if(waserror()){
		DPRINT("atapipart: cmd %uX error %uX\n", cp->cmdblk[0], cp->error);
		DPRINT("atapipart: cmd 0x%uX error 0x%uX\n", cp->cmdblk[0], cp->error);
		if((cp->status & Serr) && (cp->error & 0xF0) == 0x60){
			dp->vers++;
			if(retrycount){


@@ 2015,7 2016,7 @@ retry:
	cp->cmdblk[4] = 18;
	atapiexec(dp);
	if(cp->count != 18){
		print("cmd=%2.2uX, lastcmd=%2.2uX ", cp->cmd, cp->lastcmd);
		print("cmd=0x%2.2uX, lastcmd=0x%2.2uX ", cp->cmd, cp->lastcmd);
		print("cdsize count %d, status 0x%2.2uX, error 0x%2.2uX\n",
			cp->count, cp->status, cp->error);
		error(Eio);


@@ 2027,7 2028,7 @@ retry:
	cp->cmdblk[0] = Ccapacity;
	atapiexec(dp);
	if(cp->count != 8){
		print("cmd=%2.2uX, lastcmd=%2.2uX ", cp->cmd, cp->lastcmd);
		print("cmd=0x%2.2uX, lastcmd=0x%2.2uX ", cp->cmd, cp->lastcmd);
		print("cdsize count %d, status 0x%2.2uX, error 0x%2.2uX\n",
			cp->count, cp->status, cp->error);
		error(Eio);

M port/qio.c => port/qio.c +22 -11
@@ 35,7 35,8 @@ struct Queue
	Block*	bfirst;		/* buffer */
	Block*	blast;

	int	len;		/* bytes in queue */
	int	len;		/* bytes allocated to queue */
	int	dlen;		/* data bytes in queue */
	int	limit;		/* max bytes in queue */
	int	inilim;		/* initial limit */
	int	state;


@@ 531,6 532,7 @@ qget(Queue *q)
	q->bfirst = b->next;
	b->next = 0;
	q->len -= BALLOC(b);
	q->dlen -= BLEN(b);
	QDEBUG checkb(b, "qget");

	/* if writer flow controlled, restart */


@@ 568,10 570,12 @@ qdiscard(Queue *q, int len)
			q->bfirst = b->next;
			b->next = 0;
			q->len -= BALLOC(b);
			q->dlen -= BLEN(b);
			freeb(b);
		} else {
			n = len - sofar;
			b->rp += n;
			q->dlen -= n;
		}
	}



@@ 625,6 629,7 @@ qconsume(Queue *q, void *vp, int len)
	if((q->state & Qmsg) || len == n)
		q->bfirst = b->next;
	b->rp += len;
	q->dlen -= len;

	/* if writer flow controlled, restart */
	if((q->state & Qflow) && q->len < q->limit/2){


@@ 643,6 648,7 @@ qconsume(Queue *q, void *vp, int len)
	if((q->state & Qmsg) || len == n){
		b->next = 0;
		q->len -= BALLOC(b);
		q->dlen -= BLEN(b);
		freeb(b);
	}
	return len;


@@ 651,7 657,7 @@ qconsume(Queue *q, void *vp, int len)
int
qpass(Queue *q, Block *b)
{
	int len, dowakeup;
	int dlen, len, dowakeup;

	/* sync with qread */
	dowakeup = 0;


@@ 668,14 674,17 @@ qpass(Queue *q, Block *b)
	else
		q->bfirst = b;
	len = BALLOC(b);
	dlen = BLEN(b);
	QDEBUG checkb(b, "qpass");
	while(b->next){
		b = b->next;
		QDEBUG checkb(b, "qpass");
		len += BALLOC(b);
		dlen += BLEN(b);
	}
	q->blast = b;
	q->len += len;
	q->dlen += dlen;

	if(q->len >= q->limit/2)
		q->state |= Qflow;


@@ 696,7 705,7 @@ checkqlen(q);
int
qpassnolim(Queue *q, Block *b)
{
	int len, dowakeup;
	int dlen, len, dowakeup;

	/* sync with qread */
	dowakeup = 0;


@@ 708,14 717,17 @@ qpassnolim(Queue *q, Block *b)
	else
		q->bfirst = b;
	len = BALLOC(b);
	dlen = BLEN(b);
	QDEBUG checkb(b, "qpass");
	while(b->next){
		b = b->next;
		QDEBUG checkb(b, "qpass");
		len += BALLOC(b);
		dlen += BLEN(b);
	}
	q->blast = b;
	q->len += len;
	q->dlen += dlen;

	if(q->len >= q->limit/2)
		q->state |= Qflow;


@@ 792,6 804,7 @@ qproduce(Queue *q, void *vp, int len)
	q->blast = b;
	/* b->next = 0; done by iallocb() */
	q->len += BALLOC(b);
	q->dlen += BLEN(b);
	QDEBUG checkb(b, "qproduce");

	if(q->state & Qstarve){


@@ 935,6 948,7 @@ qbread(Queue *q, int len)
	q->bfirst = b->next;
	b->next = 0;
	n = BLEN(b);
	q->dlen -= n;
	q->len -= BALLOC(b);
	QDEBUG checkb(b, "qbread 1");



@@ 962,6 976,7 @@ qbread(Queue *q, int len)
				q->blast = b;
			q->bfirst = b;
			q->len += BALLOC(b);
			q->dlen += n;
		}
		nb->wp = nb->rp + len;
	}


@@ 1018,7 1033,6 @@ qbwrite(Queue *q, Block *b)

	dowakeup = 0;
	n = BLEN(b);

	qlock(&q->wlock);
	if(waserror()){
		qunlock(&q->wlock);


@@ 1058,6 1072,7 @@ qbwrite(Queue *q, Block *b)
	q->blast = b;
	b->next = 0;
	q->len += BALLOC(b);
	q->dlen += n;
	QDEBUG checkb(b, "qbwrite");

	if(q->state & Qstarve){


@@ 1147,6 1162,7 @@ qiwrite(Queue *q, void *vp, int len)
			q->bfirst = b;
		q->blast = b;
		q->len += BALLOC(b);
		q->dlen += n;

		if(q->state & Qstarve){
			q->state &= ~Qstarve;


@@ 1251,13 1267,7 @@ qreopen(Queue *q)
int
qlen(Queue *q)
{
	int len;
	Block *b;

	len = 0;
	for(b = q->bfirst; b; b= b->next)
		len += BLEN(b);
	return len;
	return q->dlen;
}

/*


@@ 1314,6 1324,7 @@ qflush(Queue *q)
	bfirst = q->bfirst;
	q->bfirst = 0;
	q->len = 0;
	q->dlen = 0;
	iunlock(q);

	/* free queued blocks */

M port/sysfile.c => port/sysfile.c +18 -5
@@ 378,14 378,15 @@ sysread(ulong *arg)
	long n;
	Chan *c;

	validaddr(arg[1], arg[2], 1);
	n = arg[2];
	validaddr(arg[1], n, 1);
	c = fdtochan(arg[0], OREAD, 1, 1);

	if(waserror()) {
		cclose(c);
		nexterror();
	}

	n = arg[2];
	dir = c->qid.path&CHDIR;

	if(dir) {


@@ 443,24 444,36 @@ long
syswrite(ulong *arg)
{
	Chan *c;
	long n;
	long m, n;
	uvlong oo;

	validaddr(arg[1], arg[2], 0);
	n = arg[2];
	c = fdtochan(arg[0], OWRITE, 1, 1);
	if(waserror()) {
		cclose(c);
		lock(c);
		c->offset -= n;
		unlock(c);
		nexterror();
	}

	if(c->qid.path & CHDIR)
		error(Eisdir);

	n = devtab[c->type]->write(c, (void*)arg[1], arg[2], c->offset);

	lock(c);
	oo = c->offset;
	c->offset += n;
	unlock(c);

	m = devtab[c->type]->write(c, (void*)arg[1], n, oo);

	if(m < n){
		lock(c);
		c->offset = oo + m;
		unlock(c);
	}

	poperror();
	cclose(c);