diff options
| author | bouyer <bouyer@NetBSD.org> | 2015-08-24 17:34:03 +0000 |
|---|---|---|
| committer | bouyer <bouyer@NetBSD.org> | 2015-08-24 17:34:03 +0000 |
| commit | 4c6a59c2755453f3570373d25b139b4b0f91b011 (patch) | |
| tree | e22b0bcdc26d28dae0701623c3027b570eeb3a66 /sbin/dump | |
| parent | 4eee6570b971899408b1b4c9b1b4f0ba565ac408 (diff) | |
Default the read block size (-k default value) to kern.maxphys (usually
64k these days). This gives a noticable performance boost on large filesystems.
Diffstat (limited to 'sbin/dump')
| -rw-r--r-- | sbin/dump/dump.8 | 8 | ||||
| -rw-r--r-- | sbin/dump/main.c | 7 | ||||
| -rw-r--r-- | sbin/dump/rcache.c | 17 |
3 files changed, 24 insertions, 8 deletions
diff --git a/sbin/dump/dump.8 b/sbin/dump/dump.8 index 9116ce2f1ac..84adf1baa7d 100644 --- a/sbin/dump/dump.8 +++ b/sbin/dump/dump.8 @@ -1,4 +1,4 @@ -.\" $NetBSD: dump.8,v 1.66 2015/04/28 09:48:30 prlw1 Exp $ +.\" $NetBSD: dump.8,v 1.67 2015/08/24 17:34:03 bouyer Exp $ .\" .\" Copyright (c) 1980, 1991, 1993 .\" Regents of the University of California. @@ -30,7 +30,7 @@ .\" .\" @(#)dump.8 8.3 (Berkeley) 5/1/95 .\" -.Dd February 19, 2012 +.Dd August 24, 2015 .Dt DUMP 8 .Os .Sh NAME @@ -207,7 +207,9 @@ dump. .It Fl k Ar read-blocksize The size in kilobytes of the read buffers, rounded up to a multiple of the file system block size. -Default is 32k. +Default is the value of the +.Xr sysctl 7 +kern.maxphys. .It Fl L Ar label The user-supplied text string .Ar label diff --git a/sbin/dump/main.c b/sbin/dump/main.c index d8c9718de49..a85458610ef 100644 --- a/sbin/dump/main.c +++ b/sbin/dump/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.71 2013/09/08 13:26:05 mlelstv Exp $ */ +/* $NetBSD: main.c,v 1.72 2015/08/24 17:34:03 bouyer Exp $ */ /*- * Copyright (c) 1980, 1991, 1993, 1994 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1991, 1993, 1994\ #if 0 static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/1/95"; #else -__RCSID("$NetBSD: main.c,v 1.71 2013/09/08 13:26:05 mlelstv Exp $"); +__RCSID("$NetBSD: main.c,v 1.72 2015/08/24 17:34:03 bouyer Exp $"); #endif #endif /* not lint */ @@ -47,6 +47,7 @@ __RCSID("$NetBSD: main.c,v 1.71 2013/09/08 13:26:05 mlelstv Exp $"); #include <sys/time.h> #include <sys/stat.h> #include <sys/mount.h> +#include <sys/sysctl.h> #include <ufs/ffs/fs.h> #include <ufs/ffs/ffs_extern.h> @@ -79,7 +80,7 @@ long dev_bsize = 1; /* recalculated below */ long blocksperfile; /* output blocks per file */ const char *host; /* remote host (if any) */ int readcache = -1; /* read cache size (in readblksize blks) */ -int readblksize = 32 * 1024; /* read block size */ +int readblksize = -1; /* read block size */ char default_time_string[] = "%T %Z"; /* default timestamp string */ char *time_string = default_time_string; /* timestamp string */ diff --git a/sbin/dump/rcache.c b/sbin/dump/rcache.c index b5e0cf24ff2..220cd2da372 100644 --- a/sbin/dump/rcache.c +++ b/sbin/dump/rcache.c @@ -1,4 +1,4 @@ -/* $NetBSD: rcache.c,v 1.24 2013/06/15 01:27:19 christos Exp $ */ +/* $NetBSD: rcache.c,v 1.25 2015/08/24 17:34:03 bouyer Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: rcache.c,v 1.24 2013/06/15 01:27:19 christos Exp $"); +__RCSID("$NetBSD: rcache.c,v 1.25 2015/08/24 17:34:03 bouyer Exp $"); #endif /* not lint */ #include <sys/types.h> @@ -98,6 +98,19 @@ initcache(int cachesize, int readblksize) size_t len; size_t sharedSize; + if (readblksize == -1) { /* use kern.maxphys */ + int kern_maxphys; + int mib[2] = { CTL_KERN, KERN_MAXPHYS }; + + len = sizeof(kern_maxphys); + if (sysctl(mib, 2, &kern_maxphys, &len, NULL, 0) < 0) { + msg("sysctl(kern.maxphys) failed: %s\n", + strerror(errno)); + return; + } + readblksize = kern_maxphys; + } + /* Convert read block size in terms of filesystem block size */ nblksread = howmany(readblksize, ufsib->ufs_bsize); |
