<div dir="ltr"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Jan 10, 2019 at 8:17 AM Emmanuel Dreyfus &lt;<a href="mailto:manu@netbsd.org" target="_blank">manu@netbsd.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello<br>
<br>
This is not strictly a GlusterFS question since I came to it porting<br>
LTFS to NetBSD, however I would like to make sure I will not break<br>
GlusterFS by fixing NetBSD FUSE implementation for LTFS.<br>
<br>
Current NetBSD FUSE implementation sends the filehandle in any FUSE<br>
requests for an open node, regardless of its type (directory or file). <br>
<br>
I discovered that libfuse low level code manages filehandle differently<br>
for opendir/readdir/syncdir/releasedir than for other operations. As a<br>
result, when a getattr is done on a directory, setting the filehandle<br>
obtained from opendir can cause a crash in libfuse.<br>
<br>
The fix for NetBSD FUSE implementation is to avoid setting the<br>
filehandle for the following FUSE operations on directories: getattr,<br>
setattr, poll, getlk, setlk, setlkw, read, write (only the first two<br>
ones are likely to be actually used, though)<br>
<br>
Does anyone forsee a possible problem for GlusterFS with such a<br>
behavior? In other words, will it be fine to always have a<br>
FUSE_UNKNOWN_FH (aka null) filehandle for getattr/setattr on<br>
directories?<br>
<br></blockquote><div><br></div><div>Below is the code snippet from fuse_getattr().</div><div><font face="monospace, monospace"><br></font></div><div><div><font face="monospace, monospace">#if FUSE_KERNEL_MINOR_VERSION &gt;= 9</font></div><div><font face="monospace, monospace">    priv = this-&gt;private;</font></div><div><font face="monospace, monospace">    if (priv-&gt;proto_minor &gt;= 9 &amp;&amp; fgi-&gt;getattr_flags &amp; FUSE_GETATTR_FH)</font></div><div><font face="monospace, monospace">        state-&gt;fd = fd_ref((fd_t *)(uintptr_t)fgi-&gt;fh);</font></div><div><font face="monospace, monospace">#endif</font></div></div><div><br></div><div>Which means, it may crash if we get fd as NULL, when FUSE_GETATTR_FH is set.</div><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>
-- <br>
Emmanuel Dreyfus<br>
<a href="http://hcpnet.free.fr/pubz" rel="noreferrer" target="_blank">http://hcpnet.free.fr/pubz</a><br>
<a href="mailto:manu@netbsd.org" target="_blank">manu@netbsd.org</a><br>
_______________________________________________<br>
Gluster-devel mailing list<br>
<a href="mailto:Gluster-devel@gluster.org" target="_blank">Gluster-devel@gluster.org</a><br>
<a href="https://lists.gluster.org/mailman/listinfo/gluster-devel" rel="noreferrer" target="_blank">https://lists.gluster.org/mailman/listinfo/gluster-devel</a><br>
<br>
<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail-m_3588758847047954348gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Amar Tumballi (amarts)<br></div></div></div></div></div></div></div>