<div dir="ltr">Good pickup,<br><div><br>Reviewed-by: Ira Cooper &lt;<a href="mailto:ira@samba.org">ira@samba.org</a>&gt;<br><br></div><div>-Ira<br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jan 15, 2014 at 5:17 AM, 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">On Tue, Jan 14, 2014 at 02:56:16PM -0800, Jeremy Allison wrote:<br>
&gt; On Mon, Jan 13, 2014 at 11:26:42AM +0100, Niels de Vos wrote:<br>
&gt; &gt; Hello,<br>
&gt; &gt;<br>
&gt; &gt; we were informed that when using Samba+vfs_glusterfs a normal &#39;write&#39; to<br>
&gt; &gt; a file does not correctly set the &#39;atime&#39;. In fact, the &#39;atime&#39; is set<br>
&gt; &gt; to &quot;2106-02-07 11:58:15.000000000 +0530&quot; according to &#39;stat&#39;.<br>
&gt; &gt;<br>
&gt; &gt; Tracing the network and checking the SMB/SET_FILE_INFO shows that the<br>
&gt; &gt; Linux CIFS client sends the following date:<br>
&gt; &gt; - May 28, 60056 07:36:10.955161500 CEST<br>
&gt; &gt;<br>
&gt; &gt; This date, in fact, shows as 0xffffffff (32-bit -1) in the packet<br>
&gt; &gt; capture. The Linux CIFS client sets NO_CHANGE_64 (0xffffffffffffffff,<br>
&gt; &gt; 64-bit -1) when it intends to not modify the &#39;atime&#39; (fs/cifs/inode.c).<br>
&gt; &gt;<br>
&gt; &gt; Debugging the Samba/vfs_glusterfs module with systemtap, showed that the<br>
&gt; &gt; &#39;write&#39; that triggers the unexpected &#39;atime&#39;, indeed gets forwarded to<br>
&gt; &gt; the GlusterFS volume as -1. Obviously, Samba passes a -1 for the &#39;atime&#39;<br>
&gt; &gt; when it should not get modified. Unfortunately the gfapi library does<br>
&gt; &gt; not expose a function to set the &#39;mtime&#39; only, it is always needed to<br>
&gt; &gt; set the &#39;atime&#39; as well (like &#39;utimes()&#39;).<br>
&gt; &gt;<br>
&gt; &gt; The attached patch fixes setting the &#39;atime&#39; to a value way in the<br>
&gt; &gt; future. It resolves to setting the &#39;atime&#39; to the same value as the<br>
&gt; &gt; &#39;mtime&#39;, whenever the &#39;atime&#39; is set to -1.<br>
&gt; &gt;<br>
&gt; &gt; Downstream bug report and detailed results of the debugging:<br>
&gt; &gt; - <a href="https://bugzilla.redhat.com/1051226" target="_blank">https://bugzilla.redhat.com/1051226</a><br>
&gt;<br>
&gt; Actually I have to vote NAK on this patch, as it&#39;s<br>
&gt; not doing the expected thing.<br>
&gt;<br>
&gt; Sending -1 means no atime change, and the current<br>
&gt; atime is available to you in the smb_fname-&gt;st struct<br>
&gt; passed into the ntimes VFS call.<br>
&gt;<br>
&gt; So I suggest you copy the code inside vfswrap_ntimes()<br>
&gt; in source3/modules/vfs_default.c and do:<br>
&gt;<br>
&gt;         if (null_timespec(ft-&gt;atime)) {<br>
&gt;                 ft-&gt;atime= smb_fname-&gt;st.st_ex_atime;<br>
&gt;         }<br>
&gt;<br>
&gt;         if (null_timespec(ft-&gt;mtime)) {<br>
&gt;                 ft-&gt;mtime = smb_fname-&gt;st.st_ex_mtime;<br>
&gt;         }<br>
&gt;<br>
&gt;         if (!null_timespec(ft-&gt;create_time)) {<br>
&gt;                 set_create_timespec_ea(handle-&gt;conn,<br>
&gt;                                        smb_fname,<br>
&gt;                                        ft-&gt;create_time);<br>
&gt;         }<br>
&gt;<br>
&gt;         if ((timespec_compare(&amp;ft-&gt;atime,<br>
&gt;                               &amp;smb_fname-&gt;st.st_ex_atime) == 0) &amp;&amp;<br>
&gt;             (timespec_compare(&amp;ft-&gt;mtime,<br>
&gt;                               &amp;smb_fname-&gt;st.st_ex_mtime) == 0)) {<br>
&gt;                 return 0;<br>
&gt;         }<br>
&gt;<br>
&gt; instead.<br>
<br>
That makes perfect sense to me. Thanks for the suggestion! The attached<br>
patch has been tested successfully too.<br>
<span class="HOEnZb"><font color="#888888"><br>
Niels<br>
</font></span></blockquote></div><br></div>