Date: Thu, 20 Sep 2001 18:14:23 +0200 From: Ollivier Robert <roberto@eurocontrol.fr> To: freebsd-arch@freebsd.org Subject: New option for newfs Message-ID: <20010920181423.A99633@caerdonn.eurocontrol.fr>
next in thread | raw e-mail | index | archive | help
I want to add a new option to newfs in order to maximise the number of
cylinders per cg (to reduce fragmentation and head movement).
Right now, one can use '-c' to specify another value but
1. the default is 22 (calculated for a 8k/1k FS) regardless of the FS
(i.e. it will still be 22 even though you choose a 16k/2k FS).
2. newfs barfs when '-c' argument is too high.
Proposal: a new option ('-M') that says: ignore -c if present, calculate
the maxcpg allowed for the given argument to newfs and use that.
Here is a diff and and example.
Comments ?
662 [18:11] roberto@caerdonn:sbin/newfs> /usr/obj/src/src/sbin/newfs/newfs -M -N -b 16384 -f 4096 -c 20 /dev/da0s1h
Warning: -c is ignored when -M is specified
Warning: Block size and bytes per inode restrict cylinders per group to 159.
Warning: 624 sector(s) in last cylinder unallocated
/dev/da0s1h: 9174416 sectors in 2240 cylinders of 1 tracks, 4096 sectors
4479.7MB in 15 cyl groups (159 c/g, 318.00MB/g, 19072 i/g)
super-block backups (for fsck -b #) at:
32, 651296, 1302560, 1953824, 2605088, 3256352, 3907616, 4558880, 5210144, 5861408,
6512672, 7163936, 7815200, 8466464, 9117728
Index: mkfs.c
===================================================================
RCS file: /home/ncvs/src/sbin/newfs/mkfs.c,v
retrieving revision 1.40
diff -u -2 -r1.40 mkfs.c
--- mkfs.c 20 Aug 2001 14:53:05 -0000 1.40
+++ mkfs.c 20 Sep 2001 15:51:23 -0000
@@ -91,4 +91,5 @@
* variables set up by front end.
*/
+extern int Mflag; /* take as many cpg as possible */
extern int Nflag; /* run mkfs without writing file system */
extern int Oflag; /* format as an 4.3BSD file system */
@@ -454,6 +455,11 @@
printf("Bytes per inode restrict");
printf(" cylinders per group to %d.\n", sblock.fs_cpg);
- if (cpgflg)
- exit(27);
+ if (Mflag) {
+ cpg = sblock.fs_cpg;
+ }
+ else {
+ if (cpgflg)
+ exit(27);
+ }
}
sblock.fs_cgsize = fragroundup(&sblock, CGSIZE(&sblock));
Index: newfs.c
===================================================================
RCS file: /home/ncvs/src/sbin/newfs/newfs.c,v
retrieving revision 1.40
diff -u -2 -r1.40 newfs.c
--- newfs.c 19 Aug 2001 08:19:37 -0000 1.40
+++ newfs.c 20 Sep 2001 16:06:07 -0000
@@ -110,4 +110,5 @@
*/
#define DESCPG 22 /* desired fs_cpg */
+#define MAXCPG 999 /* unrealistic value */
/*
@@ -162,4 +163,5 @@
#define NSECTORS 4096 /* number of sectors */
+int Mflag; /* take as many cpg as you can */
int Nflag; /* run without writing file system */
int Oflag; /* format as an 4.3BSD file system */
@@ -232,7 +234,11 @@
progname = *argv;
- opstring = "NOS:T:Ua:b:c:d:e:f:g:h:i:k:l:m:n:o:p:r:s:t:u:vx:";
+ opstring = "MNOS:T:Ua:b:c:d:e:f:g:h:i:k:l:m:n:o:p:r:s:t:u:vx:";
while ((ch = getopt(argc, argv, opstring)) != -1)
switch (ch) {
+ case 'M':
+ Mflag = 1;
+ cpg = MAXCPG;
+ break;
case 'N':
Nflag = 1;
@@ -266,4 +272,8 @@
break;
case 'c':
+ if (Mflag) {
+ printf("Warning: -c is ignored when -M is specified\n");
+ break;
+ }
if ((cpg = atoi(optarg)) <= 0)
fatal("%s: bad cylinders/group", optarg);
@@ -652,4 +662,6 @@
#endif
fprintf(stderr, "where fsoptions are:\n");
+ fprintf(stderr,
+ "\t-M use as many cylinders per group as possible (-c is ignored)\n");
fprintf(stderr,
"\t-N do not create file system, just print out parameters\n");
--
Ollivier ROBERT -=- Eurocontrol EEC/ITM -=- Ollivier.Robert@eurocontrol.fr
FreeBSD caerdonn.eurocontrol.fr 5.0-CURRENT #46: Wed Jan 3 15:52:00 CET 2001
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?20010920181423.A99633>
