From: otto Date: Thu, 3 Jun 2021 06:42:03 +0000 (+0000) Subject: For 4k sector disks, the minimum frag size is 4k. For a 2G fs X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=83d1f4025fdeaeabdfe885a892e6527a860a5abc;p=openbsd 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@ --- 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);