does fsync(2) do anything or is it placebo? my use case is making sure a file is properly written when i expect the system to crash within (potentially less than) a second or so
@[email protected] i feel like there's some kernel facility that allows you to do what you're trying to do that's not fsync but i am completely blanking rn so i might just have made it up.

@puppygirlhornypost2 @lizzy AFAIK fsync() works just fine for most cases, but for "must hit disk ASAP" writes, O_DIRECT will bypass the write cache for a given fd, so as long as the fd is blocking, writes will block until the data hits disk. (I had to do that to an imaging program to make the progress bar work, and given the workload in question, going through the write cache and potentially flushing more useful things was pointless)

EDIT: the biggest problem with fsync is if it fails for some reason, because the spec doesn't say what happens in that case.

@becomethewaifu @puppygirlhornypost2 @lizzy my (not very well researched so possibly wrong) understanding was that O_DIRECT bypassed the page cache but not any disk controller caches (and perhaps even bio-level caches like dm-cache?) so you still need to fsync with that?