Sunday, February 2, 2014

UNIX WRITE

A write back cache improves performance because a WRITE call will return once the data is transfered from user buffers to kernel buffers.  The kernel will scheduled write to disk at a later time asynchronously. The down side of write back cache is data corruption when system crashes,  To balance between performance and reliability, system often offers write back cache and synchronous write option to bypass this mechanism to application.

Write I/O is synchronous when a file is open with O_SYNC option.  Some file system has mount option to force all WRITE to be synchronous.  Instead of write each I/O synchronously, an application can opt to commit prior WRITES using fsync() call to improve performance.

No comments: