ref: 9150d2773fd3412940c7934dbd50dff01334434f
parent: 1d936770706311a00f52aef6dd5cfae76c6377b9
author: cinap_lenrek <[email protected]>
date: Sat Jul 18 23:32:38 EDT 2015
fcp: use iounit() to determine buffer size, reduce number of worker procs to 8
--- a/sys/src/cmd/fcp.c
+++ b/sys/src/cmd/fcp.c
@@ -1,8 +1,9 @@
#include <u.h>
#include <libc.h>
#define DEFB (8*1024)
-#define Nwork 16
+#define Nwork 8
+int buflen;
int failed;
int gflag;
int uflag;
@@ -130,6 +131,11 @@
failed = 1;
return;
}
+
+ buflen = iounit(fdf);
+ if(buflen <= 0)
+ buflen = DEFB;
+
if(copy1(fdf, fdt, from, to)==0 && (xflag || gflag || uflag)){
nulldir(&dirt);
if(xflag){
@@ -191,11 +197,16 @@
void
worker(int fdf, int fdt, char *from, char *to)
{
- char buf[DEFB], *bp;
+ char *buf, *bp;
long len, n;
vlong o;
- len = sizeof(buf);
+ len = buflen;
+ buf = malloc(len);
+ if(buf == nil){
+ fprint(2, "out of memory\n");
+ _exits(nil);
+ }
bp = buf;
o = nextoff();
@@ -212,11 +223,13 @@
o += n;
len -= n;
if(len == 0){
- len = sizeof buf;
+ len = buflen;
bp = buf;
o = nextoff();
}
}
+
+ free(buf);
_exits(nil);
}
@@ -227,7 +240,7 @@
qlock(&lk);
o = off;
- off += DEFB;
+ off += buflen;
qunlock(&lk);
return o;