4.2 fsck and /etc/rc question

Steve Glaser steveg at hammer.UUCP
Sun Feb 10 08:20:28 AEST 1985


In article <649 at turtlevax.UUCP> Ed(mund) Trujillo @ CADLINC, Menlo Park writes:

>Why does the following scenario happen under 4.2 running on a vax 750?
>
>At boot time,  fsck finds out that the root file system was modified so 
>it exits with a condition code of 4 that is passed on to /etc/rc which 
>immediately does an /etc/reboot -n.  According to the documentation for
>reboot the -n option avoids the sync.  Why then does fsck do a sync() 
>before the call to exit(4) ???  Is there a logical reason for this?

4.2 fsck uses the cooked device on the fsck of the root filesystem.
When fsck is done, if it had to modify the superblock of the filesystem
there will be TWO copies of the superblock around in kernel memory.
One is the copy kept by the kernel cause the file system is mounted and
the other is a normal block in the block buffer cache due to the write
by fsck when it fixed the superblock.  The sync(2) system call will out
BOTH of these copies (and always has).  The trick on 4.2 (4.1 too?) is
that they the kernel makes sure that the block buffer version gets
written out *after* the other one.  Thus the sync inside fsck is
correct and gets the updated stiff onto the disk.

You must then avoid all syncs until the reboot cause the copy in the
block buffer cache is no longer marked dirty (cause the sync in fsck
wrote it out and nobody has changed it since then).  Thus another sync
would write out the wrong copy of the superblock onto disk, undoing
some of the work that fsck just did.

Summary: this is a case where one sync (inside fsck) is correct and
more than one will undo some of the work fsck just did for you.

Disclaimer: I'm not saying that I *like* this scheme.  It works, but
seems kinda fragile.  At bare minimum, it should be documented and the
"new expanded" semantics of sync(2) should be guaranteed by all future
systems.

	Steve Glaser
	tektronix!steveg



More information about the Comp.unix.wizards mailing list