* [PATCH 1 of 8] devmnt: set MAXRPC to IOHDRSZ+48K
2015-08-23 23:49 [PATCH 0 of 8] 48k iounit mischief
@ 2015-08-23 23:49 ` mischief
2015-08-23 23:49 ` [PATCH 2 of 8] libc: define default IOUNIT as 48K mischief
` (5 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: mischief @ 2015-08-23 23:49 UTC (permalink / raw)
To: 9front
# HG changeset patch
# User mischief <mischief@offblast.org>
# Date 1440366687 25200
# Sun Aug 23 14:51:27 2015 -0700
# Node ID 72294b856560ea15445ffb0455e1d26084f1bfd0
# Parent 61e11ee59f8311e3cbae0cebeda0fa6e109badcd
devmnt: set MAXRPC to IOHDRSZ+48K
an iounit of 48K is chosen because it is a multiple of the old 8K iounit and
it is less than qiomaxatomic, so MAXRPC will still fit.
diff -r 61e11ee59f83 -r 72294b856560 sys/src/9/port/devmnt.c
--- a/sys/src/9/port/devmnt.c Sun Aug 23 23:49:31 2015 +0200
+++ b/sys/src/9/port/devmnt.c Sun Aug 23 14:51:27 2015 -0700
@@ -16,7 +16,7 @@
* connection.
*/
-#define MAXRPC (IOHDRSZ+8192)
+#define MAXRPC (IOHDRSZ+6*8192)
struct Mntrpc
{
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2 of 8] libc: define default IOUNIT as 48K
2015-08-23 23:49 [PATCH 0 of 8] 48k iounit mischief
2015-08-23 23:49 ` [PATCH 1 of 8] devmnt: set MAXRPC to IOHDRSZ+48K mischief
@ 2015-08-23 23:49 ` mischief
2015-08-23 23:49 ` [PATCH 4 of 8] cwfs: use IOUNIT as MAXDAT, fix Msgbuf count overflow when MAXDAT > 2^15-1 mischief
` (4 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: mischief @ 2015-08-23 23:49 UTC (permalink / raw)
To: 9front
# HG changeset patch
# User mischief <mischief@offblast.org>
# Date 1440366687 25200
# Sun Aug 23 14:51:27 2015 -0700
# Node ID 29a454214255b17dd1a1f1c14d5b63100d1bf3bb
# Parent 72294b856560ea15445ffb0455e1d26084f1bfd0
libc: define default IOUNIT as 48K
diff -r 72294b856560 -r 29a454214255 sys/include/libc.h
--- a/sys/include/libc.h Sun Aug 23 14:51:27 2015 -0700
+++ b/sys/include/libc.h Sun Aug 23 14:51:27 2015 -0700
@@ -521,6 +521,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 49152 /* 9p iounit */
#define MORDER 0x0003 /* mask for bits defining order of mounting */
#define MREPL 0x0000 /* mount replaces object */
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 4 of 8] cwfs: use IOUNIT as MAXDAT, fix Msgbuf count overflow when MAXDAT > 2^15-1
2015-08-23 23:49 [PATCH 0 of 8] 48k iounit mischief
2015-08-23 23:49 ` [PATCH 1 of 8] devmnt: set MAXRPC to IOHDRSZ+48K mischief
2015-08-23 23:49 ` [PATCH 2 of 8] libc: define default IOUNIT as 48K mischief
@ 2015-08-23 23:49 ` mischief
2015-08-23 23:49 ` [PATCH 5 of 8] dossrv: set buffer size to IOUNIT mischief
` (3 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: mischief @ 2015-08-23 23:49 UTC (permalink / raw)
To: 9front
# HG changeset patch
# User mischief <mischief@offblast.org>
# Date 1440366687 25200
# Sun Aug 23 14:51:27 2015 -0700
# Node ID b7929f69bbb7120db5900fe38f717ccb433345fa
# Parent 59420710e4e3a510c41f6c7d4047a144d5491b42
cwfs: use IOUNIT as MAXDAT, fix Msgbuf count overflow when MAXDAT > 2^15-1
diff -r 59420710e4e3 -r b7929f69bbb7 sys/src/cmd/cwfs/portdat.h
--- a/sys/src/cmd/cwfs/portdat.h Sun Aug 23 14:51:27 2015 -0700
+++ b/sys/src/cmd/cwfs/portdat.h Sun Aug 23 14:51:27 2015 -0700
@@ -26,7 +26,7 @@
/* constants that don't affect disk layout */
enum {
- MAXDAT = 8192, /* max allowable data message */
+ MAXDAT = IOUNIT, /* max allowable data message */
MAXMSG = 128, /* max protocol message sans data */
MB = 1024*1024,
@@ -459,7 +459,7 @@
struct Msgbuf
{
ulong magic;
- short count;
+ int count;
short flags;
#define LARGE (1<<0)
#define FREE (1<<1)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 5 of 8] dossrv: set buffer size to IOUNIT
2015-08-23 23:49 [PATCH 0 of 8] 48k iounit mischief
` (2 preceding siblings ...)
2015-08-23 23:49 ` [PATCH 4 of 8] cwfs: use IOUNIT as MAXDAT, fix Msgbuf count overflow when MAXDAT > 2^15-1 mischief
@ 2015-08-23 23:49 ` mischief
2015-08-23 23:49 ` [PATCH 6 of 8] mv: use iounit for reads mischief
` (2 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: mischief @ 2015-08-23 23:49 UTC (permalink / raw)
To: 9front
# HG changeset patch
# User mischief <mischief@offblast.org>
# Date 1440366687 25200
# Sun Aug 23 14:51:27 2015 -0700
# Node ID b6676a7790ca84598ccc4e66856339710ab9b544
# Parent b7929f69bbb7120db5900fe38f717ccb433345fa
dossrv: set buffer size to IOUNIT
diff -r b7929f69bbb7 -r b6676a7790ca sys/src/cmd/dossrv/dosfs.h
--- a/sys/src/cmd/dossrv/dosfs.h Sun Aug 23 14:51:27 2015 -0700
+++ b/sys/src/cmd/dossrv/dosfs.h Sun Aug 23 14:51:27 2015 -0700
@@ -1,6 +1,6 @@
enum
{
- Maxfdata = 8192,
+ Maxfdata = IOUNIT,
Maxiosize = IOHDRSZ+Maxfdata,
};
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 6 of 8] mv: use iounit for reads
2015-08-23 23:49 [PATCH 0 of 8] 48k iounit mischief
` (3 preceding siblings ...)
2015-08-23 23:49 ` [PATCH 5 of 8] dossrv: set buffer size to IOUNIT mischief
@ 2015-08-23 23:49 ` mischief
2015-08-24 0:01 ` [9front] " Iruatã Souza
2015-08-23 23:49 ` [PATCH 7 of 8] tee: " mischief
2015-08-23 23:49 ` [PATCH 8 of 8] tput: use iounit for reads, check sbrk return value mischief
6 siblings, 1 reply; 10+ messages in thread
From: mischief @ 2015-08-23 23:49 UTC (permalink / raw)
To: 9front
# HG changeset patch
# User mischief <mischief@offblast.org>
# Date 1440366687 25200
# Sun Aug 23 14:51:27 2015 -0700
# Node ID 8a7a4824b69f9c20955f3b96a01c142801f5af1f
# Parent b6676a7790ca84598ccc4e66856339710ab9b544
mv: use iounit for reads
diff -r b6676a7790ca -r 8a7a4824b69f sys/src/cmd/mv.c
--- a/sys/src/cmd/mv.c Sun Aug 23 14:51:27 2015 -0700
+++ b/sys/src/cmd/mv.c Sun Aug 23 14:51:27 2015 -0700
@@ -167,9 +167,14 @@
int
copy1(int fdf, int fdt, char *from, char *to)
{
- char buf[8192];
+ int buflen;
+ char *buf;
long n, n1;
+ buflen = iounit(fdf);
+ if(buflen <= 0)
+ buflen = IOUNIT;
+
while ((n = read(fdf, buf, sizeof buf)) > 0) {
n1 = write(fdt, buf, n);
if(n1 != n){
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [9front] [PATCH 6 of 8] mv: use iounit for reads
2015-08-23 23:49 ` [PATCH 6 of 8] mv: use iounit for reads mischief
@ 2015-08-24 0:01 ` Iruatã Souza
2015-08-24 0:03 ` Nick Owens
0 siblings, 1 reply; 10+ messages in thread
From: Iruatã Souza @ 2015-08-24 0:01 UTC (permalink / raw)
To: 9front
[-- Attachment #1: Type: text/plain, Size: 957 bytes --]
Em 23/08/2015 20:52, "mischief" <mischief@offblast.org> escreveu:
>
> # HG changeset patch
> # User mischief <mischief@offblast.org>
> # Date 1440366687 25200
> # Sun Aug 23 14:51:27 2015 -0700
> # Node ID 8a7a4824b69f9c20955f3b96a01c142801f5af1f
> # Parent b6676a7790ca84598ccc4e66856339710ab9b544
> mv: use iounit for reads
>
> diff -r b6676a7790ca -r 8a7a4824b69f sys/src/cmd/mv.c
> --- a/sys/src/cmd/mv.c Sun Aug 23 14:51:27 2015 -0700
> +++ b/sys/src/cmd/mv.c Sun Aug 23 14:51:27 2015 -0700
> @@ -167,9 +167,14 @@
> int
> copy1(int fdf, int fdt, char *from, char *to)
> {
> - char buf[8192];
> + int buflen;
> + char *buf;
> long n, n1;
>
> + buflen = iounit(fdf);
> + if(buflen <= 0)
> + buflen = IOUNIT;
> +
> while ((n = read(fdf, buf, sizeof buf)) > 0) {
> n1 = write(fdt, buf, n);
> if(n1 != n){
You don't seem to reserve memory for buf here.
[-- Attachment #2: Type: text/html, Size: 1401 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [9front] [PATCH 6 of 8] mv: use iounit for reads
2015-08-24 0:01 ` [9front] " Iruatã Souza
@ 2015-08-24 0:03 ` Nick Owens
0 siblings, 0 replies; 10+ messages in thread
From: Nick Owens @ 2015-08-24 0:03 UTC (permalink / raw)
To: 9front
[-- Attachment #1: Type: text/plain, Size: 1159 bytes --]
woops, fixed. thanks.
On Sun, Aug 23, 2015 at 5:01 PM, Iruatã Souza <iru.muzgo@gmail.com> wrote:
>
> Em 23/08/2015 20:52, "mischief" <mischief@offblast.org> escreveu:
> >
> > # HG changeset patch
> > # User mischief <mischief@offblast.org>
> > # Date 1440366687 25200
> > # Sun Aug 23 14:51:27 2015 -0700
> > # Node ID 8a7a4824b69f9c20955f3b96a01c142801f5af1f
> > # Parent b6676a7790ca84598ccc4e66856339710ab9b544
> > mv: use iounit for reads
> >
> > diff -r b6676a7790ca -r 8a7a4824b69f sys/src/cmd/mv.c
> > --- a/sys/src/cmd/mv.c Sun Aug 23 14:51:27 2015 -0700
> > +++ b/sys/src/cmd/mv.c Sun Aug 23 14:51:27 2015 -0700
> > @@ -167,9 +167,14 @@
> > int
> > copy1(int fdf, int fdt, char *from, char *to)
> > {
> > - char buf[8192];
> > + int buflen;
> > + char *buf;
> > long n, n1;
> >
> > + buflen = iounit(fdf);
> > + if(buflen <= 0)
> > + buflen = IOUNIT;
> > +
> > while ((n = read(fdf, buf, sizeof buf)) > 0) {
> > n1 = write(fdt, buf, n);
> > if(n1 != n){
>
> You don't seem to reserve memory for buf here.
>
[-- Attachment #2: Type: text/html, Size: 1875 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 7 of 8] tee: use iounit for reads
2015-08-23 23:49 [PATCH 0 of 8] 48k iounit mischief
` (4 preceding siblings ...)
2015-08-23 23:49 ` [PATCH 6 of 8] mv: use iounit for reads mischief
@ 2015-08-23 23:49 ` mischief
2015-08-23 23:49 ` [PATCH 8 of 8] tput: use iounit for reads, check sbrk return value mischief
6 siblings, 0 replies; 10+ messages in thread
From: mischief @ 2015-08-23 23:49 UTC (permalink / raw)
To: 9front
# HG changeset patch
# User mischief <mischief@offblast.org>
# Date 1440366687 25200
# Sun Aug 23 14:51:27 2015 -0700
# Node ID eb135d711d3e30fa57cfa2c87d53a2ac1a1ee34d
# Parent 8a7a4824b69f9c20955f3b96a01c142801f5af1f
tee: use iounit for reads
diff -r 8a7a4824b69f -r eb135d711d3e sys/src/cmd/tee.c
--- a/sys/src/cmd/tee.c Sun Aug 23 14:51:27 2015 -0700
+++ b/sys/src/cmd/tee.c Sun Aug 23 14:51:27 2015 -0700
@@ -12,7 +12,9 @@
int uflag;
int aflag;
-char in[8192];
+
+int buflen;
+char *buf;
int intignore(void*, char*);
@@ -61,12 +63,20 @@
argv++;
}
+ buflen = iounit(0);
+ if(buflen <= 0)
+ buflen = IOUNIT;
+
+ buf = sbrk(buflen);
+ if(buf == (void*)-1)
+ sysfatal("out of memory");
+
for(;;) {
- r = read(0, in, sizeof in);
+ r = read(0, buf, buflen);
if(r <= 0)
exits(nil);
for(i=0; i<n; i++)
- write(i+FDSTART, in, r);
+ write(i+FDSTART, buf, r);
write(1, in, r);
}
}
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 8 of 8] tput: use iounit for reads, check sbrk return value
2015-08-23 23:49 [PATCH 0 of 8] 48k iounit mischief
` (5 preceding siblings ...)
2015-08-23 23:49 ` [PATCH 7 of 8] tee: " mischief
@ 2015-08-23 23:49 ` mischief
6 siblings, 0 replies; 10+ messages in thread
From: mischief @ 2015-08-23 23:49 UTC (permalink / raw)
To: 9front
# HG changeset patch
# User mischief <mischief@offblast.org>
# Date 1440366687 25200
# Sun Aug 23 14:51:27 2015 -0700
# Node ID 4d2e0315f59bc5153bd46690b0b43991f24ce121
# Parent eb135d711d3e30fa57cfa2c87d53a2ac1a1ee34d
tput: use iounit for reads, check sbrk return value
diff -r eb135d711d3e -r 4d2e0315f59b sys/src/cmd/tput.c
--- a/sys/src/cmd/tput.c Sun Aug 23 14:51:27 2015 -0700
+++ b/sys/src/cmd/tput.c Sun Aug 23 14:51:27 2015 -0700
@@ -1,10 +1,6 @@
#include <u.h>
#include <libc.h>
-int dopipe;
-int buflen = 8192;
-uvlong bc, sec;
-
void
usage(void)
{
@@ -16,9 +12,10 @@
main(int argc, char **argv)
{
double speed;
- int rc, cpid;
+ int rc, cpid, dopipe, buflen;
+ uvlong bc, sec;
char *buf;
-
+
ARGBEGIN {
case 'b':
buflen = atoi(EARGF(usage()));
@@ -32,10 +29,16 @@
if(argc != 0)
usage();
-
+
+ buflen = iounit(0);
+ if(buflen <= 0)
+ buflen = IOUNIT;
+
bc = 0;
sec = 0;
buf = sbrk(buflen);
+ if(buf == (void*)-1)
+ sysfatal("out of memory");
cpid = rfork(RFPROC | RFMEM);
if(cpid == 0) {
while(1) {
^ permalink raw reply [flat|nested] 10+ messages in thread