25 Oct: When a read implies a write

When you read file of disk, you might assume the file is read and that's all you need to worry about. However any POSIX-compliant OS must also maintain the last access time (atime) of every file as part of stat(). This is along with the mtime (modification time, when the contents was last changed), and ctime (change time, when either the contents or some attribute was last changed). Per
  time_t      st_atime;   /* time of last access */
  time_t      st_mtime;   /* time of last modification */
  time_t      st_ctime;   /* time of last status change */
Maintaining the atime means every time we read from a file, we must then write to the inode to update it's atime metadata. Clearly this is not ideal since a high read rate shouldn't also imply high write load on a filesystem. Linux has developed a few filesystem options over the years to reduce the impact of this feature: So you can turn off atime update entirely if you want to, but its unlikely you'll get much performance gain over relatime (the default) or lazytime. Of course its worth understanding which option is in use as otherwise you might get the wrong impression of what stat is telling you.
© 2017