DO NOT RUN THIS UNTIL YOU HAVE APPLIED THE CWFS PATCH. CWFS WILL HANG
UP ON YOU WITHOUT THE PATCH FROM THE EMAIL TITLED
cwfs: fix iounit negotiation
This patch bumps up the iounit in the kernel to 32k, and
introduces the IOUNIT constant to take advantage of it.
This also changes some of userspace to increase buffer
sizes, so that we can take advantage of the larger reads.
Things to double check for:
- libthread programs have limited stack sizes,
and increasing the size of the buffer may
blow the stack in some of these programs.
- I may have misunderstood how buffer sizes
are used, and may have increased constants
that I shouldn't have.
- General bugs and typos.
- Bugs that changing the io unit tickles.
Note that when mounting 9p over TLS, the iounit will be
restricted to the iounit of the underlying transport,
in this case 16k. That may get addressed in a separate
patch.
diff 73cfaf9d694f927adf89c44e0cc7ad25df15bbdf uncommitted
--- a/sys/include/ape/bio.h
+++ b/sys/include/ape/bio.h
@@ -14,7 +14,7 @@
enum
{
- Bsize = 8*1024,
+ Bsize = 32*1024,
Bungetsize = UTFmax+1, /* space for ungetc */
Bmagic = 0x314159,
Beof = -1,
--- a/sys/include/bio.h
+++ b/sys/include/bio.h
@@ -6,7 +6,7 @@
enum
{
- Bsize = 8*1024,
+ Bsize = IOUNIT,
Bungetsize = UTFmax+1, /* space for ungetc */
Bmagic = 0x314159,
Beof = -1,
--- a/sys/include/libc.h
+++ b/sys/include/libc.h
@@ -567,6 +567,7 @@
#define STATMAX 65535U /* max length of machine-independent stat structure */
#define DIRMAX (sizeof(Dir)+STATMAX) /* max length of Dir structure */
#define ERRMAX 128 /* max length of error string */
+#define IOUNIT 32768U /* reasonable buffer size */
#define MORDER 0x0003 /* mask for bits defining order of mounting */
#define MREPL 0x0000 /* mount replaces object */
--- a/sys/src/9/port/devmnt.c
+++ b/sys/src/9/port/devmnt.c
@@ -16,7 +16,7 @@
* connection.
*/
-#define MAXRPC (IOHDRSZ+8192)
+#define MAXRPC (IOHDRSZ+32*1024)
struct Mntrpc
{
@@ -146,7 +146,7 @@
f.tag = NOTAG;
f.msize = msize;
f.version = v;
- msg = malloc(8192+IOHDRSZ);
+ msg = malloc(MAXRPC);
if(msg == nil)
exhausted("version memory");
if(waserror()){
@@ -153,7 +153,7 @@
free(msg);
nexterror();
}
- k = convS2M(&f, msg, 8192+IOHDRSZ);
+ k = convS2M(&f, msg, MAXRPC);
if(k == 0)
error("bad fversion conversion on send");
@@ -171,8 +171,8 @@
}
/* message sent; receive and decode reply */
- for(k = 0; k < BIT32SZ || (k < GBIT32(msg) && k < 8192+IOHDRSZ); k += l){
- l = devtab[c->type]->read(c, msg+k, 8192+IOHDRSZ-k, c->offset);
+ for(k = 0; k < BIT32SZ || (k < GBIT32(msg) && k < MAXRPC); k += l){
+ l = devtab[c->type]->read(c, msg+k, MAXRPC-k, c->offset);
if(l <= 0)
error("EOF receiving fversion reply");
lock(c);
--- a/sys/src/cmd/1a/a.h
+++ b/sys/src/cmd/1a/a.h
@@ -15,7 +15,6 @@
#define MAXALIGN 7
#define FPCHIP 1
#define NSYMB 500
-#define BUFSIZ 8192
#define HISTSZ 20
#define NINCLUDE 10
#define NHUNK 10000
@@ -52,7 +51,7 @@
struct Io
{
Io* link;
- char b[BUFSIZ];
+ char b[IOUNIT];
char* p;
short c;
short f;
--- a/sys/src/cmd/1l/l.h
+++ b/sys/src/cmd/1l/l.h
@@ -114,7 +114,6 @@
NHUNK = 100000,
MINSIZ = 4,
STRINGSZ = 200,
- MAXIO = 8192,
MAXHIST = 20, /* limit of path elements for history symbols */
A6OFFSET = 32766,
};
@@ -123,8 +122,8 @@
{
struct
{
- char obuf[MAXIO]; /* output buffer */
- uchar ibuf[MAXIO]; /* input buffer */
+ char obuf[IOUNIT]; /* output buffer */
+ uchar ibuf[IOUNIT]; /* input buffer */
} u;
char dbuf[1];
} buf;
--- a/sys/src/cmd/1l/obj.c
+++ b/sys/src/cmd/1l/obj.c
@@ -657,7 +657,7 @@
n = stop - good;
memmove(buf, good, stop - good);
stop = buf + n;
- n = MAXIO - n;
+ n = IOUNIT - n;
if(n > max)
n = max;
n = read(f, stop, n);
--- a/sys/src/cmd/2a/a.h
+++ b/sys/src/cmd/2a/a.h
@@ -15,7 +15,6 @@
#define MAXALIGN 7
#define FPCHIP 1
#define NSYMB 500
-#define BUFSIZ 8192
#define HISTSZ 20
#define NINCLUDE 10
#define NHUNK 10000
@@ -52,7 +51,7 @@
struct Io
{
Io* link;
- char b[BUFSIZ];
+ char b[IOUNIT];
char* p;
short c;
short f;
--- a/sys/src/cmd/2l/l.h
+++ b/sys/src/cmd/2l/l.h
@@ -116,7 +116,6 @@
NHUNK = 100000,
MINSIZ = 4,
STRINGSZ = 200,
- MAXIO = 8192,
MAXHIST = 20, /* limit of path elements for history symbols */
A6OFFSET = 32766
};
@@ -125,8 +124,8 @@
{
struct
{
- char obuf[MAXIO]; /* output buffer */
- uchar ibuf[MAXIO]; /* input buffer */
+ char obuf[IOUNIT]; /* output buffer */
+ uchar ibuf[IOUNIT]; /* input buffer */
} u;
char dbuf[1];
} buf;
--- a/sys/src/cmd/2l/obj.c
+++ b/sys/src/cmd/2l/obj.c
@@ -672,7 +672,7 @@
n = stop - good;
memmove(buf, good, stop - good);
stop = buf + n;
- n = MAXIO - n;
+ n = IOUNIT - n;
if(n > max)
n = max;
n = read(f, stop, n);
--- a/sys/src/cmd/5l/l.h
+++ b/sys/src/cmd/5l/l.h
@@ -197,7 +197,6 @@
NHUNK = 100000,
MINSIZ = 64,
NENT = 100,
- MAXIO = 8192,
MAXHIST = 20, /* limit of path elements for history symbols */
Roffset = 22, /* no. bits for offset in relocation address */
@@ -208,8 +207,8 @@
{
struct
{
- uchar obuf[MAXIO]; /* output buffer */
- uchar ibuf[MAXIO]; /* input buffer */
+ uchar obuf[IOUNIT]; /* output buffer */
+ uchar ibuf[IOUNIT]; /* input buffer */
} u;
char dbuf[1];
} buf;
--- a/sys/src/cmd/5l/obj.c
+++ b/sys/src/cmd/5l/obj.c
@@ -682,7 +682,7 @@
n = stop - good;
memmove(buf, good, stop - good);
stop = buf + n;
- n = MAXIO - n;
+ n = IOUNIT - n;
if(n > max)
n = max;
n = read(f, stop, n);
--- a/sys/src/cmd/6a/a.h
+++ b/sys/src/cmd/6a/a.h
@@ -14,7 +14,6 @@
#define MAXALIGN 7
#define FPCHIP 1
#define NSYMB 500
-#define BUFSIZ 8192
#define HISTSZ 20
#define NINCLUDE 10
#define NHUNK 10000
@@ -51,7 +50,7 @@
struct Io
{
Io* link;
- char b[BUFSIZ];
+ char b[IOUNIT];
char* p;
short c;
short f;
--- a/sys/src/cmd/6l/l.h
+++ b/sys/src/cmd/6l/l.h
@@ -118,7 +118,6 @@
MINSIZ = 8,
STRINGSZ = 200,
MINLC = 1,
- MAXIO = 8192,
MAXHIST = 20, /* limit of path elements for history symbols */
Yxxx = 0,
@@ -225,8 +224,8 @@
{
struct
{
- char obuf[MAXIO]; /* output buffer */
- uchar ibuf[MAXIO]; /* input buffer */
+ char obuf[IOUNIT]; /* output buffer */
+ uchar ibuf[IOUNIT]; /* input buffer */
} u;
char dbuf[1];
} buf;
--- a/sys/src/cmd/6l/obj.c
+++ b/sys/src/cmd/6l/obj.c
@@ -728,7 +728,7 @@
n = stop - good;
memmove(buf, good, stop - good);
stop = buf + n;
- n = MAXIO - n;
+ n = IOUNIT - n;
if(n > max)
n = max;
n = read(f, stop, n);
--- a/sys/src/cmd/7a/a.h
+++ b/sys/src/cmd/7a/a.h
@@ -17,7 +17,6 @@
#define MAXALIGN 7
#define FPCHIP 1
#define NSYMB 8192
-#define BUFSIZ 8192
#define HISTSZ 20
#define NINCLUDE 10
#define NHUNK 10000
@@ -48,7 +47,7 @@
struct Io
{
Io* link;
- char b[BUFSIZ];
+ char b[IOUNIT];
char* p;
short c;
short f;
--- a/sys/src/cmd/7l/l.h
+++ b/sys/src/cmd/7l/l.h
@@ -238,7 +238,6 @@
STRINGSZ = 200,
NHASH = 10007,
NHUNK = 100000,
- MAXIO = 8192,
MAXHIST = 20, /* limit of path elements for history symbols */
};
@@ -246,8 +245,8 @@
{
struct
{
- uchar obuf[MAXIO]; /* output buffer */
- uchar ibuf[MAXIO]; /* input buffer */
+ uchar obuf[IOUNIT]; /* output buffer */
+ uchar ibuf[IOUNIT]; /* input buffer */
} u;
char dbuf[1];
} buf;
--- a/sys/src/cmd/7l/obj.c
+++ b/sys/src/cmd/7l/obj.c
@@ -575,7 +575,7 @@
n = stop - good;
memmove(buf, good, stop - good);
stop = buf + n;
- n = MAXIO - n;
+ n = IOUNIT - n;
if(n > max)
n = max;
n = read(f, stop, n);
--- a/sys/src/cmd/8a/a.h
+++ b/sys/src/cmd/8a/a.h
@@ -14,7 +14,6 @@
#define MAXALIGN 7
#define FPCHIP 1
#define NSYMB 500
-#define BUFSIZ 8192
#define HISTSZ 20
#define NINCLUDE 10
#define NHUNK 10000
@@ -51,7 +50,7 @@
struct Io
{
Io* link;
- char b[BUFSIZ];
+ char b[IOUNIT];
char* p;
short c;
short f;
--- a/sys/src/cmd/8l/l.h
+++ b/sys/src/cmd/8l/l.h
@@ -110,7 +110,6 @@
MINSIZ = 4,
STRINGSZ = 200,
MINLC = 1,
- MAXIO = 8192,
MAXHIST = 20, /* limit of path elements for history symbols */
Yxxx = 0,
@@ -199,8 +198,8 @@
{
struct
{
- char obuf[MAXIO]; /* output buffer */
- uchar ibuf[MAXIO]; /* input buffer */
+ char obuf[IOUNIT]; /* output buffer */
+ uchar ibuf[IOUNIT]; /* input buffer */
} u;
char dbuf[1];
} buf;
--- a/sys/src/cmd/8l/obj.c
+++ b/sys/src/cmd/8l/obj.c
@@ -716,7 +716,7 @@
n = stop - good;
memmove(buf, good, stop - good);
stop = buf + n;
- n = MAXIO - n;
+ n = IOUNIT - n;
if(n > max)
n = max;
n = read(f, stop, n);
--- a/sys/src/cmd/ar.c
+++ b/sys/src/cmd/ar.c
@@ -1087,7 +1087,7 @@
{
Armember *bp;
int i;
- char buf[8192];
+ char buf[IOUNIT];
if (ap->paged) { /* copy from disk */
seek(ap->fd, 0, 0);
--- a/sys/src/cmd/audio/mp3enc/mpglib_interface.c
+++ b/sys/src/cmd/audio/mp3enc/mpglib_interface.c
@@ -47,7 +47,7 @@
{ 0, 384, 1152, 1152 }, /* MPEG-1 */
{ 0, 384, 1152, 576 } /* MPEG-2(.5) */
};
- static char out [8192];
+ static char out [IOUNIT];
signed short int* p = (signed short int*) out;
int processed_bytes;
int processed_samples; // processed samples per channel
--- a/sys/src/cmd/aux/consolefs.c
+++ b/sys/src/cmd/aux/consolefs.c
@@ -162,7 +162,7 @@
char *consoledb = "/lib/ndb/consoledb";
char *mntpt = "/mnt/consoles";
-int messagesize = 8192+IOHDRSZ;
+int messagesize = IOUNIT+IOHDRSZ;
void
fatal(char *fmt, ...)
@@ -760,8 +760,8 @@
return;
}
messagesize = r->f.msize;
- if(messagesize > 8192+IOHDRSZ)
- messagesize = 8192+IOHDRSZ;
+ if(messagesize > IOUNIT+IOHDRSZ)
+ messagesize = IOUNIT+IOHDRSZ;
r->f.msize = messagesize;
if(strncmp(r->f.version, "9P", 2) != 0)
r->f.version = "unknown";
--- a/sys/src/cmd/bzip2/bunzip2.c
+++ b/sys/src/cmd/bzip2/bunzip2.c
@@ -125,8 +125,8 @@
bunzip(int ofd, char *ofile, Biobuf *bin)
{
int e, n, done, onemore;
- char buf[8192];
- char obuf[8192];
+ char buf[IOUNIT];
+ char obuf[IOUNIT];
Biobuf bout;
bz_stream strm;
--- a/sys/src/cmd/bzip2/bzip2.c
+++ b/sys/src/cmd/bzip2/bzip2.c
@@ -132,8 +132,8 @@
bzip(char *file, long mtime, int ifd, Biobuf *bout)
{
int e, n, done, onemore;
- char buf[8192];
- char obuf[8192];
+ char buf[IOUNIT];
+ char obuf[IOUNIT];
Biobuf bin;
bz_stream strm;
--- a/sys/src/cmd/cat.c
+++ b/sys/src/cmd/cat.c
@@ -4,7 +4,7 @@
void
cat(int f, char *s)
{
- char buf[8192];
+ char buf[IOUNIT];
long n;
while((n=read(f, buf, sizeof buf))>0)
--- a/sys/src/cmd/cc/cc.h
+++ b/sys/src/cmd/cc/cc.h
@@ -19,7 +19,6 @@
typedef struct Bits Bits;
#define NHUNK 50000L
-#define BUFSIZ 8192
#define NSYMB 1500
#define NHASH 1024
#define STRINGSZ 200
@@ -149,7 +148,7 @@
{
Io* link;
char* p;
- char b[BUFSIZ];
+ char b[IOUNIT];
short c;
short f;
};
--- a/sys/src/cmd/cc/lex.c
+++ b/sys/src/cmd/cc/lex.c
@@ -1310,7 +1310,7 @@
return EOF;
if(i->f < 0)
goto pop;
- fi.c = read(i->f, i->b, BUFSIZ) - 1;
+ fi.c = read(i->f, i->b, IOUNIT) - 1;
if(fi.c < 0) {
close(i->f);
linehist(0, 0);
--- a/sys/src/cmd/cc/lexbody
+++ b/sys/src/cmd/cc/lexbody
@@ -558,7 +558,7 @@
return EOF;
if(i->f < 0)
goto pop;
- fi.c = read(i->f, i->b, BUFSIZ) - 1;
+ fi.c = read(i->f, i->b, IOUNIT) - 1;
if(fi.c < 0) {
close(i->f);
linehist(0, 0);
--- a/sys/src/cmd/cfs/cfs.c
+++ b/sys/src/cmd/cfs/cfs.c
@@ -49,12 +49,11 @@
char statbuf[2048];
int statlen;
-#define MAXFDATA 8192 /* i/o size for read/write */
-int messagesize = MAXFDATA+IOHDRSZ;
+int messagesize = IOUNIT+IOHDRSZ;
-uchar datasnd[MAXFDATA + IOHDRSZ];
-uchar datarcv[MAXFDATA + IOHDRSZ];
+uchar datasnd[IOUNIT + IOHDRSZ];
+uchar datarcv[IOUNIT + IOHDRSZ];
Qid rootqid;
Qid ctlqid = {0x5555555555555555LL, 0, 0};
@@ -495,7 +494,7 @@
long n;
vlong off, first;
char *cp;
- char data[MAXFDATA];
+ char data[IOUNIT];
Ibuf *b;
off = c.thdr.offset;
@@ -607,7 +606,7 @@
rwrite(Mfile *mf)
{
Ibuf *b;
- char buf[MAXFDATA];
+ char buf[IOUNIT];
if(statson && ctltest(mf)){
sendreply("read only");
--- a/sys/src/cmd/cp.c
+++ b/sys/src/cmd/cp.c
@@ -1,8 +1,6 @@
#include <u.h>
#include <libc.h>
-#define DEFB (8*1024)
-
int buflen;
int failed;
int gflag;
@@ -125,7 +123,7 @@
buflen = iounit(fdf);
if(buflen <= 0)
- buflen = DEFB;
+ buflen = IOUNIT;
if(copy1(fdf, fds < 0 ? fdt : fds, from, to)==0){
if(fds >= 0 && write(fds, "", 0) < 0){
--- a/sys/src/cmd/crc32.c
+++ b/sys/src/cmd/crc32.c
@@ -38,7 +38,7 @@
sum(int fd, char *name)
{
int n;
- uchar buf[8192];
+ uchar buf[IOUNIT];
u32int crc;
crc = init ^ xor;
--- a/sys/src/cmd/derp.c
+++ b/sys/src/cmd/derp.c
@@ -43,14 +43,10 @@
return v;
}
-enum {
- BUFSIZE = 8*1024,
-};
-
int
cmpfile(char *a, char *b)
{
- static uchar buf1[BUFSIZE], buf2[BUFSIZE];
+ static uchar buf1[IOUNIT], buf2[IOUNIT];
int r, n, m, fd1, fd2;
if((fd1 = open(a, OREAD)) < 0)
--- a/sys/src/cmd/diff/main.c
+++ b/sys/src/cmd/diff/main.c
@@ -81,7 +81,7 @@
{
int fd, i;
char *p;
- char buf[8192];
+ char buf[IOUNIT];
atnotify(catch, 1);
p = mktemp(tmp[whichtmp++]);
--- a/sys/src/cmd/disk/9660/write.c
+++ b/sys/src/cmd/disk/9660/write.c
@@ -75,7 +75,7 @@
writefiles(Dump *d, Cdimg *cd, Direc *direc)
{
int i;
- uchar buf[8192], digest[MD5dlen];
+ uchar buf[IOUNIT], digest[MD5dlen];
ulong length, n, start;
Biobuf *b;
DigestState *s;
--- a/sys/src/cmd/disk/format.c
+++ b/sys/src/cmd/disk/format.c
@@ -397,11 +397,11 @@
{
long m, tot;
- /* write 8k at a time, to be nice to the disk subsystem */
+ /* write IOUNIT at a time, to be nice to the disk subsystem */
for(tot=0; tot<n; tot+=m){
m = n - tot;
- if(m > 8192)
- m = 8192;
+ if(m > IOUNIT)
+ m = IOUNIT;
if(write(fd, (uchar*)buf+tot, m) != m)
break;
}
--- a/sys/src/cmd/dossrv/dosfs.h
+++ b/sys/src/cmd/dossrv/dosfs.h
@@ -1,7 +1,7 @@
enum
{
- Maxfdata = 8192,
- Maxiosize = IOHDRSZ+Maxfdata,
+ Maxfdata = IOUNIT,
+ Maxiosize = IOHDRSZ+IOUNIT,
};
extern Fcall *req;
--- a/sys/src/cmd/exportfs/exportfs.c
+++ b/sys/src/cmd/exportfs/exportfs.c
@@ -83,7 +83,7 @@
if(messagesize == 0){
messagesize = iounit(0);
if(messagesize == 0)
- messagesize = 8192+IOHDRSZ;
+ messagesize = IOUNIT+IOHDRSZ;
}
fhash = emallocz(sizeof(Fid*)*FHASHSIZE);
--- a/sys/src/cmd/fcp.c
+++ b/sys/src/cmd/fcp.c
@@ -1,6 +1,5 @@
#include <u.h>
#include <libc.h>
-#define DEFB (8*1024)
#define Nwork 8
int buflen;
@@ -134,7 +133,7 @@
buflen = iounit(fdf);
if(buflen <= 0)
- buflen = DEFB;
+ buflen = IOUNIT;
if(copy1(fdf, fdt, from, to)==0 && (xflag || gflag || uflag)){
nulldir(&dirt);
--- a/sys/src/cmd/ip/ftpfs/ftpfs.h
+++ b/sys/src/cmd/ip/ftpfs/ftpfs.h
@@ -107,6 +107,6 @@
#define TIMEOUT 5*60
#define DMSYML 0x10000000
-#define MAXFDATA 8192
+#define MAXFDATA IOUNIT
extern char net[]; /* network for connections */
--- a/sys/src/cmd/ip/hproxy.c
+++ b/sys/src/cmd/ip/hproxy.c
@@ -1,8 +1,12 @@
#include <u.h>
#include <libc.h>
-enum { bufsize = 8*1024 };
-char buf[bufsize+1], addr[128], *proto, *host, *port, *path;
+char buf[IOUNIT+1];
+char addr[128];
+char *proto;
+char *host;
+char *port;
+char *path;
void
main(void)
@@ -13,9 +17,9 @@
/* read all the headers */
n = 0;
do {
- if(n >= bufsize)
+ if(n >= IOUNIT)
return;
- if((r = read(0, buf+n, bufsize-n)) <= 0)
+ if((r = read(0, buf+n, IOUNIT-n)) <= 0)
return;
n += r;
buf[n] = 0;
--- a/sys/src/cmd/ka/a.h
+++ b/sys/src/cmd/ka/a.h
@@ -12,7 +12,6 @@
#define MAXALIGN 7
#define FPCHIP 1
#define NSYMB 500
-#define BUFSIZ 8192
#define HISTSZ 20
#define NINCLUDE 10
#define NHUNK 10000
@@ -43,7 +42,7 @@
struct Io
{
Io* link;
- char b[BUFSIZ];
+ char b[IOUNIT];
char* p;
short c;
short f;
--- a/sys/src/cmd/kbmap.c
+++ b/sys/src/cmd/kbmap.c
@@ -137,7 +137,7 @@
writemap(char *file)
{
int i, fd, ofd;
- char buf[8192];
+ char buf[IOUNIT];
if((fd = open(file, OREAD)) < 0){
fprint(2, "cannot open %s: %r", file);
--- a/sys/src/cmd/kl/l.h
+++ b/sys/src/cmd/kl/l.h
@@ -96,7 +96,6 @@
FPCHIP = 1,
BIG = 4096-8,
STRINGSZ = 200,
- MAXIO = 8192,
MAXHIST = 20, /* limit of path elements for history symbols */
DATBLK = 1024,
NHASH = 10007,
@@ -178,8 +177,8 @@
{
struct
{
- uchar obuf[MAXIO]; /* output buffer */
- uchar ibuf[MAXIO]; /* input buffer */
+ uchar obuf[IOUNIT]; /* output buffer */
+ uchar ibuf[IOUNIT]; /* input buffer */
} u;
char dbuf[1];
} buf;
--- a/sys/src/cmd/kl/obj.c
+++ b/sys/src/cmd/kl/obj.c
@@ -587,7 +587,7 @@
n = stop - good;
memmove(buf, good, stop - good);
stop = buf + n;
- n = MAXIO - n;
+ n = IOUNIT - n;
if(n > max)
n = max;
n = read(f, stop, n);
--- a/sys/src/cmd/lens.c
+++ b/sys/src/cmd/lens.c
@@ -217,7 +217,7 @@
int x, y, xx, yy, dd, i;
int dx, dy;
int xoff, yoff;
- uchar out[8192];
+ uchar out[IOUNIT];
uchar sp[4];
dx = (Dx(tmp->r)+mag-1)/mag;
--- a/sys/src/cmd/lnfs.c
+++ b/sys/src/cmd/lnfs.c
@@ -10,7 +10,7 @@
{
OPERM = 0x3, /* mask of all permission types in open mode */
Maxsize = 512*1024*1024,
- Maxfdata = 8192,
+ Maxfdata = IOUNIT,
NAMELEN = 28,
};
--- a/sys/src/cmd/md5sum.c
+++ b/sys/src/cmd/md5sum.c
@@ -23,7 +23,7 @@
sum(int fd, char *name)
{
int n;
- uchar buf[8192], digest[MD5dlen];
+ uchar buf[IOUNIT], digest[MD5dlen];
DigestState *s;
s = md5(nil, 0, nil, nil);
--- a/sys/src/cmd/mv.c
+++ b/sys/src/cmd/mv.c
@@ -167,7 +167,7 @@
int
copy1(int fdf, int fdt, char *from, char *to)
{
- char buf[8192];
+ char buf[IOUNIT];
long n, n1;
while ((n = read(fdf, buf, sizeof buf)) > 0) {
--- a/sys/src/cmd/os.c
+++ b/sys/src/cmd/os.c
@@ -20,7 +20,7 @@
char *mnt = "/mnt/term/cmd";
char *dir = nil;
-char buf[8192];
+char buf[IOUNIT];
int fd[Nfd] = {-1};
int pid[Npid];
int nice, foreground = 1;
--- a/sys/src/cmd/page.c
+++ b/sys/src/cmd/page.c
@@ -55,7 +55,7 @@
enum {
NPROC = 8,
- NBUF = 8*1024,
+ NBUF = IOUNIT,
NPATH = 1024,
};
--- a/sys/src/cmd/paqfs/paqfs.c
+++ b/sys/src/cmd/paqfs/paqfs.c
@@ -62,7 +62,7 @@
Fcall rhdr, thdr;
int blocksize;
int cachesize = 20;
-int mesgsize = 8*1024 + IOHDRSZ;
+int mesgsize = IOUNIT + IOHDRSZ;
Paq *root, *rootfile;
Block *cache;
ulong cacheage;
--- a/sys/src/cmd/pump.c
+++ b/sys/src/cmd/pump.c
@@ -37,7 +37,7 @@
char *file;
kilo = 5000;
- obsize = ibsize = 8*1024;
+ obsize = ibsize = IOUNIT;
dsize = 0;
fo = 1;
--- a/sys/src/cmd/qa/a.h
+++ b/sys/src/cmd/qa/a.h
@@ -12,7 +12,6 @@
#define MAXALIGN 7
#define FPCHIP 1
#define NSYMB 8192
-#define BUFSIZ 8192
#define HISTSZ 20
#define NINCLUDE 10
#define NHUNK 10000
@@ -43,7 +42,7 @@
struct Io
{
Io* link;
- char b[BUFSIZ];
+ char b[IOUNIT];
char* p;
short c;
short f;
--- a/sys/src/cmd/ql/l.h
+++ b/sys/src/cmd/ql/l.h
@@ -93,7 +93,6 @@
FPCHIP = 1,
BIG = 32768-8,
STRINGSZ = 200,
- MAXIO = 8192,
MAXHIST = 20, /* limit of path elements for history symbols */
DATBLK = 1024,
NHASH = 10007,
@@ -171,8 +170,8 @@
{
struct
{
- uchar obuf[MAXIO]; /* output buffer */
- uchar ibuf[MAXIO]; /* input buffer */
+ uchar obuf[IOUNIT]; /* output buffer */
+ uchar ibuf[IOUNIT]; /* input buffer */
} u;
char dbuf[1];
} buf;
--- a/sys/src/cmd/ql/obj.c
+++ b/sys/src/cmd/ql/obj.c
@@ -670,7 +670,7 @@
n = stop - good;
memmove(buf, good, stop - good);
stop = buf + n;
- n = MAXIO - n;
+ n = IOUNIT - n;
if(n > max)
n = max;
n = read(f, stop, n);
--- a/sys/src/cmd/qr.c
+++ b/sys/src/cmd/qr.c
@@ -699,7 +699,7 @@
void
main(int argc, char **argv)
{
- uchar buf[8192];
+ uchar buf[IOUNIT];
int rc;
int ver, lev, mode, s;
char *c;
--- a/sys/src/cmd/ratrace.c
+++ b/sys/src/cmd/ratrace.c
@@ -14,7 +14,7 @@
typedef struct Msg Msg;
struct Msg {
int pid;
- char buf[8*1024];
+ char buf[IOUNIT];
};
typedef struct Reader Reader;
--- a/sys/src/cmd/rc/io.c
+++ b/sys/src/cmd/rc/io.c
@@ -3,10 +3,6 @@
#include "io.h"
#include "fns.h"
-enum {
- NBUF = 8192,
-};
-
void
vpfmt(io *f, char *fmt, va_list ap)
{
@@ -247,7 +243,7 @@
io*
openiofd(int fd)
{
- return newio(emalloc(NBUF), 0, fd);
+ return newio(emalloc(IOUNIT), 0, fd);
}
/*
@@ -279,7 +275,7 @@
dotrap();
}
f->bufp = f->buf;
- f->ebuf = f->buf+NBUF;
+ f->ebuf = f->buf+IOUNIT;
}
}
@@ -294,7 +290,7 @@
emptyiobuf(io *f)
{
int n;
- if(f->fd<0 || (n = Read(f->fd, f->buf, NBUF))<=0) return EOF;
+ if(f->fd<0 || (n = Read(f->fd, f->buf, IOUNIT))<=0) return EOF;
f->bufp = f->buf;
f->ebuf = f->buf + n;
return *f->bufp++;
--- a/sys/src/cmd/read.c
+++ b/sys/src/cmd/read.c
@@ -56,7 +56,7 @@
void
chars(int fd, char *file)
{
- char buf[8*1024];
+ char buf[IOUNIT];
vlong m;
int n;
--- a/sys/src/cmd/sha1sum.c
+++ b/sys/src/cmd/sha1sum.c
@@ -43,7 +43,7 @@
sum(int fd, char *name)
{
int n;
- uchar buf[8192], digest[SHA2_512dlen];
+ uchar buf[IOUNIT], digest[SHA2_512dlen];
DigestState *s;
s = (*shafunc)(nil, 0, nil, nil);
--- a/sys/src/cmd/sum.c
+++ b/sys/src/cmd/sum.c
@@ -45,7 +45,7 @@
int n;
ulong sum;
uvlong fsize;
- char buf[8*1024];
+ char buf[IOUNIT];
if(file){
if((fd = open(file, OREAD)) < 0){
--- a/sys/src/cmd/tee.c
+++ b/sys/src/cmd/tee.c
@@ -12,7 +12,7 @@
int uflag;
int aflag;
-char in[8192];
+char in[IOUNIT];
int intignore(void*, char*);
--- a/sys/src/cmd/touchfs.c
+++ b/sys/src/cmd/touchfs.c
@@ -5,7 +5,7 @@
void
Bpass(Biobuf *bin, Biobuf *bout, int n)
{
- char buf[8192];
+ char buf[IOUNIT];
int m;
while(n > 0) {
--- a/sys/src/cmd/upas/Mail/mail.h
+++ b/sys/src/cmd/upas/Mail/mail.h
@@ -6,7 +6,7 @@
enum {
Stack = 64*1024,
- Bufsz = 8192,
+ Bufsz = IOUNIT,
Eventsz = 256*UTFmax,
Subjlen = 56,
};
--- a/sys/src/cmd/upas/common/folder.c
+++ b/sys/src/cmd/upas/common/folder.c
@@ -338,10 +338,10 @@
char *buf;
int n, m;
- buf = malloc(8192);
+ buf = malloc(IOUNIT);
for(;;){
m = 0;
- n = Bread(in, buf, 8192);
+ n = Bread(in, buf, IOUNIT);
if(n <= 0)
break;
m = Bwrite(out, buf, n);
--- a/sys/src/cmd/va/a.h
+++ b/sys/src/cmd/va/a.h
@@ -12,7 +12,6 @@
#define MAXALIGN 7
#define FPCHIP 1
#define NSYMB 8192
-#define BUFSIZ 8192
#define HISTSZ 20
#define NINCLUDE 10
#define NHUNK 10000
@@ -43,7 +42,7 @@
struct Io
{
Io* link;
- char b[BUFSIZ];
+ char b[IOUNIT];
char* p;
short c;
short f;
--- a/sys/src/cmd/vl/l.h
+++ b/sys/src/cmd/vl/l.h
@@ -163,7 +163,6 @@
NHUNK = 100000,
MINSIZ = 64,
NENT = 100,
- MAXIO = 8192,
MAXHIST = 20, /* limit of path elements for history symbols */
};
@@ -171,8 +170,8 @@
{
struct
{
- uchar obuf[MAXIO]; /* output buffer */
- uchar ibuf[MAXIO]; /* input buffer */
+ uchar obuf[IOUNIT]; /* output buffer */
+ uchar ibuf[IOUNIT]; /* input buffer */
} u;
char dbuf[1];
} buf;
--- a/sys/src/cmd/vl/obj.c
+++ b/sys/src/cmd/vl/obj.c
@@ -637,7 +637,7 @@
n = stop - good;
memmove(buf, good, stop - good);
stop = buf + n;
- n = MAXIO - n;
+ n = IOUNIT - n;
if(n > max)
n = max;
n = read(f, stop, n);
--- a/sys/src/cmd/vnc/devdraw.c
+++ b/sys/src/cmd/vnc/devdraw.c
@@ -36,7 +36,7 @@
#define NHASH (1<<5)
#define HASHMASK (NHASH-1)
-#define IOUNIT (64*1024)
+#define MAXBUF (64*1024)
typedef struct Client Client;
typedef struct Draw Draw;
@@ -1023,7 +1023,7 @@
if(c->qid.type & QTDIR){
c = devopen(c, omode, 0, 0, drawgen);
- c->iounit = IOUNIT;
+ c->iounit = MAXBUF;
}
dlock();
@@ -1080,7 +1080,7 @@
c->mode = openmode(omode);
c->flag |= COPEN;
c->offset = 0;
- c->iounit = IOUNIT;
+ c->iounit = MAXBUF;
return c;
}
--- a/sys/src/cmd/vnc/exportfs.c
+++ b/sys/src/cmd/vnc/exportfs.c
@@ -12,8 +12,7 @@
enum
{
Nfidhash = 32,
- Maxfdata = 8192,
- Maxrpc = IOHDRSZ + Maxfdata,
+ Maxrpc = IOHDRSZ + IOUNIT,
};
struct Export
--- a/sys/src/cmd/wc.c
+++ b/sys/src/cmd/wc.c
@@ -8,7 +8,6 @@
*/
#include <u.h>
#include <libc.h>
-#define NBUF (8*1024)
uvlong nline, tnline; int pline;
uvlong nword, tnword; int pword;
uvlong nrune, tnrune; int prune;
@@ -292,7 +291,7 @@
count(int f, char *name)
{
int n;
- uchar buf[NBUF];
+ uchar buf[IOUNIT];
uchar *bufp, *ebuf;
uchar *state = statesp;
@@ -303,7 +302,7 @@
nchar = 0;
for(;;){
- n=read(f, buf, NBUF);
+ n=read(f, buf, sizeof(buf));
if(n<=0)
break;
nchar+=n;
--- a/sys/src/cmd/webfs/http.c
+++ b/sys/src/cmd/webfs/http.c
@@ -28,7 +28,7 @@
int tunnel;
int len;
char addr[128];
- char buf[8192+2];
+ char buf[IOUNIT+UTFmax];
};
struct Hpool
@@ -549,7 +549,7 @@
http(char *m, Url *u, Key *shdr, Buq *qbody, Buq *qpost)
{
int i, l, n, try, pid, fd, cfd, needlength, chunked, retry, nobody, badauth;
- char *s, *x, buf[8192+2], status[256], method[16], *host;
+ char *s, *x, buf[IOUNIT+UTFmax], status[256], method[16], *host;
vlong length, offset;
Url ru, tu, *nu;
Key *k, *rhdr;
--- a/sys/src/games/midi.c
+++ b/sys/src/games/midi.c
@@ -16,7 +16,7 @@
int fd, ofd, div, tempo = 500000, ntrack;
uvlong T;
int freq[128];
-uchar out[8192], *outp = out;
+uchar out[IOUNIT], *outp = out;
void *
emallocz(int size)
--- a/sys/src/games/wadfs.c
+++ b/sys/src/games/wadfs.c
@@ -11,7 +11,7 @@
Nhdr = Nsig+4+4,
Ndict = 4+4+8,
Nname = 8,
- Nbuf = 8192,
+ Nbuf = IOUNIT,
Maxsz = 0x7fffffff - Nhdr
};
--- a/sys/src/lib9p/srv.c
+++ b/sys/src/lib9p/srv.c
@@ -830,7 +830,7 @@
if(srv->rpool == nil)
srv->rpool = allocreqpool(srv->destroyreq);
if(srv->msize == 0)
- srv->msize = 8192+IOHDRSZ;
+ srv->msize = IOUNIT+IOHDRSZ;
changemsize(srv, srv->msize);
--- a/sys/src/libdisk/proto.c
+++ b/sys/src/libdisk/proto.c
@@ -6,11 +6,6 @@
#include <disk.h>
#include <regexp.h>
-enum {
- LEN = 8*1024,
- HUNKS = 128,
-};
-
typedef struct File File;
struct File{
char *new;
--- a/sys/src/libdraw/openfont.c
+++ b/sys/src/libdraw/openfont.c
@@ -5,18 +5,17 @@
static char*
readfile(char *name)
{
- enum { HUNK = 8*1024, };
int f, n, r;
char *s, *p;
n = 0;
r = -1;
- if((s = malloc(HUNK)) != nil){
+ if((s = malloc(IOUNIT)) != nil){
if((f = open(name, OREAD|OCEXEC)) >= 0){
- while((r = read(f, s+n, HUNK)) > 0){
+ while((r = read(f, s+n, IOUNIT)) > 0){
n += r;
r = -1;
- if((p = realloc(s, n+HUNK)) == nil)
+ if((p = realloc(s, n+IOUNIT)) == nil)
break;
s = p;
}
--- a/sys/src/libdraw/readimage.c
+++ b/sys/src/libdraw/readimage.c
@@ -30,7 +30,7 @@
if(d != nil)
chunk = d->bufsize - 32; /* a little room for header */
else
- chunk = 8192;
+ chunk = IOUNIT;
/*
* distinguish new channel descriptor from old ldepth.
--- a/sys/src/libflate/deflate.c
+++ b/sys/src/libflate/deflate.c
@@ -50,7 +50,7 @@
* internal lz paramaters
*/
DeflateOut = 4096, /* output buffer size */
- BlockSize = 8192, /* attempted input read quanta */
+ BlockSize = IOUNIT, /* attempted input read quanta */
DeflateBlock = DeflateMaxBlock & ~(BlockSize - 1),
MinMatchMaxOff = 4096, /* max profitable offset for small match;
* assumes 8 bits for len, 5+10 for offset