diff options
author | Ori Bernstein <ori@eigenstate.org> | 2022-06-07 22:38:04 +0000 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2022-06-07 22:38:04 +0000 |
commit | 4eeefed7b0c1c47329213f1da719820ebbbebf18 (patch) | |
tree | 5a26470746cd117ac61b2e2d7c090a18a8fb3581 /sys/src/cmd/cwfs | |
parent | 13065e16b3c4fba4d9200ed7fec89ee49338f12a (diff) |
cwfs: fix iounit negotiation
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.
Diffstat (limited to 'sys/src/cmd/cwfs')
-rw-r--r-- | sys/src/cmd/cwfs/9p2.c | 11 | ||||
-rw-r--r-- | sys/src/cmd/cwfs/all.h | 1 | ||||
-rw-r--r-- | sys/src/cmd/cwfs/con.c | 8 | ||||
-rw-r--r-- | sys/src/cmd/cwfs/console.c | 1 | ||||
-rw-r--r-- | sys/src/cmd/cwfs/portdat.h | 14 | ||||
-rw-r--r-- | sys/src/cmd/cwfs/srv.c | 1 | ||||
-rw-r--r-- | sys/src/cmd/cwfs/sub.c | 2 |
7 files changed, 12 insertions, 26 deletions
diff --git a/sys/src/cmd/cwfs/9p2.c b/sys/src/cmd/cwfs/9p2.c index a4d129c97..3745fff76 100644 --- a/sys/src/cmd/cwfs/9p2.c +++ b/sys/src/cmd/cwfs/9p2.c @@ -1,7 +1,4 @@ #include "all.h" -#include <fcall.h> - -enum { MSIZE = MAXDAT+MAXMSG }; static int mkmode9p1(ulong mode9p2) @@ -155,10 +152,10 @@ version(Chan* chan, Fcall* f, Fcall* r) 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 @@ serve9p2(Msgbuf* mb) * 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 @@ serve9p2(Msgbuf* mb) */ 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); diff --git a/sys/src/cmd/cwfs/all.h b/sys/src/cmd/cwfs/all.h index 418d15f55..900113fbd 100644 --- a/sys/src/cmd/cwfs/all.h +++ b/sys/src/cmd/cwfs/all.h @@ -1,6 +1,7 @@ #include <u.h> #include <libc.h> #include <ctype.h> +#include <fcall.h> #define Tfile Tfilescsi /* avoid name conflict */ #include <disk.h> #undef Tfile diff --git a/sys/src/cmd/cwfs/con.c b/sys/src/cmd/cwfs/con.c index 2b418d8c6..d604f9241 100644 --- a/sys/src/cmd/cwfs/con.c +++ b/sys/src/cmd/cwfs/con.c @@ -711,9 +711,9 @@ cmd_time(int argc, char *argv[]) { int i, len; char *cmd; - Timet t1, t2; + vlong t1, t2; - t1 = time(nil); + t1 = nsec(); len = 0; for(i=1; i<argc; i++) len += 1 + strlen(argv[i]); @@ -724,9 +724,9 @@ cmd_time(int argc, char *argv[]) strcat(cmd, argv[i]); } cmd_exec(cmd); - t2 = time(nil); + t2 = nsec(); free(cmd); - print("time = %ld ms\n", TK2MS(t2-t1)); + print("time = %lld ns\n", t2-t1); } void diff --git a/sys/src/cmd/cwfs/console.c b/sys/src/cmd/cwfs/console.c index 3a5e7771f..9f730678f 100644 --- a/sys/src/cmd/cwfs/console.c +++ b/sys/src/cmd/cwfs/console.c @@ -1,5 +1,4 @@ #include "all.h" -#include <fcall.h> /* 9p2 */ int version(Chan*, Fcall*, Fcall*); diff --git a/sys/src/cmd/cwfs/portdat.h b/sys/src/cmd/cwfs/portdat.h index 80af31044..3e025065c 100644 --- a/sys/src/cmd/cwfs/portdat.h +++ b/sys/src/cmd/cwfs/portdat.h @@ -20,18 +20,10 @@ typedef vlong Devsize; /* in bytes */ #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 @@ enum { 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 @@ enum { struct Msgbuf { ulong magic; - short count; + ulong count; short flags; #define LARGE (1<<0) #define FREE (1<<1) diff --git a/sys/src/cmd/cwfs/srv.c b/sys/src/cmd/cwfs/srv.c index e022b9fbf..d745cdf8e 100644 --- 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 <fcall.h> /* 9p2000 */ #include <thread.h> enum { diff --git a/sys/src/cmd/cwfs/sub.c b/sys/src/cmd/cwfs/sub.c index d8befccb9..6a871b554 100644 --- a/sys/src/cmd/cwfs/sub.c +++ b/sys/src/cmd/cwfs/sub.c @@ -101,8 +101,6 @@ loop: unlock(&flock); } -enum { NOFID = (ulong)~0 }; - /* * returns a locked file structure */ |