[net.bugs.usg] System III ialloc

peachey (03/22/83)

	There appears to be a bug in the ialloc() subroutine of
	the System III alloc.c source file.  s_inode[0] is used
	as a "low water mark" of free inodes.  It is necessary to
	compute the inode number "ino" for the first inode in the
	same block as s_inode[0].  The code used is

	ino = (fp->s_inode[0]&~7) + 1;

	This code gives an incorrect value if the s_inode[0] is
	the last inode of a block.  The correct code is

	ino = ((fp->s_inode[0] - 1) & ~(INOPB-1)) + 1;

	(where it is assumed that INOPB is a power of 2).

	The effect of the bug would be to miss one free inode in
	the disk scan for free inodes that is done when s_inode
	becomes empty.  Moreover, the inode is missed only if
	(s_inode[0] & 07) == 0.  Thus, the fix is more important
	esthetically than practically.

				Darwyn Peachey
				Hospital Systems Study Group

				harpo!utah-cs!sask!hssg40!peachey
				OR
				decvax!utzoo!utcsrgv!sask!hssg40!peachey