Date: Mon, 29 Oct 2001 08:14:01 +1100 From: Peter Jeremy <peter.jeremy@alcatel.com.au> To: Mikhail Teterin <mi@aldan.algebra.com> Cc: obrien@FreeBSD.org, cvs-committers@FreeBSD.org, freebsd-arch@FreeBSD.org Subject: Re: cvs commit: src/sbin/newfs newfs.8 newfs.c Message-ID: <20011029081400.H75481@gsmx07.alcatel.com.au> In-Reply-To: <200110261630.f9QGTwa79290@aldan.algebra.com>; from mi@aldan.algebra.com on Fri, Oct 26, 2001 at 12:29:55PM -0400 References: <20011026153413.Z75481@gsmx07.alcatel.com.au> <200110261630.f9QGTwa79290@aldan.algebra.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2001-Oct-26 12:29:55 -0400, Mikhail Teterin <mi@aldan.algebra.com> wrote:
>On 26 Oct, Peter Jeremy wrote:
>> On Sun, Oct 14, 2001 at 07:42:32PM -0700, David O'Brien wrote:
>>>"-c" was a no-brainer as noone has ever argued that a low "-c" was
>>>prefered (that I've seen).
>>
>> I can think of one case: For small filesystems, I often reduce "-c" to
>> ensure that there are at least 2 cylinder groups (in case one
>> superblock gets corrupted). Where there are only 2-3 CG's, I might
>> juggle "-c" and the slice size to make the last CG the same size as
>> the other CGs.
>
>Why don't we make newfs apply this (and/or similar) heuristics by
>default -- when no options are specified?
The following patch will make newfs default to 2 cylinder groups where
a filesystem has 4 or more cylinders. (You probably don't want more
than 1 CG on smaller filesystems). If this results in excessively
large CPs, it will be reduced in mkfs(). For filesystems just over
twice the maximum size of a cylinder group, having cpg = ncyls/3
would give a more even spread, but would require a more extensive
change in mkfs(). It's obviously impractical for newfs to tweak the
partition size to suit itself.
Note: This patch is untested. It should apply to -stable as well, but
the line numbers for the 2nd hunk are too far out for patch(1) to
handle ("@@ -618,8 +622,14 @@" is the appropriate hunk header for
-stable). When manually applied to -stable, newfs compiles. (My
running -current is too out-of date to easily compile it).
Index: newfs.c
===================================================================
RCS file: /home/CVSROOT/src/sbin/newfs/newfs.c,v
retrieving revision 1.42
diff -u -r1.42 newfs.c
--- newfs.c 2001/10/04 12:24:18 1.42
+++ newfs.c 2001/10/28 20:52:29
@@ -102,12 +102,16 @@
#define DFL_BLKSIZE 8192
/*
- * 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 as many as possible
- * cylinders per group.
+ * Cylinder groups comprise an integral number of cylinders. The
+ * actual number used depends upon how much information can be stored
+ * on a single cylinder. The default is to have a single group for
+ * filesystems smaller than TINYFS cylinders and MINCGS cylinder
+ * groups otherwise. The actual number of cylinder groups may be
+ * larger than MINCGS due to restrictions on the number of cylinders
+ * per group.
*/
-#define DESCPG 65536 /* desired fs_cpg ("infinity") */
+#define TINYFS 4 /* Default to 1 CG below this size */
+#define MINCGS 2 /* Default to this many cylinder groups */
/*
* Once upon a time...
@@ -548,8 +552,14 @@
ncyls = fssize / secpercyl;
if (ncyls == 0)
ncyls = 1; /* XXX */
- if (cpg == 0)
- cpg = DESCPG < ncyls ? DESCPG : ncyls;
+ /*
+ * By default we try to create MINCGS cylinder groups. For
+ * tiny filesystems, this is impractical. On large filesystems,
+ * cpg will be further limited to the largest possible size
+ * (restricted by the blocks/inodes per group) within mkfs().
+ */
+ if (!cpgflg)
+ cpg = ncyls < TINYFS ? ncyls : (ncyls + MINCGS - 1) / MINCGS;
else if (cpg > ncyls) {
cpg = ncyls;
printf(
Peter
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011029081400.H75481>
