summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>2000-10-17 00:41:36 +0000
committerpeter <peter@FreeBSD.org>2000-10-17 00:41:36 +0000
commit72a496d998e780a1ca5c7e154625638b187c28fb (patch)
tree96a6e57cda36b28c6b68d1ed7ccec4beba585cfc /sbin
parentf891ccb78e8c209dd34b173b5293831c84961b0f (diff)
downloadFreeBSD-src-72a496d998e780a1ca5c7e154625638b187c28fb.zip
FreeBSD-src-72a496d998e780a1ca5c7e154625638b187c28fb.tar.gz
Implement simple write combining for newfs - this is particularly useful
for large scsi disks with WCE = 0. This yields around a 7 times speedup on elapsed newfs time on test disks here. 64k clusters seems to be the sweet spot for scsi disks using our present drivers.
Diffstat (limited to 'sbin')
-rw-r--r--sbin/newfs/mkfs.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c
index 615b5c2..fea37d6 100644
--- a/sbin/newfs/mkfs.c
+++ b/sbin/newfs/mkfs.c
@@ -1324,6 +1324,11 @@ rdfs(bno, size, bf)
}
}
+#define WCSIZE (128 * 1024)
+daddr_t wc_sect; /* units of sectorsize */
+int wc_end; /* bytes */
+static char wc[WCSIZE]; /* bytes */
+
/*
* write a block to the file system
*/
@@ -1334,6 +1339,7 @@ wtfs(bno, size, bf)
char *bf;
{
int n;
+ int done;
if (mfs) {
memmove(membase + bno * sectorsize, bf, size);
@@ -1341,6 +1347,37 @@ wtfs(bno, size, bf)
}
if (Nflag)
return;
+ done = 0;
+ if (wc_end == 0 && size <= WCSIZE) {
+ wc_sect = bno;
+ bcopy(bf, wc, size);
+ wc_end = size;
+ if (wc_end < WCSIZE)
+ return;
+ done = 1;
+ }
+ if (wc_sect * sectorsize + wc_end == bno * sectorsize &&
+ wc_end + size <= WCSIZE) {
+ bcopy(bf, wc + wc_end, size);
+ wc_end += size;
+ if (wc_end < WCSIZE)
+ return;
+ done = 1;
+ }
+ if (wc_end) {
+ if (lseek(fso, (off_t)wc_sect * sectorsize, SEEK_SET) < 0) {
+ printf("seek error: %ld\n", (long)wc_sect);
+ err(35, "wtfs - writecombine");
+ }
+ n = write(fso, wc, wc_end);
+ if (n != wc_end) {
+ printf("write error: %ld\n", (long)wc_sect);
+ err(36, "wtfs - writecombine");
+ }
+ wc_end = 0;
+ }
+ if (done)
+ return;
if (lseek(fso, (off_t)bno * sectorsize, SEEK_SET) < 0) {
printf("seek error: %ld\n", (long)bno);
err(35, "wtfs");
OpenPOWER on IntegriCloud