i was moving ~400gb to a new other file system, and noticed that mkfs was extremely slow. it turns out that mkfs by default moves 1024-8 bytes at a time. i'm pretty sure this magical number turns out to be the default kfs block size minus the size of the tag (careful with that ax, eugene). ok, but this makes no sense when not extracting to a local kfs. and why do we need to write exactly 1 block at a time? what bug are we covering for? - erik ---- ; adiff mkfs.c /n/atom/plan9/sys/src/cmd/disk/mkfs.c:5,12 - mkfs.c:5,13 enum{ LEN = 8*1024, - HUNKS = 128, + Tagsize = 8, + /* * types of destination file sytems */ /n/atom/plan9/sys/src/cmd/disk/mkfs.c:65,71 - mkfs.c:66,72 int lineno; char *buf; char *zbuf; - int buflen = 1024-8; + int buflen; int indent; int verb; int modes; /n/atom/plan9/sys/src/cmd/disk/mkfs.c:148,154 - mkfs.c:149,155 xflag = 1; break; case 'z': - buflen = atoi(EARGF(usage()))-8; + buflen = atoi(EARGF(usage())); break; default: usage(); /n/atom/plan9/sys/src/cmd/disk/mkfs.c:156,161 - mkfs.c:157,178 if(!argc) usage(); + + switch(fskind){ + case Kfs: + /* + * preserve ancient hack for dflt block size; make room for tag + * why does this need to fit into 1 block? + */ + if(buflen == 0) + buflen = 1024; + buflen -= Tagsize; + break; + default: + if(buflen == 0) + buflen = 8192; + break; + } buf = emalloc(buflen); zbuf = emalloc(buflen); Reference: /n/atom/patch/applied/mkfsbufsize Date: Thu Jun 19 14:41:56 CES 2014 Signed-off-by: quanstro@quanstro.net --- /sys/src/cmd/disk/mkfs.c Thu Jun 19 14:40:23 2014 +++ /sys/src/cmd/disk/mkfs.c Thu Jun 19 14:40:23 2014 @@ -5,7 +5,8 @@ enum{ LEN = 8*1024, - HUNKS = 128, + + Tagsize = 8, /* * types of destination file sytems @@ -65,7 +66,7 @@ int lineno; char *buf; char *zbuf; -int buflen = 1024-8; +int buflen; int indent; int verb; int modes; @@ -148,7 +149,7 @@ xflag = 1; break; case 'z': - buflen = atoi(EARGF(usage()))-8; + buflen = atoi(EARGF(usage())); break; default: usage(); @@ -156,6 +157,22 @@ if(!argc) usage(); + + switch(fskind){ + case Kfs: + /* + * preserve ancient hack for dflt block size; make room for tag + * why does this need to fit into 1 block? + */ + if(buflen == 0) + buflen = 1024; + buflen -= Tagsize; + break; + default: + if(buflen == 0) + buflen = 8192; + break; + } buf = emalloc(buflen); zbuf = emalloc(buflen);