Re: Appropriate use of sync() from user space?
From: Chris Friesen
Date: Wed Oct 05 2011 - 20:32:44 EST
On 10/05/2011 05:57 PM, Mark Mielke wrote:
The vendor stated that sync() is integral to their synchronization
process to ensure all files reach disk before they are accessed, and
that this is not a defect in their product. We have a work around - run
"sync" before calling their command, and this generally avoids the
I think the use of sync() in this regard is a hack. According to POSIX.1
and the Linux man pages, it seems clear to me that sync() does not
guarantee data integrity (bytes guaranteed to have reached disk) - and
it also seems clear that forcing all system data to flush out in
response to a minor command is over kill. Like cutting down the forest
to harvest fruit from a single tree.
I'm wondering what you think.
The susv3 man page for sync() is pretty clear: "The writing, although
scheduled, is not necessarily complete upon return from sync()."
They should probably be using msync()/fsync()/fdatasync() which only
affect the specified files and are supposed to wait for the data to hit
the storage device. Of course this would require them to do something
for each file they touch rather than once at the end of the whole operation.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/