3 ms·
> fsync does not work because it returns when everything (in the same thread? or whatever) has been written to disk, and doesn't let you wait for a particular b
by maxlybbert 13y ago
> fsync does not work because it returns when everything (in the same thread? or whatever) has been written to disk, and doesn't let you wait for a particular block to have been written.
I believe fsync is per-file (or, really, per-file descriptor). I wasn't familiar with this specific problem, but I believe the problem is that for fsync to work, it has to issue commands to the hardware to flush hardware buffers to disk. Apparently that isn't well targeted in Linux, and has the effect that calling fsync on a file can slow down other threads and processes that happen to be writing to that same disk, even if they're writing to a different file.
- SamReidHughes 13y agoWell even doing it on a file is bad. It's per file, but also, it's (necessarily) the in-core state of that file, as a Linux man page says. So if you do a write on one thread, wait for that write to complete, and then signal another thread to do an fsync, I don't really know what happens.