gluster-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gluster-devel] how to distinguish whether the current xlator is use


From: Mingfan Lu
Subject: Re: [Gluster-devel] how to distinguish whether the current xlator is used in the client or the server?
Date: Tue, 17 Dec 2013 17:42:45 +0800

1. use option is a good idea
2. we could also traverse the this->children to see whether there is a xlator with type == protocol/client  (depth first!)
   and save cache value in conf->use_with_client
gf_boolean_t
could_use_xlator(xlator_t *this)
{
      struct ios_conf  *conf = NULL;
      gf_boolean_t ret_value = _gf_false;
      conf = this->private;

      if(!conf) {
              gf_log(this->name, GF_LOG_INFO, "configuration should not be null when check whether on client xlator");
              return ret_value;
      }

      LOCK(&conf->lock);
      {
              if (conf->check_use_client == _gf_true) {
                      gf_log(this->name, GF_LOG_INFO, "use the cached value");
                      ret_value = conf->use_with_client;
              } else {
                      conf->use_with_client = ret_value = trav_children(this);
                      conf->check_use_client = _gf_true;
              }
      }
      UNLOCK(&conf->lock);
      return ret_value;
}

gf_boolean_t
trav_children(xlator_t *this)
{
   xlator_list_t * children = this->children;
   while(children)
   {
      gf_log(this->name, GF_LOG_INFO, "children - name %s type %s ", children->xlator->name, children->xlator->type);
      if (children->xlator->init_succeeded && strcmp(children->xlator->type, "protocol/client") == 0) {
          return _gf_true;
      }
      if(trav_children(children -> xlator) == _gf_true) {
          return _gf_true;
      }
      children = children->next;
   }
   return _gf_false;
}


and then,
  


On Tue, Dec 17, 2013 at 2:31 AM, Vijay Bellur <address@hidden> wrote:
On 12/16/2013 04:20 PM, Pranith Kumar Karampuri wrote:
hi Mingfan Lu,
     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
 server vs client side. Would writing two different xlators one for client side and the other for server side make sense?

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'.

-Vijay



Pranith.
----- Original Message -----
From: "Mingfan Lu" <address@hidden>
To: address@hidden
Sent: Monday, December 16, 2013 2:55:24 PM
Subject: [Gluster-devel] how to distinguish whether the current xlator is used in the client or the server?

When I write a xlator for glusterfs, the xlator could be used for client and
server. but when being used in server and client, the behavior of the xlator
could be some-what differrent. How could I know whether the xlator is used
in glusterfs or glusterfsd when I developing the xlator? then I could tune
the code path for client and server.

_______________________________________________
Gluster-devel mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/gluster-devel


_______________________________________________
Gluster-devel mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/gluster-devel





reply via email to

[Prev in Thread] Current Thread [Next in Thread]