<div dir="ltr">1. use option is a good idea<div>2. we could also traverse the this->children to see whether there is a xlator with type == protocol/client (depth first!)</div><div> and save cache value in conf->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->private;</div>
<div><br></div><div> if(!conf) {</div><div> gf_log(this->name, GF_LOG_INFO, "configuration should not be null when check whether on client xlator");</div><div> return ret_value;</div>
<div> }</div><div><br></div><div> LOCK(&conf->lock);</div><div> {</div><div> if (conf->check_use_client == _gf_true) {</div><div> gf_log(this->name, GF_LOG_INFO, "use the cached value");</div>
<div> ret_value = conf->use_with_client;</div><div> } else {</div><div> conf->use_with_client = ret_value = trav_children(this);</div><div> conf->check_use_client = _gf_true;</div>
<div> }</div><div> }</div><div> UNLOCK(&conf->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->children;</div><div> while(children)</div><div> {</div><div> gf_log(this->name, GF_LOG_INFO, "children - name %s type %s ", children->xlator->name, children->xlator->type);</div>
<div> if (children->xlator->init_succeeded && strcmp(children->xlator->type, "protocol/client") == 0) {</div><div> return _gf_true;</div><div> }</div><div> if(trav_children(children -> xlator) == _gf_true) {</div>
<div> return _gf_true;</div><div> }</div><div> children = children->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"><<a href="mailto:vbellur@redhat.com" target="_blank">vbellur@redhat.com</a>></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 'mode'.<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: "Mingfan Lu" <<a href="mailto:mingfan.lu@gmail.com" target="_blank">mingfan.lu@gmail.com</a>><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>