<div dir="ltr">1. use option is a good idea<div>2. we could also traverse the this-&gt;children to see whether there is a xlator with type == protocol/client  (depth first!)</div><div>   and save cache value in conf-&gt;use_with_client</div>

<div><div>gf_boolean_t</div><div>could_use_xlator(xlator_t *this)</div><div>{</div><div>      struct ios_conf  *conf = NULL;</div><div>      gf_boolean_t ret_value = _gf_false;</div><div>      conf = this-&gt;private;</div>

<div><br></div><div>      if(!conf) {</div><div>              gf_log(this-&gt;name, GF_LOG_INFO, &quot;configuration should not be null when check whether on client xlator&quot;);</div><div>              return ret_value;</div>

<div>      }</div><div><br></div><div>      LOCK(&amp;conf-&gt;lock);</div><div>      {</div><div>              if (conf-&gt;check_use_client == _gf_true) {</div><div>                      gf_log(this-&gt;name, GF_LOG_INFO, &quot;use the cached value&quot;);</div>

<div>                      ret_value = conf-&gt;use_with_client;</div><div>              } else {</div><div>                      conf-&gt;use_with_client = ret_value = trav_children(this);</div><div>                      conf-&gt;check_use_client = _gf_true;</div>

<div>              }</div><div>      }</div><div>      UNLOCK(&amp;conf-&gt;lock);</div><div>      return ret_value;</div><div>}</div></div><div><br></div><div><div>gf_boolean_t</div><div>trav_children(xlator_t *this)</div>

<div>{</div><div>   xlator_list_t * children = this-&gt;children;</div><div>   while(children)</div><div>   {</div><div>      gf_log(this-&gt;name, GF_LOG_INFO, &quot;children - name %s type %s &quot;, children-&gt;xlator-&gt;name, children-&gt;xlator-&gt;type);</div>

<div>      if (children-&gt;xlator-&gt;init_succeeded &amp;&amp; strcmp(children-&gt;xlator-&gt;type, &quot;protocol/client&quot;) == 0) {</div><div>          return _gf_true;</div><div>      }</div><div>      if(trav_children(children -&gt; xlator) == _gf_true) {</div>

<div>          return _gf_true;</div><div>      }</div><div>      children = children-&gt;next;</div><div>   }</div><div>   return _gf_false;</div><div>}</div></div><div><br></div><div><br></div><div>and then,</div><div>
  </div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Dec 17, 2013 at 2:31 AM, Vijay Bellur <span dir="ltr">&lt;<a href="mailto:vbellur@redhat.com" target="_blank">vbellur@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 12/16/2013 04:20 PM, Pranith Kumar Karampuri wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
hi Mingfan Lu,<br>
     xlators are not supposed to know which part of the stack they belong to. If you think the functionality needs to be different when it is in<br>
 server vs client side. Would writing two different xlators one for client side and the other for server side make sense?<br>
</blockquote>
<br>
You can also consider having optional behavior and enable the appropriate option in the client/server volume files for the xlator to behave differently. For e.g. the compression translator is loaded in both client and server stacks, but it performs compression/de-compression for the appropriate fops by looking at option &#39;mode&#39;.<br>


<br>
-Vijay<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Pranith.<br>
----- Original Message -----<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
From: &quot;Mingfan Lu&quot; &lt;<a href="mailto:mingfan.lu@gmail.com" target="_blank">mingfan.lu@gmail.com</a>&gt;<br>
To: <a href="mailto:gluster-devel@nongnu.org" target="_blank">gluster-devel@nongnu.org</a><br>
Sent: Monday, December 16, 2013 2:55:24 PM<br>
Subject: [Gluster-devel] how to distinguish whether the current xlator is used in the client or the server?<br>
<br>
When I write a xlator for glusterfs, the xlator could be used for client and<br>
server. but when being used in server and client, the behavior of the xlator<br>
could be some-what differrent. How could I know whether the xlator is used<br>
in glusterfs or glusterfsd when I developing the xlator? then I could tune<br>
the code path for client and server.<br>
<br>
______________________________<u></u>_________________<br>
Gluster-devel mailing list<br>
<a href="mailto:Gluster-devel@nongnu.org" target="_blank">Gluster-devel@nongnu.org</a><br>
<a href="https://lists.nongnu.org/mailman/listinfo/gluster-devel" target="_blank">https://lists.nongnu.org/<u></u>mailman/listinfo/gluster-devel</a><br>
<br>
</blockquote>
<br>
______________________________<u></u>_________________<br>
Gluster-devel mailing list<br>
<a href="mailto:Gluster-devel@nongnu.org" target="_blank">Gluster-devel@nongnu.org</a><br>
<a href="https://lists.nongnu.org/mailman/listinfo/gluster-devel" target="_blank">https://lists.nongnu.org/<u></u>mailman/listinfo/gluster-devel</a><br>
<br>
<br>
</blockquote>
<br>
</blockquote></div><br></div>