<div dir="auto"><div>Adding in Eric and Steve.</div><div dir="auto"><br></div><div dir="auto">Ric</div><div dir="auto"><br><div class="gmail_extra" dir="auto"><br><div class="gmail_quote">On Oct 18, 2017 9:35 AM, &quot;Raghavendra G&quot; &lt;<a href="mailto:raghavendra@gluster.com">raghavendra@gluster.com</a>&gt; wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">+Brian Foster<br><div class="gmail_extra"><br><div class="gmail_quote"><div class="elided-text">On Wed, Oct 11, 2017 at 4:11 PM, Raghavendra G <span dir="ltr">&lt;<a href="mailto:raghavendra@gluster.com" target="_blank">raghavendra@gluster.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 dir="ltr">We ran into a regression [2][3]. Hence reviving this thread.<br><br>[2] <a href="https://bugzilla.redhat.com/show_bug.cgi?id=1500269" target="_blank">https://bugzilla.redhat.com/sh<wbr>ow_bug.cgi?id=1500269</a><br>[3] <a href="https://review.gluster.org/18463" target="_blank">https://review.gluster.org/184<wbr>63</a><br><div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="m_-7260625155758624070h5">On Thu, Mar 31, 2016 at 1:22 AM, J. Bruce Fields <span dir="ltr">&lt;<a href="mailto:bfields@fieldses.org" target="_blank">bfields@fieldses.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="m_-7260625155758624070m_8986995149772584679gmail-HOEnZb"><div class="m_-7260625155758624070m_8986995149772584679gmail-h5">On Mon, Mar 28, 2016 at 04:21:00PM -0400, Vijay Bellur wrote:<br>
&gt; On 03/28/2016 09:34 AM, FNU Raghavendra Manjunath wrote:<br>
&gt; &gt;<br>
&gt; &gt;I can understand the concern. But I think instead of generally<br>
&gt; &gt;converting all the ESTALE errors ENOENT, probably we should try to<br>
&gt; &gt;analyze the errors that are generated by lower layers (like posix).<br>
&gt; &gt;<br>
&gt; &gt;Even fuse kernel module some times returns ESTALE. (Well, I can see it<br>
&gt; &gt;returning ESTALE errors in some cases in the code. Someone please<br>
&gt; &gt;correct me if thats not the case).  And aso I am not sure if converting<br>
&gt; &gt;all the ESTALE errors to ENOENT is ok or not.<br>
&gt;<br>
&gt; ESTALE in fuse is returned only for export_operations. fuse<br>
&gt; implements this for providing support to export fuse mounts as nfs<br>
&gt; exports. A cursory reading of the source seems to indicate that fuse<br>
&gt; returns ESTALE only in cases where filehandle resolution fails.<br>
&gt;<br>
&gt; &gt;<br>
&gt; &gt;For fd based operations, I am not sure if ENOENT can be sent or not (as<br>
&gt; &gt;though the file is unlinked, it can be accessed if there were open fds<br>
&gt; &gt;on it before unlinking the file).<br>
&gt;<br>
&gt; ESTALE should be fine for fd based operations. It would be analogous<br>
&gt; to a filehandle resolution failing and should not be a common<br>
&gt; occurrence.<br>
&gt;<br>
&gt; &gt;<br>
&gt; &gt;I feel, we have to look into some parts to check if they generating<br>
&gt; &gt;ESTALE is a proper error or not. Also, if there is any bug in below<br>
&gt; &gt;layers fixing which can avoid ESTALE errors, then I feel that would be<br>
&gt; &gt;the better option.<br>
&gt; &gt;<br>
&gt;<br>
&gt; I would prefer to:<br>
&gt;<br>
&gt; 1. Return ENOENT for all system calls that operate on a path.<br>
&gt;<br>
&gt; 2. ESTALE might be ok for file descriptor based operations.<br>
<br>
</div></div>Note that operations which operate on paths can fail with ESTALE when<br>
they attempt to look up a component within a directory that no longer<br>
exists.<br></blockquote><div><br></div></div></div><div>But, &quot;man 2 rmdir&quot;  or &quot;man 2 unlink&quot; doesn&#39;t list ESTALE as a valid error. Also rm doesn&#39;t seem to handle ESTALE too [3]</div><div><br></div><div>[4] <a href="https://github.com/coreutils/coreutils/blob/master/src/remove.c#L305" target="_blank">https://github.com/coreutils/c<wbr>oreutils/blob/master/src/remov<wbr>e.c#L305</a></div><span><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Maybe non-creating open(&quot;./foo&quot;) returning ENOENT would be reasonable in<br>
this case since that&#39;s what you&#39;d get in the local filesystem case, but<br>
creat(&quot;./foo&quot;) returning ENOENT, for example, isn&#39;t something<br>
applications will be written to handle.<br>
<br>
The Linux VFS will retry ESTALE on path-based systemcalls *one* time, to<br>
reduce the chance of ESTALE in those cases.  </blockquote><div><br></div></span><div>I should&#39;ve anticipated bug [2] due to this comment. My mistake. Bug [2] is indeed due to kernel not retrying open on receiving an ENOENT error. Glusterfs sent ENOENT because file&#39;s inode-number/nodeid changed but same path exists. The correct error would&#39;ve been ESTALE, but due to our conversion of ESTALE to ENOENT, the latter was sent back to kernel.<br></div></div></div></div></div></blockquote><div><br></div></div><div>We&#39;ve an application which does very frequent renames (around 10-15 per second). So, single retry by kernel of an open failed with ESTALE is not helping us.</div><div><br></div><div>@Bruce/Brian,</div><div><br></div><div>Do you know why VFS chose an approach of retrying instead of a stricter synchronization mechanism using locking? For eg., rename and open could&#39;ve been synchronized using a lock.</div><div><br></div><div>For eg., a rough psuedocode for open and rename could&#39;ve been (please ignore ordering src,dst locks in rename)</div><div><br></div><div>sys_open ()</div><div>{</div><div>       LOCK (dentry-&gt;lock);</div><div>       {</div><div>            lookup path;</div><div>            open (inode)</div><div>       }</div><div>       UNLOCK (dentry-&gt;lock;</div><div>}</div><div><br></div><div>sys_rename ()</div><div>{</div><div>         LOCK (dst-dentry-&gt;lock);</div><div>         {</div><div>                LOCK (src-dentry-&gt;lock);</div><div>                {</div><div>                     rename (src, dst);</div><div>                }</div><div>                UNLOCK (src-dentry-&gt;lock);</div><div>        }</div><div>        UNLOCK (dst-dentry-&gt;lock);</div><div>}<br></div><div><br> </div><div>@Bruce,</div><div><br></div><div>With the current retry model, any suggestions on how to handle applications that do frequent renames?</div><div class="elided-text"><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div class="gmail_extra"><div class="gmail_quote"><div></div><div><br> </div><div>Looking through kernel VFS code, only open *seems* to retry (do_filep_open). I couldn&#39;t find similar logic to other path based syscalls like rmdir, unlink, stat, chmod etc</div><span><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">The bugzilla entry that<br>
tracked those patches might be interesting:<br>
<br>
        <a href="https://bugzilla.redhat.com/show_bug.cgi?id=678544" rel="noreferrer" target="_blank">https://bugzilla.redhat.com/sh<wbr>ow_bug.cgi?id=678544</a><br>
<span class="m_-7260625155758624070m_8986995149772584679gmail-"><br>
&gt; NFS recommends that applications add special code for handling<br>
&gt; ESTALE [1]. Unfortunately changing application code is not easy and<br>
&gt; hence it does not come as a surprise that coreutils also does not<br>
&gt; accommodate ESTALE.<br>
<br>
</span>We also need to consider whether the application&#39;s handling of the<br>
ENOENT case could be incorrect for the ESTALE case, with consequences<br>
possibly as bad as or worse than consequences of seeing an unexpected<br>
error.<br>
<br>
My first intuition is that translating ESTALE to ENOENT is less safe<br>
than not doing so, because:<br>
<br>
        - once an ESTALE-unaware application his the ESTALE case, we<br>
          risk a bug regardless of which we return, but if we return<br>
          ESTALE at least the problem should be more obvious to the<br>
          person debugging.<br>
        - for ESTALE-aware applications, the ESTALE/ENOENT distinction<br>
          is useful.<br></blockquote><div><br></div></span><div>Another place to not convert is for  those cases where kernel retries the operation on seeing an ESTALE.</div><div><br></div><div>I guess we need to think through each operation and we cannot ESTALE to ENOENT always.<br></div><span><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
But I haven&#39;t really thought through examples.<br>
<span class="m_-7260625155758624070m_8986995149772584679gmail-HOEnZb"><font color="#888888"><br>
--b.<br>
</font></span><div class="m_-7260625155758624070m_8986995149772584679gmail-HOEnZb"><div class="m_-7260625155758624070m_8986995149772584679gmail-h5">______________________________<wbr>_________________<br>
Gluster-devel mailing list<br>
<a href="mailto:Gluster-devel@gluster.org" target="_blank">Gluster-devel@gluster.org</a><br>
<a href="http://www.gluster.org/mailman/listinfo/gluster-devel" rel="noreferrer" target="_blank">http://www.gluster.org/mailman<wbr>/listinfo/gluster-devel</a><br>
</div></div></blockquote></span></div><span class="m_-7260625155758624070HOEnZb"><font color="#888888"><br><br clear="all"><br>-- <br><div class="m_-7260625155758624070m_8986995149772584679gmail_signature">Raghavendra G<br></div>
</font></span></div></div></div>
</blockquote></div></div><br><br clear="all"></div><div class="gmail_extra">regards,<font color="#888888"><br></font></div><font color="#888888"><div class="gmail_extra">-- <br><div class="m_-7260625155758624070gmail_signature" data-smartmail="gmail_signature">Raghavendra G<br></div>
</div></font></div>
<br>______________________________<wbr>_________________<br>
Gluster-devel mailing list<br>
<a href="mailto:Gluster-devel@gluster.org">Gluster-devel@gluster.org</a><br>
<a href="http://lists.gluster.org/mailman/listinfo/gluster-devel" rel="noreferrer" target="_blank">http://lists.gluster.org/<wbr>mailman/listinfo/gluster-devel</a><br></blockquote></div><br></div></div></div>