Subject: newfs(8) has too much hard coded information (+fix)
Index:	etc/newfs.c,doc/2.10/setup.2.11,man/man8/newfs.8, 2.11BSD

Description:
	The 'newfs' program has too much hard coded information in it.

	This means that adding a new drive type to /etc/disktab is
	not sufficient, the newfs.c program must also be edited and
	recompiled.

	Much of the information present in newfs.c is in the form of
	tables (indexed by cpu type) providing the 'm' and 'n' parameters 
	for the 'mkfs' command.  Also, several of the entries were
	incorrect, having 'm' values set too high or 'n' values too low.

	Extensive testing using a variety of processor/controller/drive
	combinations has demonstrated a rather complete insensitivity
	to 'm' as long as 'n' is one cylinder in size.  One test 
	demonstrated a monotonically increasing runtime as 'm' was varied
	from 1 thru 14 (with m=1 giving the lowest time).  The only test
	which exhibited a large degradation in time involved an RX50 (floppy)
	and those are extremely slow to begin with.

	The changes included below enable 'newfs' to correctly calculate the 'n'
	parameter using only information from /etc/disktab (the 'se', 'nt', and
	'ns' entries).  A default 'm' of 2 is used if another choice is
	not specified by the (new) '-m #' option.

		example: newfs -m 5 special disktype

	The "cpu" argument to 'newfs' is no longer used, all other options
	(-b, -B, -N) are still present.

	The tests and results are available via email if anyone is interested.

Repeat-By:
	Testing, examination of the code, adding a new drive to /etc/disktab
	and still having to modify 'newfs'.

Fix:
	The patch following will update the newfs program and the
	documentation (which includes both the manual page and setup documents).
	Apply the patch, recompile and install 'newfs' and the manual page.
---------------------------------------------------------------------------
*** /usr/doc/2.10/setup.2.11/2.t.old	Tue May 28 16:31:13 1991
--- /usr/doc/2.10/setup.2.11/2.t	Tue Dec 31 23:53:09 1991
***************
*** 2,8 ****
  .\" All rights reserved.  The Berkeley software License Agreement
  .\" specifies the terms and conditions for redistribution.
  .\"
! .\"	@(#)2.t	1.1 (Contel) 5/4/91
  .\"
  .ds lq ``
  .ds rq ''
--- 2,8 ----
  .\" All rights reserved.  The Berkeley software License Agreement
  .\" specifies the terms and conditions for redistribution.
  .\"
! .\"	@(#)2.t	1.2 (Contel) 12/31/91
  .\"
  .ds lq ``
  .ds rq ''
***************
*** 222,228 ****
  for about 10 seconds.
  .PP
  Finally, determine the proper interleaving factors \fIm\fP and \fIn\fP
! for your disk and CPU combination from the following table.
  These numbers determine the layout of the free list that will be constructed;
  the proper interleaving will help increase the speed of the file system.
  If you have a non-DEC disk that emulates one of the disks listed,
--- 222,238 ----
  for about 10 seconds.
  .PP
  Finally, determine the proper interleaving factors \fIm\fP and \fIn\fP
! for your disk from the following table.  Extensive testing has demonstrated
! that the choice of \fIm\fP is non critical (performance of a file system
! varying only by 3 to 4% for a wide range of \fIm\fP values).  Values for
! \fIm\fP within the range from  2 to 5 give almost identical performance.
! Increasing \fIm\fP too much actually causes degraded performance because
! the free blocks are too far apart.  Slower processors (such as the 73 and
! 44) may want to start with a \fIm\fP of 4 or 5, faster processors (such as the
! 70 and 84) may start with a \fIm\fP of 3 or 4.
! On the other
! hand, the \fIn\fP value is fairly important - it should be the number
! of filesystem blocks contained by one cylinder of the disc.
  These numbers determine the layout of the free list that will be constructed;
  the proper interleaving will help increase the speed of the file system.
  If you have a non-DEC disk that emulates one of the disks listed,
***************
*** 231,294 ****
  (rather than the controller mapping onto a different physical disk).
  Also, the rotational speed must be the same as the DEC disk
  for these numbers to apply.
  .KS
  .DS
  .TS
! cB s s s s s s s s
! l l l l l l l l l.
! Disk Interleaving Factors for Disk/CPU Combinations (\fIm\fP/\fIn\fP)
! CPU	23	24	34	40	44	45	53	55
  DISK
! RL01/2	7/10	6/10	6/10	6/10	4/10	5/10	4/10	5/10
! RK06/7	8/33	7/33	6/33	6/33	4/33	5/33	4/33	5/33
! RM02	11/80	10/80	8/80	8/80	6/80	7/80	6/80	7/80
! RM03	16/80	15/80	12/80	12/80	8/80	11/80	8/80	11/80
! RM05	16/304	15/304	12/304	12/304	8/304	11/304	8/304	11/304
! RP04/5/6	11/209	10/209	8/209	8/209	6/209	7/209	6/209	7/209
! RA60	21/84	21/84	17/84	17/84	12/84	15/84	12/84	15/84
! RA80	16/217	16/217	13/217	13/217	9/217	11/217	9/217	11/217
! RA81	26/357	26/357	21/357	21/357	14/357	18/357	14/357	17/357
! RA82	26/435	26/435	21/435	21/435	14/435	18/435	14/435	17/435
! RD51	1/36	1/36	1/36	1/36	1/36	1/36	1/36	1/36
! RQDX2\(ua	2/36	2/36	2/36	2/36	2/36	2/36	2/36	2/36
! RQDX3\(ua	7/36	7/36	7/36	7/36	7/36	7/36	7/36	7/36
! RC25	15/31	15/31	13/31	13/31	9/31	11/31	9/31	11/31
  .TE
- 
- .TS
- cB s s s s s
- l l l l l l.
- Disk Interleaving Factors for Disk/CPU Combinations (\fIm\fP/\fIn\fP)
- CPU	60	70	73	83	84	93	94
- DISK
- RL01/2	5/10	3/10	4/10	4/10	3/10	3/10	3/10
- RK06/7	5/33	3/33	4/33	4/33	3/33	3/33	3/33
- RM02	7/80	5/80	6/80	6/80	5/80	5/80	5/80
- RM03	11/80	7/80	9/80	9/80	7/80	7/80	7/80
- RM05	11/304	7/304	8/304	8/304	7/304	7/304	7/304
- RP04/5/6	7/209	5/209	6/209	6/209	5/209	5/209	5/209
- RA60	15/84	10/84	12/84	12/84	10/84	10/84	10/84
- RA80	11/217	7/217	9/217	9/217	7/217	7/217	7/217
- RA81	18/357	12/357	14/357	14/357	12/357	12/357	12/357
- RA82	18/435	12/435	14/435	14/435	12/435	12/435	12/435
- RD51	1/36	1/36	1/36	1/36	1/36	1/36	1/36
- RQDX2\(ua	2/36	2/36	2/36	2/36	2/36	2/36	2/36
- RQDX3\(ua	7/36	7/36	7/36	7/36	7/36	7/36	7/36
- RC25	11/31	7/31	9/31	9/31	7/31	7/31	7/31
- .TE
  .DE
  .KE
  .sp
- .FS
- .IP \(ua
- \fIm\fP/\fIn\fP numbers for RD52/53/54's are based on controller type
- (RQDX2 or RQDX3) rather than drive type.
- .FE
  For example, for an RP06 on an 11/70, \fIm\fP is 7 and \fIn\fP is 209.
  See
  \fImkfs\fP\|(8)
  for more explanation of the values of \fIm\fP and \fIn\fP.
  For \fIm\fP/\fIn\fP numbers for other drive types see \fI/etc/disktab\fP.
  .PP
  Then run the standalone version of the \fImkfs\fP (8) program.
  In the following procedure, substitute the correct types
--- 241,286 ----
  (rather than the controller mapping onto a different physical disk).
  Also, the rotational speed must be the same as the DEC disk
  for these numbers to apply.
+ .PP
+ The earlier tables went into great detail specifying separate tables for
+ each cpu type.  This is not necessary.  In several cases the \fIm\fP
+ values were too high or the \fIn\fP values were too low.  The following
+ table specifies the \fIn\fP parameter only.  The \fIm\fP parameter selection
+ was explained in a previous paragraph.
  .KS
  .DS
  .TS
! cB s
! l l.
! Disk Interleaving Factor for Disk/CPU Combinations (\fIn\fP)
  DISK
! RL01/2	20
! RK06/7	33
! RM02	80
! RM03	80
! RM05	304
! RP04/5/6	209
! RA60	84
! RA80	217
! RA81	357
! RA82	435
! RD51	36
! RD52	63
! RD53	72
! RD54	127
! RC25	31
  .TE
  .DE
  .KE
  .sp
  For example, for an RP06 on an 11/70, \fIm\fP is 7 and \fIn\fP is 209.
  See
  \fImkfs\fP\|(8)
  for more explanation of the values of \fIm\fP and \fIn\fP.
  For \fIm\fP/\fIn\fP numbers for other drive types see \fI/etc/disktab\fP.
+ \fIn\fP would be calculated using the \fBnt\fP and \fBns\fP parameters
+ from \fI/etc/disktab\fP.  For a disc with 512 byte sectors compute \fIn\fP
+ by multiplying \fBns\fP times \fBnt\fP and dividing the result by 2.
  .PP
  Then run the standalone version of the \fImkfs\fP (8) program.
  In the following procedure, substitute the correct types
***************
*** 556,567 ****
  .DE
  .FS
  .IP \(ua
- The type of controller the RD52 and RD53 are on (RQDX2 or RQDX3) must
- be specified for proper file system free list spacing to be computed.  If
- you don't know what controller your RD is on, it is all right to guess,
- though the created file system may not perform as well.  The RD54 requires
- the RQDX3 controller not the RQDX2.
- .IP \(dd
  Unfortunately the \fInewfs\fP(8) program is relatively primitive and
  doesn't know the free list spacing for these non-DEC drives.  An
  appropriate \fImkfs\fP(8) command will have to be substituted for the
--- 548,553 ----
***************
*** 569,592 ****
  [hopefully] appropriate free list \fIm/n\fP numbers for some non-DEC
  disks.
  .FE
- Find the type of cpu that you have in the following table and
- commands in the right hand portion of the table:
- .DS
- .TS
- l l.
- PDP-11	Command
- ---	-------
- 44	\fB#\fP cpu=44
- 45	\fB#\fP cpu=45
- 55	\fB#\fP cpu=45
- 70	\fB#\fP cpu=70
- 73	\fB#\fP cpu=73
- 83	\fB#\fP cpu=83
- 84	\fB#\fP cpu=84
- 93	\fB#\fP cpu=93
- 94	\fB#\fP cpu=94
- .TE
- .DE
  Find the tape you have in the following table and execute the
  commands in the right hand portion of the table:
  .DS
--- 555,560 ----
***************
*** 612,619 ****
  \fBNew password:\fP	(password will not echo)
  \fBRetype new password:\fP
  \fB#\fP hostname \fImysitename\fP	(set your hostname)
! \fB#\fP newfs ${name} ${type} ${cpu}	(create empty user file system)
  (this takes a few minutes)
  \fB#\fP mount /dev/${name} /usr	(mount the usr file system)
  \fB#\fP cd /usr	(make /usr the current directory)
  \fB#\fP mt rew
--- 580,590 ----
  \fBNew password:\fP	(password will not echo)
  \fBRetype new password:\fP
  \fB#\fP hostname \fImysitename\fP	(set your hostname)
! \fB#\fP newfs ${name} ${type}  (create empty user file system)
  (this takes a few minutes)
+ (if you wish to specify a different \fIm\fP value, use a command of the 
+  form: newfs -m # ${name} ${type}
+  where # is the \fIm\fP parameter and must be between 1 and 31)
  \fB#\fP mount /dev/${name} /usr	(mount the usr file system)
  \fB#\fP cd /usr	(make /usr the current directory)
  \fB#\fP mt rew
*** /usr/doc/2.10/setup.2.11/4.t.old	Tue May 28 16:27:36 1991
--- /usr/doc/2.10/setup.2.11/4.t	Tue Dec 31 23:55:47 1991
***************
*** 443,450 ****
  .DS
  \fB#\fP cd /dev
  \fB#\fP MAKEDEV ra1
! \fB#\fP newfs ra1c ra80 \fIcpu_type\fP
  (information about file system prints out)
  \fB#\fP mkdir /mnt
  \fB#\fP mount /dev/ra1c /mnt
  .DE
--- 443,452 ----
  .DS
  \fB#\fP cd /dev
  \fB#\fP MAKEDEV ra1
! \fB#\fP newfs ra1c ra80
  (information about file system prints out)
+ (to specify an alternate \fIm\fP value: newfs -m # ra1c ra80)
+ (where # is between 1 and 31)
  \fB#\fP mkdir /mnt
  \fB#\fP mount /dev/ra1c /mnt
  .DE
*** /usr/src/man/man8/newfs.8.old	Mon Aug 22 18:26:38 1988
--- /usr/src/man/man8/newfs.8	Sat Dec 28 22:27:33 1991
***************
*** 2,10 ****
  .\" All rights reserved.  The Berkeley software License Agreement
  .\" specifies the terms and conditions for redistribution.
  .\"
! .\"	@(#)newfs.8	6.3 (Berkeley) 5/21/86
  .\"
! .TH NEWFS 8 "May 21, 1986"
  .UC 5
  .SH NAME
  newfs \- construct a new file system
--- 2,10 ----
  .\" All rights reserved.  The Berkeley software License Agreement
  .\" specifies the terms and conditions for redistribution.
  .\"
! .\"	@(#)newfs.8	7.0 (Berkeley) 12/28/91
  .\"
! .TH NEWFS 8 "December 28, 1991"
  .UC 5
  .SH NAME
  newfs \- construct a new file system
***************
*** 14,25 ****
  .B \-N
  ]
  [
  .B \-b
  ]
  [
  .B \-B bootblock
  ]
! .B special disk-type cpu-type
  .SH DESCRIPTION
  .I Newfs
  is a ``friendly'' front-end to the
--- 14,28 ----
  .B \-N
  ]
  [
+ .B \-m free-gap
+ ]
+ [
  .B \-b
  ]
  [
  .B \-B bootblock
  ]
! .B special disk-type
  .SH DESCRIPTION
  .I Newfs
  is a ``friendly'' front-end to the
***************
*** 34,39 ****
--- 37,43 ----
  parameters to use in calling
  .IR mkfs ,
  then build the file system by forking \fImkfs\fP.
+ .PP
  The
  .I \-N
  option causes the file system parameters to be printed out
***************
*** 40,46 ****
  without actually creating the file system.
  .PP
  The
! .IR \-b and \-B
  options specify that a primary block zero bootstrap should be installed in
  block zero of
  .IR special .
--- 44,70 ----
  without actually creating the file system.
  .PP
  The
! .I \-m
! option allows the specification of the block interleaving of the free list
! (the
! .I m
! parameter of 
! .IR mkfs ).
! If not specified or outside the range 0 thru 31 then 
! .I m
! is given a value of 2.
! The 
! .I n
! parameter to 
! .I mkfs
! is calcuated by
! .I newfs
! to be 1 cylinder in size.
! .PP
! The
! .IR \-b 
! and
! .IR \-B
  options specify that a primary block zero bootstrap should be installed in
  block zero of
  .IR special .
***************
*** 51,56 ****
--- 75,81 ----
  .I newfs
  will attempt to use a default boot block (defined in
  .IR /etc/disktab ).
+ .PP
  The
  .I \-B
  option allows one to specify the file to read the boot block from
***************
*** 59,67 ****
  .PP
  	\fBdd if=\fIbootblock\fB of=\fIspecial\fB bs=512 count=1 conv=sync\fR
  .PP
- \fINewfs\fP without arguments will print a list of the disk and cpu
- types that it is familiar with.
- .PP
  .SH FILES
  /etc/disktab	for disk geometry and file system partition information 
  .br
--- 84,89 ----
***************
*** 69,83 ****
  .br
  /mdec/*	block zero bootstraps
  .SH "SEE ALSO"
! disktab(5), fs(5), diskpart(8), fsck(8), format(8), mkfs(8), tunefs(8)
  .SH BUGS
- Should figure out the disk and cpu types without the user's help.
- .PP
- The standard 4.3BSD C libarary disktab structure, as declared in
- \fI/usr/include/disktab.h\fP, was not sufficient to convey the
- information the PDP-11 needs, such as the relationship between the cpu
- type and the M/N values.  Therefore, the relevant values were
- extracted from the \fI/etc/disktab\fP file and hardwired into the
- \fInewfs\fP program.  If you have an unknown disk or cpu type, you
- may want to read through \fI/etc/disktab\fP and \fInewfs\fP to find
- a similar disk or cpu.
--- 91,95 ----
  .br
  /mdec/*	block zero bootstraps
  .SH "SEE ALSO"
! disktab(5), fs(5), diskpart(8), fsck(8), format(8), mkfs(8)
  .SH BUGS
