People still believe that it is essential to run sync(8) a couple of
times before a reboot/halt. Document that this has not been necessary
for a long time now.
MFC after: 2 weeks
Differential D33233
sync.8: Document that the "sync dance" is not a thing 0mp on Dec 2 2021, 12:12 PM. Authored by Tags None Referenced Files
Subscribers
Details People still believe that it is essential to run sync(8) a couple of MFC after: 2 weeks
Diff Detail
Event TimelineComment Actions Sounds good to have in there as these old misconceptions are still around. Approved from my side.
Comment Actions Suggested different wording for last paragraph.
Comment Actions Late to the party, but I find this passage rather obscure:
What does that refer to exactly? To typing only a single sync, as evoked in the previous paragraph ("The shutdown procedure involved running...")?
with something like: Comment Actions Since reboot and shutdown system calls were added just after v7, the sync 3 times dance is a placebo. It was marginally useful on v7 before powering off. It's existed in lore as being necessary when it hasn't been. And since all it does is schedule IO you can't use it to know data is on the disk. Comment Actions Yes, all of this was clear to me. I'm only talking about the formulation of the specific passage quoted above. I don't understand the mention of "one per line sync" in the quoted sentence, and I think it is confusing. My suggested text explicitly ties "placebo" to the sync-3-times dance, not to the use of sync before powering down the machine. I don't think the latter is a placebo: Of course, it doesn't guarantee that everything is on disk (and nothing prevents new buffers to become dirty between issuing the sync and the power off), but at least it speeds up the process, so the operator can wait less before pulling the plug in an almost safe manner. Do you consider that last part to be a placebo as well? Comment Actions There's almost no difference between sync; shutdown and just shutdow other than more typing. The latter does a sync first thing anyway (in the system call) so you may start the io a smidgen earlier with the former... but sync doesn't guarantee the io will be done before shutdown starts... so even doing them on sepatate lines might only gain you the time it takes you to type shutdown at the expense of typing 5 extra characters. Comment Actions The main difference is that you control the time you leave to the system to actually write to disk. Typing sync and then shutdown almost immediately indeed doesn't make much sense. Waiting for some seconds or much more does, if you know statistically that all writes will have finished by that chosen time. This new text suggests instead an empirical evaluation, but otherwise is the same idea:
I think my proposed formulation is essentially compatible with that. Revising it a little bit: Comment Actions Kinda yes, kinda know. sync ; shutdown is a shorthand that people have used. You are suggesting sync <time passes> shutdown, which is different.
Almost. The placebo was designed to take enough time for the worst case number of buffers that could be dirty, and there's some indirect evidence that it was 'by design to take time' rather than the other way around 'a process that also happened to take enough time'. The evidence for it being cause, rather than effect, is a bit weak though. "Typing sync three times before shutting the system off was designed to occupy the operator for enough time for all dirty buffers to make it to the disk in the absence of a safe shutdown command." |