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 @[email protected] yeah. it's slowly coming back together. i remember one of the frustrations here is due to page caching with block devices. there's several layers in which write cache exists and you just need something that can cut through the bs
@becomethewaifu @[email protected] bc u can have fs level (think something like zfs with ZiL), the page cache for block devices themselves and the controller for the drives. considering that this is for a system crash and not a power outage i dont think you have to worry about controller level (and/or drive level)
@puppygirlhornypost2 @lizzy ZIL isn't a cache, it's only read back when repairing after an unclean shutdown. It exists to provide the "scratch space" for immediately fsyncing writes without interfering with other portions of ZFS's internals. fsync flushes to ZIL, but as the ZIL is stable storage, the rest of the FS is free to take however long it wants to do the 'normal' TXG write.
@puppygirlhornypost2 @lizzy And disk controllers generally have write barriers so the host can at least know when they've actually flushed something, though a lot of cheaper SSDs will straight up lie about that "for performance" and trash your FS on a power cut.