fcp: use iounit() to determine buffer size, reduce number of worker procs to 8
This commit is contained in:
parent
1d93677070
commit
9150d2773f
1 changed files with 18 additions and 5 deletions
|
@ -1,8 +1,9 @@
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
#define DEFB (8*1024)
|
#define DEFB (8*1024)
|
||||||
#define Nwork 16
|
#define Nwork 8
|
||||||
|
|
||||||
|
int buflen;
|
||||||
int failed;
|
int failed;
|
||||||
int gflag;
|
int gflag;
|
||||||
int uflag;
|
int uflag;
|
||||||
|
@ -130,6 +131,11 @@ copy(char *from, char *to, int todir)
|
||||||
failed = 1;
|
failed = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buflen = iounit(fdf);
|
||||||
|
if(buflen <= 0)
|
||||||
|
buflen = DEFB;
|
||||||
|
|
||||||
if(copy1(fdf, fdt, from, to)==0 && (xflag || gflag || uflag)){
|
if(copy1(fdf, fdt, from, to)==0 && (xflag || gflag || uflag)){
|
||||||
nulldir(&dirt);
|
nulldir(&dirt);
|
||||||
if(xflag){
|
if(xflag){
|
||||||
|
@ -191,11 +197,16 @@ copy1(int fdf, int fdt, char *from, char *to)
|
||||||
void
|
void
|
||||||
worker(int fdf, int fdt, char *from, char *to)
|
worker(int fdf, int fdt, char *from, char *to)
|
||||||
{
|
{
|
||||||
char buf[DEFB], *bp;
|
char *buf, *bp;
|
||||||
long len, n;
|
long len, n;
|
||||||
vlong o;
|
vlong o;
|
||||||
|
|
||||||
len = sizeof(buf);
|
len = buflen;
|
||||||
|
buf = malloc(len);
|
||||||
|
if(buf == nil){
|
||||||
|
fprint(2, "out of memory\n");
|
||||||
|
_exits(nil);
|
||||||
|
}
|
||||||
bp = buf;
|
bp = buf;
|
||||||
o = nextoff();
|
o = nextoff();
|
||||||
|
|
||||||
|
@ -212,11 +223,13 @@ worker(int fdf, int fdt, char *from, char *to)
|
||||||
o += n;
|
o += n;
|
||||||
len -= n;
|
len -= n;
|
||||||
if(len == 0){
|
if(len == 0){
|
||||||
len = sizeof buf;
|
len = buflen;
|
||||||
bp = buf;
|
bp = buf;
|
||||||
o = nextoff();
|
o = nextoff();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(buf);
|
||||||
_exits(nil);
|
_exits(nil);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,7 +240,7 @@ nextoff(void)
|
||||||
|
|
||||||
qlock(&lk);
|
qlock(&lk);
|
||||||
o = off;
|
o = off;
|
||||||
off += DEFB;
|
off += buflen;
|
||||||
qunlock(&lk);
|
qunlock(&lk);
|
||||||
|
|
||||||
return o;
|
return o;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue