Reputation: 532
The linux fsync
system call guarantees that when it returns any dirty kernel buffers have been flushed to the disk. I've seen a previous discussion about whether the data has necessarily actually been successfully written to the disk, but that isn't my question. I want to know whether the the kernel buffers have been freed, so that a subsequent read will get data from the disk and not from a kernel buffer.
In the absence of fsync
, a kernel could keep the data until it needs the memory for some reason, and satisfy a subsequent read without actually reading from the disk: modern kernels do seem to do this. What I want to know is whether fsync
prevents this: the man page doesn't say anything about it.
The behaviour matters if I'm testing a disk for write failures. If the data was not written correctly, I can only discover this by actually reading from the disk.
Upvotes: 1
Views: 194