4.2BSD installation mystery ...

Dave Martindale dmmartindale at watrose.UUCP
Sat Dec 10 06:39:39 AEST 1983


In ALL versions of UNIX that I know of, the kernel has no idea of any
sort of correspondence between disk blocks accessed via the "block"
and "character"/"raw" devices.  They are completely different interfaces
as far as the system is concerned, and there is no locking of updates
between them.  References to the "raw" device ALWAYS read/write data
directly from disk to memory or vice versa; references to the "block"
device always go through the buffer cache.  If you do a write on the
block device, doing a sync will ensure that it has been written out and
so it will be there for any subsequent reads of either device.  But if
a particular block is already in the buffer cache, there is no way of
convincing the kernel that it is an invalid copy of the disk data after
you've written the block using the raw device.  Thus, reads of that block
using the block interface will give you the old data as long as the
block remains in the cache.

Yet another effect is that most versions of UNIX keep the superblock
of a mounted filesystem in a secret buffer in memory, that is not part
of the buffer cache.  If you update the superblock in the cache with
the block device interface, you still haven't updated the superblock
that the kernel deals with.  The only way you can safely fsck a filesystem
is with it NOT MOUNTED - then the kernel doesn't have the secret copy.
4.1BSD did not have this problem, but it seems to be back in 4.2BSD.

	Dave Martindale



More information about the Comp.bugs.4bsd.ucb-fixes mailing list