On Sun, Aug 25, 2024 at 11:55 PM Tim via users users@lists.fedoraproject.org wrote:
Fulko Hew:
But 'shutdown' provided all the housekeeping work such as:
- disabling logins
- sending out messages to users screen warning them of the impending
doom
- providing grace time
- unmounted file systems
- killed the system
Patrick O'Callaghan:
Same here. However these are reasonable measures on a multi-user system. On a single-user desktop they just get in the way, especially with journal-based filesystems.
Things really oughta order unmounts, unmounts should happen pretty quickly, be flagged as done, and the progress of shutting down be monitored. Not, order unmounts, wait some time, and assume it worked. Likewise for various other shutdowns.
Things may have terminated almost instantly without issues, things may have jammed and it still wouldn't have waited long enough. If something sticks you really ought to be prompted about it. If you don't have network mounts, databases running, mail servers currently dealing with a queue, etc, I see no excuses for prolonged shutdowns.
I think part of the problem is the behavior of sync(8) and sync(2) (which the sync command uses) are poorly specified.[1,2] The man pages don't even clearly state whether the command or api call block or return immediately. If it blocks until complete, then the sync family are synchronous; if they return immediately they are asynchronous. If the sync family is asynchronous (returns immediately), then a script will need to insert sleeps in hopes there's enough time for the write-backs to get done.
The sync(2) man page does say this:[2]
According to the standard specification (e.g., POSIX.1-2001), sync() schedules the writes, but may return before the actual writing is done. However, since version 1.3.20 Linux does actually wait. (This still does not guarantee data integrity: modern disks have large caches.)
But that leaves additional questions since the wait or blocking appears to be an incomplete wait.
[1] https://linux.die.net/man/8/sync [2] https://linux.die.net/man/2/sync
Jeff