<div dir="ltr"><div><div><div><div>This is great info - with a lot of options to take in :)<br><br></div>To summarise, to enable direct-io and bypass the kernel filesystem cache for a volume<br></div>1. Mount the brick with <span class="im">direct-io-mode=enable option<br></span></div><div><span class="im">2. run vol set &lt;vol&gt; performance.strict-o-direct on <br></span></div><span class="im">3. update the vol files with </span><span class="im">&#39;o-direct&#39; option in storage/posix (at least for now)<br><br></span></div><span class="im">Is that right?<br><br><br></span></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 25, 2016 at 5:56 PM, Raghavendra Gowdappa <span dir="ltr">&lt;<a href="mailto:rgowdapp@redhat.com" target="_blank">rgowdapp@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"><span class=""><br>
<br>
----- Original Message -----<br>
&gt; From: &quot;Krutika Dhananjay&quot; &lt;<a href="mailto:kdhananj@redhat.com">kdhananj@redhat.com</a>&gt;<br>
&gt; To: &quot;Gluster Devel&quot; &lt;<a href="mailto:gluster-devel@gluster.org">gluster-devel@gluster.org</a>&gt;, &quot;Raghavendra Gowdappa&quot; &lt;<a href="mailto:rgowdapp@redhat.com">rgowdapp@redhat.com</a>&gt;<br>
&gt; Cc: &quot;Paul Cuzner&quot; &lt;<a href="mailto:pcuzner@redhat.com">pcuzner@redhat.com</a>&gt;<br>
&gt; Sent: Thursday, February 25, 2016 7:28:30 AM<br>
&gt; Subject: What&#39;s the correct way to enable direct-IO?<br>
&gt;<br>
&gt; Hi,<br>
&gt;<br>
&gt; git-grep tells me there are multiple options in our code base for enabling<br>
&gt; direct-IO on a gluster volume, at several layers in the translator stack:<br>
&gt; i) use the mount option &#39;direct-io-mode=enable&#39;<br>
<br>
</span>This option is between kernel and glusterfs. Specifically it asks fuse kernel module to bypass page-cache. Note that when this option is set, direct-io is enabled for _all_ fds irrespective of whether applications have used O_DIRECT in their open/create calls or not.<br>
<span class=""><br>
&gt; ii) enable &#39;network.remote-dio&#39; which is a protocol/client option using<br>
&gt; volume set command<br>
<br>
</span>This is an option introduced by [1] to _filter_ O_DIRECT flags in open/create calls before sending those requests to server. The option name is misleading here. However please note that this is the key (alias?) used by glusterd. The exact option name used by protocol/client is &quot;filter_O_DIRECT&quot; and its fine. Probably we should file a bug on glusterd to change the name?<br>
<br>
Coming to your use case, we don&#39;t want to filter O_DIRECT from reaching brick. Hence, we need to set this option to _off_ (by default its disabled).<br>
<br>
I am still not sure what is the relevance of this option against the bug it was introduced. If we need direct-io, we&#39;ve to pass it to brick too, so that backend fs on brick is configured appropriately.<br>
<br>
[1] <a href="http://review.gluster.org/4206" rel="noreferrer" target="_blank">http://review.gluster.org/4206</a><br>
[2] <a href="https://bugzilla.redhat.com/show_bug.cgi?id=845213" rel="noreferrer" target="_blank">https://bugzilla.redhat.com/show_bug.cgi?id=845213</a><br>
<span class=""><br>
&gt; iii) enable performance.strict-o-direct which is a performance/write-behind<br>
&gt; option using volume-set command<br>
<br>
</span>Yes, write-behind honours O_DIRECT only if this option is set. So, we need to enable this for your use-case. Also, note that applications still need to use O_DIRECT in open/create calls.<br>
<br>
To summarize, following are the ways to bypass write-behind cache:<br>
1. disable write-behind :).<br>
2. applications use O_SYNC/O_DSYNC in open calls<br>
3. enable performance.strict-o-direct _and_ applications should use O_DIRECT in open/create calls.<br>
<span class=""><br>
&gt; iv) use &#39;o-direct&#39; option in storage/posix, volume-set on which reports that<br>
&gt; the option doesn&#39;t exist.<br>
<br>
</span>The option exists in storage/posix. But, there is no way to set it through cli (probably you can send a patch to do that if necessary). With this option, O_DIRECT is passed with _every_ open/create call on the brick.<br>
<span class=""><br>
&gt;<br>
&gt; So then the question is - what is a surefire way to get direct-io-like<br>
&gt; behavior on gluster volume(s)?<br>
<br>
</span>There is no one global option. You need to configure various translators in the stack. Probably [2] was asking for such a feature. Also, as you might&#39;ve noticed above the behavior/interpretation of these options is not same across all translators (like some are global and some are local only to an fd etc).<br>
<br>
Also note that apart from the options you listed above,<br>
1. Quick-read is not aware of O_DIRECT. We need to make it to disable caching if open happens with O_DIRECT.<br>
2. Handling of Quota Marker xattrs is not synchronous (though not exactly an O_DIRECT requirement) as marking is done after sending reply to calls like writev.<br>
<br>
On a related note, found article [3] to be informative.<br>
<br>
[1] <a href="http://review.gluster.org/4206" rel="noreferrer" target="_blank">http://review.gluster.org/4206</a><br>
[2] <a href="https://bugzilla.redhat.com/show_bug.cgi?id=845213" rel="noreferrer" target="_blank">https://bugzilla.redhat.com/show_bug.cgi?id=845213</a><br>
[3] <a href="https://lwn.net/Articles/457667/" rel="noreferrer" target="_blank">https://lwn.net/Articles/457667/</a><br>
<br>
regards,<br>
Raghavendra.<br>
</blockquote></div><br></div>