so. I added sync() calls after writing user data files, and my user has reported that the problem has gone away. I didn't do fsync() because the additional requirement to call fsync() on affected parent directories is an incredible pain when using c++ fstreams.
If my reading is correct, this seems deeply alarming! It implies that any file write operation that occurs up to five minutes before power is removed from a Raspberry Pi can be lost!
According to documentation somewhere or another, ext4 filesystems can delay the commit of file operations to storage for up to five minutes. (ext3 could delay for up to five seconds; ext2, infamously doesn't ever synch, so powering off pretty much guarantees loss of data).
If this is true, does this mean that ALL file operations on a raspberry pi are cached in memory, and can be lost if the system is powered off within five minutes of performing the file write?
Or am I just not privy to a Linux-ism that requires calls to sync() or fsynch() WHENEVER you write to a file?
If my reading is correct, this seems deeply alarming! It implies that any file write operation that occurs up to five minutes before power is removed from a Raspberry Pi can be lost!
According to documentation somewhere or another, ext4 filesystems can delay the commit of file operations to storage for up to five minutes. (ext3 could delay for up to five seconds; ext2, infamously doesn't ever synch, so powering off pretty much guarantees loss of data).
If this is true, does this mean that ALL file operations on a raspberry pi are cached in memory, and can be lost if the system is powered off within five minutes of performing the file write?
Or am I just not privy to a Linux-ism that requires calls to sync() or fsynch() WHENEVER you write to a file?
Statistics: Posted by rerdavies — Thu Sep 05, 2024 9:43 pm