diff --git a/sbin/newfs/newfs.8 b/sbin/newfs/newfs.8 index 687d22e686cc..b046499c1ead 100644 --- a/sbin/newfs/newfs.8 +++ b/sbin/newfs/newfs.8 @@ -112,12 +112,10 @@ for more details on how to set this option. The block size of the file system, in bytes. It must be a power of 2. The default size is 8192 bytes, and the smallest allowable size is 4096 bytes. .It Fl c Ar #cylinders/group -The number of cylinders per cylinder group in a file system. The default value -is 22. The maximum value is dependent on a number of other parameters, in -particular the block size. The best way to find the maximum value for a -specific file system is to attempt to specify a value which is far too large: -.Nm -will print out the maximum value. +The number of cylinders per cylinder group in a file system. The default +is to compute the maximum allowed by the other parameters. This value is +dependent on a number of other parameters, in particular the block size +and the number of bytes per inode. .It Fl d Ar rotdelay This parameter once specified the minimum time in milliseconds required to initiate another disk transfer on the same cylinder. It was used in determining diff --git a/sbin/newfs/newfs.c b/sbin/newfs/newfs.c index a133f54355a8..b950f51aa89a 100644 --- a/sbin/newfs/newfs.c +++ b/sbin/newfs/newfs.c @@ -104,11 +104,10 @@ void fatal(); /* * Cylinder groups may have up to many cylinders. The actual * number used depends upon how much information can be stored - * on a single cylinder. The default is to use 22 cylinders - * per group, which seems to be the largest value allowed given - * all the other default values. + * on a single cylinder. The default is to use as many as possible + * cylinders per group. */ -#define DESCPG 22 /* desired fs_cpg */ +#define DESCPG 65536 /* desired fs_cpg ("infinity") */ /* * Once upon a time... @@ -167,6 +166,7 @@ int Uflag; /* enable soft updates for file system */ int fssize; /* file system size */ int ntracks = NTRACKS; /* # tracks/cylinder */ int nsectors = NSECTORS; /* # sectors/track */ +int ncyls; /* # complete cylinders */ int nphyssectors; /* # sectors/track including spares */ int secpercyl; /* sectors per cylinder */ int trackspares = -1; /* spare sectors per track */ @@ -180,7 +180,7 @@ int headswitch; /* head switch time, usec */ int trackseek; /* track-to-track seek, usec */ int fsize = 0; /* fragment size */ int bsize = 0; /* block size */ -int cpg = DESCPG; /* cylinders/cylinder group */ +int cpg = 0; /* cylinders/cylinder group */ int cpgflg; /* cylinders/cylinder group flag was given */ int minfree = MINFREE; /* free space threshold */ int opt = DEFAULTOPT; /* optimization preference (space or time) */ @@ -545,6 +545,17 @@ main(argc, argv) pp->p_size *= secperblk; } #endif + ncyls = fssize / secpercyl; + if (ncyls == 0) + ncyls = 1; /* XXX */ + if (cpg == 0) + cpg = DESCPG < ncyls ? DESCPG : ncyls; + else if (cpg > ncyls) { + cpg = ncyls; + printf( + "Number of cylinders restricts cylinders per group to %d.\n", + cpg); + } mkfs(pp, special, fsi, fso); #ifdef tahoe if (realsectorsize != DEV_BSIZE)