<div dir="ltr">I filed a bug and attached this proposed patch last week.<div>I have tested it with both gluster-NFS and Ganesha and it appears to fix the problem.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Dec 2, 2016 at 10:19 PM, Niels de Vos <span dir="ltr">&lt;<a href="mailto:ndevos@redhat.com" target="_blank">ndevos@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Thu, Dec 01, 2016 at 05:04:06PM -0800, Eivind Sarto wrote:<br>
&gt; Overwriting an existing file with O_TRUNC will yield an incorrect atime.<br>
&gt; Example:<br>
&gt;<br>
&gt; root@vsan123:~# cp /vmlinuz /nfs<br>
&gt; root@vsan123:~# stat /nfs/vmlinuz<br>
&gt;   File: ‘/nfs/vmlinuz’<br>
&gt;   Size: 6565968         Blocks: 12825      IO Block: 1048576 regular file<br>
&gt; Device: 25h/37d Inode: 10266595591654252930  Links: 1<br>
&gt; Access: (0600/-rw-------)  Uid: (    0/    root)   Gid: (    0/    root)<br>
&gt; Access: 2016-12-01 16:39:48.000000000 -0800<br>
&gt; Modify: 2016-12-01 16:39:48.235275472 -0800<br>
&gt; Change: 2016-12-01 16:39:48.239275472 -0800<br>
&gt;  Birth: -<br>
&gt; root@vsan123:~# dd if=/vmlinuz of=/nfs/vmlinuz bs=64k conv=nocreat<br>
&gt; 100+1 records in<br>
&gt; 100+1 records out<br>
&gt; 6565968 bytes (6.6 MB) copied, 0.0271412 s, 242 MB/s<br>
&gt; root@vsan123:~# stat /nfs/vmlinuz<br>
&gt;   File: ‘/nfs/vmlinuz’<br>
&gt;   Size: 6565968         Blocks: 12825      IO Block: 1048576 regular file<br>
&gt; Device: 25h/37d Inode: 10266595591654252930  Links: 1<br>
&gt; Access: (0600/-rw-------)  Uid: (    0/    root)   Gid: (    0/    root)<br>
&gt; Access: 1969-12-31 16:00:00.000000000 -0800<br>
&gt; Modify: 2016-12-01 16:39:57.923275920 -0800<br>
&gt; Change: 2016-12-01 16:39:57.923275920 -0800GF_SET_ATTR_MTIME<br>
&gt;  Birth: -<br>
&gt;<br>
&gt; The Access time has been set to zero (or 1970 PST in my case)<br>
&gt;<br>
&gt; This appears to happen in all versions of gluster.  I think the problem can<br>
&gt; actually be blamed on posix_setattr().  If one does a FOP_SETATTR and only<br>
&gt; passes the GF_SET_ATTR_MTIME flag, posix_setattr() will blindly call<br>
&gt; lutimes() to modify both atime+mtime and atime gets set to 0.<br>
&gt; I think the solution would be to modify posix_setattr() to write back<br>
&gt; original atime/mtime if one of the flags are not specified.<br>
<br>
</div></div>Thanks for reporting this! Could you file a bug on<br>
<a href="https://bugzilla.redhat.com/enter_bug.cgi?product=GlusterFS" rel="noreferrer" target="_blank">https://bugzilla.redhat.com/<wbr>enter_bug.cgi?product=<wbr>GlusterFS</a> as well?<br>
Just copy/paste the contents of the email in the report and let us know<br>
the URL of the bug that you created. We&#39;ll clone the bug for all<br>
actively maintained versions after that.<br>
<br>
The attached patch has been completely untested, but it should resolve<br>
the problem. I&#39;d appreciate it if you can give that a try and report<br>
results.<br>
<span class=""><br>
&gt; I have also seen NFS-Ganesha end up with a zero atime, but it does happen<br>
&gt; not for the example above on Ganesha.  Ganesha probably does something<br>
&gt; similar someplace in its code where only GF_SET_ATTR_MTIME is being set.<br>
&gt; But, I cannot remember exactly what caused the zero atime on Ganesha.<br>
<br>
</span>NFS-Ganesha uses libgfapi and the library makes it possible to only pass<br>
atime or mtime in glfs_h_setattrs(). Possibly NFS-Ganesha internally<br>
maintains the atime+mtime combination, or the (Linux?) NFS-client<br>
handles it differently over NFSv4. In any case, the attached patch<br>
should also prevent this from happening with NFS-Ganesha.<br>
<span class=""><br>
&gt; All other code in gluster, other than nfsserver, sets both ATIME and MTIME<br>
&gt; when doing an FOP_SETATTR.<br>
<br>
</span>Good to check that, it would give one possible explanation why this is<br>
not happening over FUSE mounts.<br>
<br>
Thanks again,<br>
Niels<br>
</blockquote></div><br></div>