[net.bugs.usg] another bug in mkfs

wescott@ncrcae.UUCP (Mike Wescott) (03/21/85)

mkfs as distributed in SysVr2 has a minor bug.  If you invoke mkfs

	mkfs /dev/rdsk/0s4 fssize latency cylsize

where fssize = N * cylsize + 2.  That is, the filesystem is a multiple
of the cylinder size plus 2 (assuming cylsize is even, odd cylsize is
a different problem).  The mkfs, in this case, produces a filesystem with
the last block missing (fsck complains, and fixes). 

In mkfs.c/bflist() you have:

	    .
	    .
	    .
	bfree((daddr_t)0);
	filsys->s_tfree = 0;
	d = filsys->s_fsize-1;
	while(d%f_n)
		d++;
	    .
	    .
Change to:
	    .
	bfree((daddr_t)0);
	filsys->s_tfree = 0;
	d = filsys->s_fsize; /* don't miss the last one */
	while(d%f_n)
		d++;
	    .


The problem with odd cylinder sizes is that mkfs when making 1-Kb block
filesystems divides cylsize by 2 and ignores the remainder.  This leads 
to a performance degradation because the freelist organization loses track
of where the physical cylinder boundaries are.  In the middle of the 
freelist excessive seeks take place as the freelist is allocated.

One fix is to allocate the freelist so that the oddball blocks that
straddle cylinders are allocated first (and are put at the end of the
freelist). And the allocate the rest with careful consideration to the 
actual number of sectors on the cylinder.  The fix needs to be applied
to fsck and dcopy as well.  I don't have fixes coded for dcopy, and
I think that the fixes to fsck and mkfs are to big to post (too much
Bell code).

Odd cylinder sizes pop up on the 5" drives where we have 7 heads and
17 sectors/track.  Also we have seen some 8" drives with 33 sectors/track
with such long head switch times to make it desirable to tell mkfs that
cylsize was the tracksize.

	Mike Wescott
	ncrcae!wescott