Yeah, that article is 15 years olde, and SSDs were not common at that point 
either and they add another layer of caching and erase and write in hardware 
blocks, not filesystem sectors.

Just to be clear, the thesis was intended to address saving document files, ie 
`document.c:write_data_to_disk()` which is not used for settings, temporary 
files, run script files, or any other detritus :-)

It might not hurt to add an `fsync()` to the `write_data_to_disk()` truncate 
and overwrite method for a local filesystem, but a lot of care needs to be put 
into what it might do to remote slow networked storage or if it will actually 
do anything in that case.  That should be a separate issue so those things can 
be considered before adding it, if at all.

IMO #3946 is simply Geany not getting to finish writing its settings between 
getting a close signal and the OS killing it with extreme prejudice  because it 
hasn't closed yet.  Even with SSDs, when shutdown is happening, lots of stuff 
is being written by all the processes being closed, the OS itself syncing the 
file systems, etc etc so there is not guarantee that Geany will get its data 
written to disk because the disk is so busy, and the CPU is so busy with all 
those processes closing Geany might not even get scheduled, so even if settings 
saving has `fsync()`, it simply won't have time to do it.  

The best solution is this PR to make saving settings atomic if it can and 
`fsync()`ed in any case.  It can still be lost if atomic is not possible in 
some cases and the truncate and overwrite doesn't finish, but its less likely.



-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3947#issuecomment-2354379101
You are receiving this because you are subscribed to this thread.

Message ID: <geany/geany/pull/3947/c2354379...@github.com>

Reply via email to