diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2021-06-03 06:42:04 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2021-06-03 06:42:04 +0000 |
commit | 748d445dbc51d46d4c439ff686daddade9324f4d (patch) | |
tree | cc5dc77ba2ab90cb2c66a49ce691b21ecb5a85ec /sbin | |
parent | 0aed04a051cfa9f40574b3149afeaf7d8ee7b149 (diff) |
For 4k sector disks, the minimum frag size is 4k. For a 2G fs
that delivers too few inodes to hold a src tree. So adjust the
density for partitions on a 4k disk if fragsize and density are not
passed on the command line. This is kind of a hack, since we do not
have a way to signal the desired # of inodes from the install script.
ok kettenis@ krw@
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/newfs/newfs.8 | 7 | ||||
-rw-r--r-- | sbin/newfs/newfs.c | 11 |
2 files changed, 13 insertions, 5 deletions
diff --git a/sbin/newfs/newfs.8 b/sbin/newfs/newfs.8 index d7af0fd616a..2ad76eca4b1 100644 --- a/sbin/newfs/newfs.8 +++ b/sbin/newfs/newfs.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: newfs.8,v 1.77 2020/05/18 06:20:44 otto Exp $ +.\" $OpenBSD: newfs.8,v 1.78 2021/06/03 06:42:03 otto Exp $ .\" $NetBSD: newfs.8,v 1.12 1995/03/18 14:58:41 cgd Exp $ .\" .\" Copyright (c) 1983, 1987, 1991, 1993, 1994 @@ -30,7 +30,7 @@ .\" .\" @(#)newfs.8 8.3 (Berkeley) 3/27/94 .\" -.Dd $Mdocdate: May 18 2020 $ +.Dd $Mdocdate: June 3 2021 $ .Dt NEWFS 8 .Os .Sh NAME @@ -167,7 +167,8 @@ The expected average file size for the file system in bytes. The expected average number of files per directory on the file system. .It Fl i Ar bytes This specifies the density of inodes in the file system. -The default is to create an inode for every 4 fragments. +The default is to create an inode for every 4 fragments, +for 4k disks one inode for every 2 fragments. If fewer inodes are desired, a larger number should be used; to create more inodes a smaller number should be given. .It Fl m Ar free-space diff --git a/sbin/newfs/newfs.c b/sbin/newfs/newfs.c index 1f279908886..76d254d35c1 100644 --- a/sbin/newfs/newfs.c +++ b/sbin/newfs/newfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: newfs.c,v 1.114 2020/05/19 12:49:51 sthen Exp $ */ +/* $OpenBSD: newfs.c,v 1.115 2021/06/03 06:42:03 otto Exp $ */ /* $NetBSD: newfs.c,v 1.20 1996/05/16 07:13:03 thorpej Exp $ */ /* @@ -191,6 +191,7 @@ main(int argc, char *argv[]) const char *errstr; long long fssize_input = 0; int fssize_usebytes = 0; + int defaultfsize; u_int64_t nsecs; if (strstr(__progname, "mfs")) @@ -468,6 +469,7 @@ havelabel: fssize = nsecs * (sectorsize / DEV_BSIZE); if (oflagset == 0 && fssize >= INT_MAX) Oflag = 2; /* FFS2 */ + defaultfsize = fsize == 0; if (fsize == 0) { fsize = DISKLABELV1_FFS_FSIZE(pp->p_fragblock); if (fsize <= 0) @@ -478,8 +480,13 @@ havelabel: if (bsize <= 0) bsize = MINIMUM(DFL_BLKSIZE, 8 * fsize); } - if (density == 0) + if (density == 0) { density = NFPI * fsize; + /* large sectors lead to fewer inodes due to large fsize, + compensate */ + if (defaultfsize && sectorsize > DEV_BSIZE) + density /= 2; + } if (minfree < MINFREE && opt != FS_OPTSPACE && reqopt == -1) { warnx("warning: changing optimization to space " "because minfree is less than %d%%\n", MINFREE); |