zfsonlinux/zfs — pull request #1127 by ryao (2012-12-04 01:26:20+00:00)
Title: Update mtime when mmapped pages become writable

GNU Tar is sensitive to situations where mtimes on open files are
updated to times in the past.

When doing write operations on mmapped files, the modification time update
presently occurs during a flush. Observant programs that open such files
shortly after they are closed will observe that modification times
appear to occur in the past. This caused a failure to be observed during
binary package generation on Gentoo where PaX-marking is done on certain
files via mmap almost immediately prior to package generation, which
relies on GNU tar. This can be replicated with a Hello World program by
doing:

gcc hello.c && scanelf -Xxz -r a.out && tar -cf hello.tgz a.out

Brian Behlendorf pointed out that we could avoid this problem by doing
mtime updates in the kernel's page_mkwrite() callback function, which is
invoked whenever a page becomes writeable. We implement that though a
C++-style overload of the page_mkwrite function to add a call to
zfs_inode_update(). It would be better to do this on each close()
operation done from userland, but unfortunately, the Linux kernel
provides no way for us to be informed of such events.

Signed-off-by: Richard Yao