Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site rna.UUCP Path: utzoo!linus!philabs!cmcl2!rna!dan From: dan@rna.UUCP (Dan Ts'o) Newsgroups: net.unix-wizards Subject: Re: Voodoo Practices Message-ID: <401@rna.UUCP> Date: Thu, 23-May-85 01:04:20 EDT Article-I.D.: rna.401 Posted: Thu May 23 01:04:20 1985 Date-Received: Fri, 24-May-85 21:27:45 EDT References: <867@sdcsvax.UUCP> <> Reply-To: dan@rna.UUCP ( Ts'o) Organization: Rockefeller Neurobiology, NYC Lines: 35 Summary: In article <> john@x.UUCP (John Woods) writes: >> >> I have just begun to learn how to hack/program device drivers, >> and I seem to be seeing what might be called "voodoo" practices. >> By "voodoo" I mean practices that are done ``Because they Work''. >> 3 syncs during a reboot. >This one is my favorite nervous habit. I picked it up because I saw >someone else do it. When I finally asked "Why more than one?" I got this >answer: sync() does not wait until the last block leaves the write-behind >cache, it only schedules the blocks for flushing. The second time you type >sync(), the shell requests /bin/sync to be brought in from disk again, and >this read request gets queued AFTER all those write requests. Therefore, >when the second sync() executes, the first sync() is done (and the only Well on the UNIXs I know about this explanation is not quite correct. sync() (actually update() in the kernel) not only queues up the write requests but initiates it (in XXstrategy()). Thus the writes are completed as fast as the kernel/driver/hardware is capable of it. Furthermore, a second /bin/sync would probably just read from the buffer cache, since it was just read in from the first /bin/sync. What this means, though, is that it pays to wait a second or two after running /bin/sync to allow the hardware to do the writes (they are done asynchronously, unlike normal file I/O). I, too, run sync*3 just because I saw someone else do it. As a beginning UNIX hacker you are pounded with the idea that if you don't do a sync, every filesystem will be totally destroyed and you will have lost years of work. No wonder we are nervous and sync twice or three times. As an aside, I noticed that the 4.2BSD manual page for update(8) still carries that ol' BUGS message about how you can actually damage a filesystem by halting the CPU with update(8) running. Does anyone know if this problem is still valid for modern day DEC CPU's, buses and controllers. Dan