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