Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Update mtime when mmap'ed pages become writable #1127
GNU Tar is sensitive to situations where mtimes on open files are
When doing write operations on mmap'ed files, the modification time update
gcc hello.c && scanelf -Xxz -r a.out && tar -cf hello.tgz a.out
Brian Behlendorf suggested that we could prevent this by doing mtime
Signed-off-by: Richard Yao email@example.com
This really isn't what you want. This will effectively overwrite the atime/mtime in the inode which you just updated (correctly) with the times in the znode (which are incorrect). This probably effectively resolves the problem by preventing the mtime from increasing until the zpl_putpage() occurs, however it will have a stale time. What you want to be doing here is updating the times in the znode.
Hmm... doing what we should do turns out to be hard. Updating the mtime SA in the znode means constructing a TX per page which is going to be expensive and I want to avoid that in this critical I/O path. Suppressing the mtime update feels wrong here but it may be the least evil thing we can do until the znode/inode are cleanly unified. I'm warming up to your approach...
However, rather than using the filemap_page_mkwrite() helper it might be wiser to create our own helper which does everything but update the time. This ensures there is no race between when the helper updating the time and when we set it back to the znode time. Basically we'll just defer all mtime updates until the page gets written to the ARC.