From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=DATE_IN_PAST_12_24, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.4 Received: (qmail 19262 invoked from network); 8 Jun 2022 20:58:36 -0000 Received: from 9front.inri.net (168.235.81.73) by inbox.vuxu.org with ESMTPUTF8; 8 Jun 2022 20:58:36 -0000 Received: from mimir.eigenstate.org ([206.124.132.107]) by 9front; Wed Jun 8 16:57:10 -0400 2022 Received: from abbatoir.myfiosgateway.com (pool-74-108-56-225.nycmny.fios.verizon.net [74.108.56.225]) by mimir.eigenstate.org (OpenSMTPD) with ESMTPSA id e7a689ae (TLSv1.2:ECDHE-RSA-AES256-SHA:256:NO) for <9front@9front.org>; Wed, 8 Jun 2022 13:56:58 -0700 (PDT) Message-ID: <2088FA55C2CBA08C664E567D6272A812@eigenstate.org> From: Ori Bernstein Date: Tue, 07 Jun 2022 22:38:04 +0000 To: 9front@9front.org MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: managed session browser framework module Subject: [9front] [PATCH] cwfs: fix iounit negotiation Reply-To: 9front@9front.org Precedence: bulk cwfs had an issue with iounit negotiation as a result of the conversion to 9p2000 -- with the move to variable size messages, the fixed message overhead decreased, but the advertised message size was still adding the old fixed overhead. This meant that if the kernel negotiated the maximum io size, cwfs would negotiate something larger than it supported, and would hang up when an io of that size was made. In addition, the size of messages was stored in a short, which means that negotiating an iounit larger than 16384 bytes would overflow the message count, and cause things to fall over. Finally, whle we're here, we clean up some duplicated and unused constants. --- diff 1b5ea51ee1203952900fafc0def48985d900f7a7 73cfaf9d694f927adf89c44e0cc7ad25df15bbdf --- a/sys/src/cmd/cwfs/9p2.c +++ b/sys/src/cmd/cwfs/9p2.c @@ -1,8 +1,5 @@ #include "all.h" -#include -enum { MSIZE = MAXDAT+MAXMSG }; - static int mkmode9p1(ulong mode9p2) { @@ -155,10 +152,10 @@ if(chan->protocol != nil || f->msize < 256) return Eversion; - if(f->msize < MSIZE) + if(f->msize < MAXDAT+IOHDRSZ) r->msize = f->msize; else - r->msize = MSIZE; + r->msize = MAXDAT+IOHDRSZ; /* * Should check the '.' stuff here. @@ -1825,7 +1822,7 @@ * replies. */ if(convM2S(mb->data, mb->count, &f) != mb->count){ - fprint(2, "didn't like %d byte message\n", mb->count); + fprint(2, "didn't like %ld byte message\n", mb->count); return 0; } type = f.type; @@ -1921,7 +1918,7 @@ */ if(chan->msize == 0){ r.ename = "Tversion not seen"; - n = convS2M(&r, rmb->data, MAXMSG); + n = convS2M(&r, rmb->data, SMALLBUF); } else { snprint(ename, sizeof(ename), "9p2: convS2M: type %d", type); --- a/sys/src/cmd/cwfs/all.h +++ b/sys/src/cmd/cwfs/all.h @@ -1,6 +1,7 @@ #include #include #include +#include #define Tfile Tfilescsi /* avoid name conflict */ #include #undef Tfile --- a/sys/src/cmd/cwfs/con.c +++ b/sys/src/cmd/cwfs/con.c @@ -711,9 +711,9 @@ { int i, len; char *cmd; - Timet t1, t2; + vlong t1, t2; - t1 = time(nil); + t1 = nsec(); len = 0; for(i=1; i /* 9p2 */ int version(Chan*, Fcall*, Fcall*); --- a/sys/src/cmd/cwfs/portdat.h +++ b/sys/src/cmd/cwfs/portdat.h @@ -20,18 +20,10 @@ #define HOWMANY(x, y) (((x)+((y)-1)) / (y)) #define ROUNDUP(x, y) (HOWMANY((x), (y)) * (y)) -#define TK2MS(t) (((ulong)(t)*1000)/HZ) /* ticks to ms - beware rounding */ -#define MS2TK(t) (((ulong)(t)*HZ)/1000) /* ms to ticks - beware rounding */ -#define TK2SEC(t) ((t)/HZ) /* ticks to seconds */ - /* constants that don't affect disk layout */ enum { MAXDAT = 8192, /* max allowable data message */ - MAXMSG = 128, /* max protocol message sans data */ - MB = 1024*1024, - - HZ = 1, /* clock frequency */ }; /* @@ -152,8 +144,8 @@ DIRPERBUF = BUFSIZE / sizeof(Dentry), INDPERBUF = BUFSIZE / sizeof(Off), FEPERBUF = (BUFSIZE-sizeof(Super1)-sizeof(Off)) / sizeof(Off), - SMALLBUF = MAXMSG, - LARGEBUF = MAXMSG+MAXDAT+256, + SMALLBUF = 128, + LARGEBUF = IOHDRSZ+MAXDAT+256, RAGAP = (300*1024)/BUFSIZE, /* readahead parameter */ BKPERBLK = 10, CEPERBK = (BUFSIZE - BKPERBLK*sizeof(Off)) / @@ -459,7 +451,7 @@ struct Msgbuf { ulong magic; - short count; + ulong count; short flags; #define LARGE (1<<0) #define FREE (1<<1) --- a/sys/src/cmd/cwfs/srv.c +++ b/sys/src/cmd/cwfs/srv.c @@ -1,6 +1,5 @@ #include "all.h" #include "io.h" -#include /* 9p2000 */ #include enum { --- a/sys/src/cmd/cwfs/sub.c +++ b/sys/src/cmd/cwfs/sub.c @@ -101,8 +101,6 @@ unlock(&flock); } -enum { NOFID = (ulong)~0 }; - /* * returns a locked file structure */