diff options
| author | Kaleb S. KEITHLEY <kkeithle@redhat.com> | 2013-08-21 14:11:38 -0400 | 
|---|---|---|
| committer | Anand Avati <avati@redhat.com> | 2013-10-31 09:32:50 -0700 | 
| commit | 3108d4529d57690f58027da61ac5e56a0987ed57 (patch) | |
| tree | ed2eb16d54fdc4dcbdfe15eb2bff90597658339a /libglusterfs/src | |
| parent | c47408e896c9bcaf21e7f8956bdae85633f873e0 (diff) | |
client_t: phase 2, refactor server_ctx and locks_ctx out
remove server_ctx and locks_ctx from client_ctx directly and store as
into discrete entities in the scratch_ctx
hooking up dump will be in phase 3
BUG: 849630
Change-Id: I94cea328326db236cdfdf306cb381e4d58f58d4c
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
Reviewed-on: http://review.gluster.org/5678
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'libglusterfs/src')
| -rw-r--r-- | libglusterfs/src/Makefile.am | 7 | ||||
| -rw-r--r-- | libglusterfs/src/client_t.c | 193 | ||||
| -rw-r--r-- | libglusterfs/src/client_t.h | 77 | ||||
| -rw-r--r-- | libglusterfs/src/glusterfs.h | 5 | ||||
| -rw-r--r-- | libglusterfs/src/lock-table.c | 133 | ||||
| -rw-r--r-- | libglusterfs/src/lock-table.h | 54 | ||||
| -rw-r--r-- | libglusterfs/src/stack.h | 9 | ||||
| -rw-r--r-- | libglusterfs/src/xlator.h | 13 | 
8 files changed, 143 insertions, 348 deletions
diff --git a/libglusterfs/src/Makefile.am b/libglusterfs/src/Makefile.am index 2f2ab97697b..907399ae601 100644 --- a/libglusterfs/src/Makefile.am +++ b/libglusterfs/src/Makefile.am @@ -23,10 +23,9 @@ libglusterfs_la_SOURCES = dict.c xlator.c logging.c \  	$(CONTRIBDIR)/uuid/uuid_time.c $(CONTRIBDIR)/uuid/compare.c \  	$(CONTRIBDIR)/uuid/isnull.c $(CONTRIBDIR)/uuid/unpack.c syncop.c \  	graph-print.c trie.c run.c options.c fd-lk.c circ-buff.c \ -	event-history.c gidcache.c ctx.c client_t.c lock-table.c \ +	event-history.c gidcache.c ctx.c client_t.c event-poll.c event-epoll.c \  	$(CONTRIBDIR)/libgen/basename_r.c $(CONTRIBDIR)/libgen/dirname_r.c \ -	$(CONTRIBDIR)/stdlib/gf_mkostemp.c \ -	event-poll.c event-epoll.c +	$(CONTRIBDIR)/stdlib/gf_mkostemp.c  nodist_libglusterfs_la_SOURCES = y.tab.c graph.lex.c gf-error-codes.h @@ -42,7 +41,7 @@ noinst_HEADERS = common-utils.h defaults.h dict.h glusterfs.h hashfn.h timespec.  	$(CONTRIBDIR)/uuid/uuid.h $(CONTRIBDIR)/uuid/uuidP.h \  	$(CONTRIB_BUILDDIR)/uuid/uuid_types.h syncop.h graph-utils.h trie.h \  	run.h options.h lkowner.h fd-lk.h circ-buff.h event-history.h \ -	gidcache.h client_t.h lock-table.h glusterfs-acl.h +	gidcache.h client_t.h glusterfs-acl.h  EXTRA_DIST = graph.l graph.y diff --git a/libglusterfs/src/client_t.c b/libglusterfs/src/client_t.c index f0d66da3a3d..06447dc5d3f 100644 --- a/libglusterfs/src/client_t.c +++ b/libglusterfs/src/client_t.c @@ -11,9 +11,9 @@  #include "glusterfs.h"  #include "dict.h"  #include "statedump.h" -#include "lock-table.h" -#include "rpcsvc.h"  #include "client_t.h" +#include "list.h" +#include "rpcsvc.h"  #ifndef _CONFIG_H @@ -103,7 +103,7 @@ gf_clienttable_alloc (void)          clienttable_t *clienttable = NULL;          clienttable = -                GF_CALLOC (1, sizeof (*clienttable), gf_common_mt_clienttable_t); +                GF_CALLOC (1, sizeof (clienttable_t), gf_common_mt_clienttable_t);          if (!clienttable)                  return NULL; @@ -116,14 +116,11 @@ gf_clienttable_alloc (void)  void  gf_client_clienttable_destroy (clienttable_t *clienttable)  { -        struct list_head  list          = {0, };          client_t         *client        = NULL;          cliententry_t    *cliententries = NULL;          uint32_t          client_count  = 0;          int32_t           i             = 0; -        INIT_LIST_HEAD (&list); -          if (!clienttable) {                  gf_log_callingfn ("client_t", GF_LOG_WARNING, "!clienttable");                  return; @@ -152,9 +149,8 @@ gf_client_clienttable_destroy (clienttable_t *clienttable)          }  } -  client_t * -gf_client_get (xlator_t *this, rpcsvc_auth_data_t *cred, char *client_uid) +gf_client_get (xlator_t *this, struct rpcsvc_auth_data *cred, char *client_uid)  {          client_t      *client      = NULL;          cliententry_t *cliententry = NULL; @@ -181,13 +177,13 @@ gf_client_get (xlator_t *this, rpcsvc_auth_data_t *cred, char *client_uid)                           * look for matching client_uid, _and_                           * if auth was used, matching auth flavour and data                           */ -                        if (strcmp (client_uid, client->server_ctx.client_uid) == 0 && +                        if (strcmp (client_uid, client->client_uid) == 0 &&                                  (cred->flavour != AUTH_NONE && -                                        (cred->flavour == client->server_ctx.auth.flavour && -                                        (size_t) cred->datalen == client->server_ctx.auth.len && +                                        (cred->flavour == client->auth.flavour && +                                        (size_t) cred->datalen == client->auth.len &&                                          memcmp (cred->authdata, -                                                client->server_ctx.auth.data, -                                                client->server_ctx.auth.len) == 0))) { +                                                client->auth.data, +                                                client->auth.len) == 0))) {  #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)                                  __sync_add_and_fetch(&client->ref.bind, 1);  #else @@ -211,58 +207,49 @@ gf_client_get (xlator_t *this, rpcsvc_auth_data_t *cred, char *client_uid)                  }                  client->this = this; -             /* client->server_ctx.lk_version = 0; redundant */ -                LOCK_INIT (&client->server_ctx.fdtable_lock); -                LOCK_INIT (&client->locks_ctx.ltable_lock);                  LOCK_INIT (&client->scratch_ctx.lock);                  LOCK_INIT (&client->ref.lock); -                client->server_ctx.client_uid = gf_strdup (client_uid); -                if (client->server_ctx.client_uid == NULL) { -                        errno = ENOMEM; +                client->client_uid = gf_strdup (client_uid); +                if (client->client_uid == NULL) {                          GF_FREE (client);                          client = NULL; -                        goto unlock; -                } -                client->server_ctx.fdtable = gf_fd_fdtable_alloc (); -                if (client->server_ctx.fdtable == NULL) {                          errno = ENOMEM; -                        GF_FREE (client->server_ctx.client_uid); -                        GF_FREE (client); -                        client = NULL;                          goto unlock;                  } - -                client->locks_ctx.ltable = gf_lock_table_new (); -                if (client->locks_ctx.ltable == NULL) { -                        errno = ENOMEM; -                        GF_FREE (client->server_ctx.fdtable); -                        GF_FREE (client->server_ctx.client_uid); +                client->scratch_ctx.count = GF_CLIENTCTX_INITIAL_SIZE; +                client->scratch_ctx.ctx = +                        GF_CALLOC (GF_CLIENTCTX_INITIAL_SIZE, +                                   sizeof (struct client_ctx), +                                   gf_common_mt_client_ctx); +                if (client->scratch_ctx.ctx == NULL) { +                        GF_FREE (client->client_uid);                          GF_FREE (client);                          client = NULL; +                        errno = ENOMEM;                          goto unlock;                  }                  /* no need to do these atomically here */                  client->ref.bind = client->ref.count = 1; -                client->server_ctx.auth.flavour = cred->flavour; +                client->auth.flavour = cred->flavour;                  if (cred->flavour != AUTH_NONE) { -                        client->server_ctx.auth.data = -                                GF_CALLOC (1, cred->datalen, gf_common_mt_client_t); -                        if (client->server_ctx.auth.data == NULL) { -                                errno = ENOMEM; -                                GF_FREE (client->locks_ctx.ltable); -                                GF_FREE (client->server_ctx.fdtable); -                                GF_FREE (client->server_ctx.client_uid); +                        client->auth.data = +                                GF_CALLOC (1, cred->datalen, +                                           gf_common_mt_client_t); +                        if (client->auth.data == NULL) { +                                GF_FREE (client->scratch_ctx.ctx); +                                GF_FREE (client->client_uid);                                  GF_FREE (client);                                  client = NULL; +                                errno = ENOMEM;                                  goto unlock;                          } -                        memcpy (client->server_ctx.auth.data, cred->authdata, +                        memcpy (client->auth.data, cred->authdata,                                  cred->datalen); -                        client->server_ctx.auth.len = cred->datalen; +                        client->auth.len = cred->datalen;                  }                  client->tbl_index = clienttable->first_free; @@ -301,7 +288,7 @@ gf_client_put (client_t *client, gf_boolean_t *detached)          if (unref) {                  gf_log (THIS->name, GF_LOG_INFO, "Shutting down connection %s", -                        client->server_ctx.client_uid); +                        client->client_uid);                  if (detached)                          *detached = _gf_true;                  gf_client_unref (client); @@ -333,7 +320,9 @@ gf_client_ref (client_t *client)  static void  client_destroy (client_t *client)  { -        clienttable_t *clienttable = NULL; +        clienttable_t     *clienttable = NULL; +        glusterfs_graph_t *gtrav       = NULL; +        xlator_t          *xtrav       = NULL;          if (client == NULL){                  gf_log_callingfn ("xlator", GF_LOG_ERROR, "invalid argument"); @@ -342,8 +331,6 @@ client_destroy (client_t *client)          clienttable = client->this->ctx->clienttable; -        LOCK_DESTROY (&client->server_ctx.fdtable_lock); -        LOCK_DESTROY (&client->locks_ctx.ltable_lock);          LOCK_DESTROY (&client->scratch_ctx.lock);          LOCK_DESTROY (&client->ref.lock); @@ -356,17 +343,44 @@ client_destroy (client_t *client)          }          UNLOCK (&clienttable->lock); -        GF_FREE (client->server_ctx.auth.data); +        list_for_each_entry (gtrav, &client->this->ctx->graphs, list) { +                xtrav = gtrav->top; +                while (xtrav != NULL) { +                        if (xtrav->cbks->client_destroy != NULL) +                                xtrav->cbks->client_destroy (xtrav, client); +                        xtrav = xtrav->next; +                } +        } +        GF_FREE (client->auth.data);          GF_FREE (client->scratch_ctx.ctx); -        GF_FREE (client->locks_ctx.ltable); -        GF_FREE (client->server_ctx.fdtable); -        GF_FREE (client->server_ctx.client_uid); +        GF_FREE (client->client_uid);          GF_FREE (client);  out:          return;  } +int +gf_client_disconnect (client_t *client) +{ +        int                ret   = 0; +        glusterfs_graph_t *gtrav = NULL; +        xlator_t          *xtrav = NULL; + +        list_for_each_entry (gtrav, &client->this->ctx->graphs, list) { +                xtrav = gtrav->top; +                while (xtrav != NULL) { +                        if (xtrav->cbks->client_disconnect != NULL) +                                if (xtrav->cbks->client_disconnect (xtrav, client) != 0) +                                        ret = -1; +                        xtrav = xtrav->next; +                } +        } + +        return ret; +} + +  void  gf_client_unref (client_t *client)  { @@ -392,37 +406,33 @@ gf_client_unref (client_t *client)  } -int -__client_ctx_set (client_t *client, xlator_t *xlator, uint64_t value) +static int +client_ctx_set_int (client_t *client, void *key, void *value)  {          int index   = 0;          int ret     = 0;          int set_idx = -1; -        if (!client || !xlator) -                return -1; -          for (index = 0; index < client->scratch_ctx.count; index++) { -                if (!client->scratch_ctx.ctx[index].key) { +                if (!client->scratch_ctx.ctx[index].ctx_key) {                          if (set_idx == -1)                                  set_idx = index;                          /* dont break, to check if key already exists                             further on */                  } -                if (client->scratch_ctx.ctx[index].xl_key == xlator) { +                if (client->scratch_ctx.ctx[index].ctx_key == key) {                          set_idx = index;                          break;                  }          }          if (set_idx == -1) { -                gf_log_callingfn ("", GF_LOG_WARNING, "%p %s", client, xlator->name);                  ret = -1;                  goto out;          } -        client->scratch_ctx.ctx[set_idx].xl_key = xlator; -        client->scratch_ctx.ctx[set_idx].value  = value; +        client->scratch_ctx.ctx[set_idx].ctx_key = key; +        client->scratch_ctx.ctx[set_idx].ctx_value  = value;  out:          return ret; @@ -430,18 +440,16 @@ out:  int -client_ctx_set (client_t *client, xlator_t *xlator, uint64_t value) +client_ctx_set (client_t *client, void *key, void *value)  {          int ret = 0; -        if (!client || !xlator) { -                gf_log_callingfn ("", GF_LOG_WARNING, "%p %p", client, xlator); +        if (!client || !key)                  return -1; -        }          LOCK (&client->scratch_ctx.lock);          { -                ret = __client_ctx_set (client, xlator, value); +                ret = client_ctx_set_int (client, key, value);          }          UNLOCK (&client->scratch_ctx.lock); @@ -449,17 +457,14 @@ client_ctx_set (client_t *client, xlator_t *xlator, uint64_t value)  } -int -__client_ctx_get (client_t *client, xlator_t *xlator, uint64_t *value) +static int +client_ctx_get_int (client_t *client, void *key, void **value)  {          int index = 0;          int ret   = 0; -        if (!client || !xlator) -                return -1; -          for (index = 0; index < client->scratch_ctx.count; index++) { -                if (client->scratch_ctx.ctx[index].xl_key == xlator) +                if (client->scratch_ctx.ctx[index].ctx_key == key)                          break;          } @@ -469,7 +474,7 @@ __client_ctx_get (client_t *client, xlator_t *xlator, uint64_t *value)          }          if (value) -                *value = client->scratch_ctx.ctx[index].value; +                *value = client->scratch_ctx.ctx[index].ctx_value;  out:          return ret; @@ -477,16 +482,16 @@ out:  int -client_ctx_get (client_t *client, xlator_t *xlator, uint64_t *value) +client_ctx_get (client_t *client, void *key, void **value)  {          int ret = 0; -        if (!client || !xlator) +        if (!client || !key)                  return -1;          LOCK (&client->scratch_ctx.lock);          { -                ret = __client_ctx_get (client, xlator, value); +                ret = client_ctx_get_int (client, key, value);          }          UNLOCK (&client->scratch_ctx.lock); @@ -494,17 +499,14 @@ client_ctx_get (client_t *client, xlator_t *xlator, uint64_t *value)  } -int -__client_ctx_del (client_t *client, xlator_t *xlator, uint64_t *value) +static int +client_ctx_del_int (client_t *client, void *key, void **value)  {          int index = 0;          int ret   = 0; -        if (!client || !xlator) -                return -1; -          for (index = 0; index < client->scratch_ctx.count; index++) { -                if (client->scratch_ctx.ctx[index].xl_key == xlator) +                if (client->scratch_ctx.ctx[index].ctx_key == key)                          break;          } @@ -514,10 +516,10 @@ __client_ctx_del (client_t *client, xlator_t *xlator, uint64_t *value)          }          if (value) -                *value = client->scratch_ctx.ctx[index].value; +                *value = client->scratch_ctx.ctx[index].ctx_value; -        client->scratch_ctx.ctx[index].key   = 0; -        client->scratch_ctx.ctx[index].value = 0; +        client->scratch_ctx.ctx[index].ctx_key   = 0; +        client->scratch_ctx.ctx[index].ctx_value = 0;  out:          return ret; @@ -525,16 +527,16 @@ out:  int -client_ctx_del (client_t *client, xlator_t *xlator, uint64_t *value) +client_ctx_del (client_t *client, void *key, void **value)  {          int ret = 0; -        if (!client || !xlator) +        if (!client || !key)                  return -1;          LOCK (&client->scratch_ctx.lock);          { -                ret = __client_ctx_del (client, xlator, value); +                ret = client_ctx_del_int (client, key, value);          }          UNLOCK (&client->scratch_ctx.lock); @@ -659,11 +661,13 @@ out:  int  gf_client_dump_fdtables_to_dict (xlator_t *this, dict_t *dict)  { -        client_t       *client      = NULL;          clienttable_t  *clienttable = NULL;          int             count       = 0;          int             ret         = -1; +#ifdef NOTYET +        client_t       *client      = NULL;          char            key[GF_DUMP_MAX_BUF_LEN] = {0,}; +#endif          GF_VALIDATE_OR_GOTO (THIS->name, this, out);          GF_VALIDATE_OR_GOTO (this->name, dict, out); @@ -673,6 +677,7 @@ gf_client_dump_fdtables_to_dict (xlator_t *this, dict_t *dict)          if (!clienttable)                  return -1; +#ifdef NOTYET          ret = TRY_LOCK (&clienttable->lock);          {                  if (ret) { @@ -692,6 +697,7 @@ gf_client_dump_fdtables_to_dict (xlator_t *this, dict_t *dict)                  }          }          UNLOCK(&clienttable->lock); +#endif          ret = dict_set_int32 (dict, "conncount", count);  out: @@ -729,11 +735,11 @@ gf_client_dump_fdtables (xlator_t *this)                                  continue;                          client = clienttable->cliententries[count].client;                          memset(key, 0, sizeof key); -                        if (client->server_ctx.client_uid) { +                        if (client->client_uid) {                                  gf_proc_dump_build_key (key, "conn",                                                          "%d.id", count);                                  gf_proc_dump_write (key, "%s", -                                                    client->server_ctx.client_uid); +                                                    client->client_uid);                          }                          gf_proc_dump_build_key (key, "conn", "%d.ref", @@ -746,8 +752,10 @@ gf_client_dump_fdtables (xlator_t *this)                                                      client->bound_xl->name);                          } +#ifdef NOTYET                          gf_proc_dump_build_key (key, "conn","%d.id", count);                          fdtable_dump (client->server_ctx.fdtable, key); +#endif                  }          } @@ -836,14 +844,14 @@ gf_client_dump_inodes (xlator_t *this)          clienttable = this->ctx->clienttable;          if (!clienttable) -                return -1; +                goto out;          ret = TRY_LOCK (&clienttable->lock);          {                  if (ret) {                          gf_log ("client_t", GF_LOG_WARNING,                                  "Unable to acquire lock"); -                        return -1; +                        goto out;                  }                  for ( ; count < clienttable->max_clients; count++) { @@ -879,3 +887,4 @@ gf_client_dump_inodes (xlator_t *this)  out:          return ret;  } + diff --git a/libglusterfs/src/client_t.h b/libglusterfs/src/client_t.h index 7b3fcf0dd3a..f7812f8f07d 100644 --- a/libglusterfs/src/client_t.h +++ b/libglusterfs/src/client_t.h @@ -20,37 +20,13 @@  #include "locking.h"  /* for gf_lock_t, not included by glusterfs.h */  struct client_ctx { -        union { -                uint64_t  key; -                void     *xl_key; -        }; -        union { -                uint64_t  value; -                void     *ptr1; -        }; +        void     *ctx_key; +        void     *ctx_value;  }; -struct _client_t { +typedef struct _client_t {          struct { -                /* ctx for .../xlators/protocol/server */ -                gf_lock_t            fdtable_lock; -                fdtable_t           *fdtable; -                char                *client_uid; -                struct _gf_timer    *grace_timer; -                uint32_t             lk_version; -                struct { -                        int          flavour; -                        size_t       len; -                        char        *data; -                }            auth; -        }            server_ctx; -        struct { -                /* ctx for .../xlators/features/locks */ -                gf_lock_t            ltable_lock; -                struct _lock_table  *ltable; -        }            locks_ctx; -        struct { -                /* e.g. hekafs uidmap can stash stuff here */ +                /* e.g. protocol/server stashes its ctx here */                  gf_lock_t            lock;                  unsigned short       count;                  struct client_ctx   *ctx; @@ -63,9 +39,15 @@ struct _client_t {          xlator_t    *bound_xl;          xlator_t    *this;          int          tbl_index; -}; -typedef struct _client_t client_t; +        char        *client_uid; +        struct { +                int                  flavour; +                size_t               len; +                char                *data; +        }            auth; +} client_t; +#define GF_CLIENTCTX_INITIAL_SIZE 8  struct client_table_entry {          client_t            *client; @@ -73,14 +55,13 @@ struct client_table_entry {  };  typedef struct client_table_entry cliententry_t; - -struct _clienttable { +struct clienttable {          unsigned int         max_clients;          gf_lock_t            lock;          cliententry_t       *cliententries;          int                  first_free;  }; -typedef struct _clienttable clienttable_t; +typedef struct clienttable clienttable_t;  #define GF_CLIENTTABLE_INITIAL_SIZE 32 @@ -92,10 +73,10 @@ typedef struct _clienttable clienttable_t;   */  #define GF_CLIENTENTRY_ALLOCATED    -2 - +struct rpcsvc_auth_data;  client_t * -gf_client_get (xlator_t *this, rpcsvc_auth_data_t *cred, char *client_uid); +gf_client_get (xlator_t *this, struct rpcsvc_auth_data *cred, char *client_uid);  void  gf_client_put (client_t *client, gf_boolean_t *detached); @@ -103,15 +84,12 @@ gf_client_put (client_t *client, gf_boolean_t *detached);  clienttable_t *  gf_clienttable_alloc (void); -  void  gf_client_clienttable_destroy (clienttable_t *clienttable); -  client_t *  gf_client_ref (client_t *client); -  void  gf_client_unref (client_t *client); @@ -128,27 +106,13 @@ int  gf_client_dump_inodes (xlator_t *this);  int -client_ctx_set (client_t *client, xlator_t *xlator, uint64_t value); - - -int -client_ctx_get (client_t *client, xlator_t *xlator, uint64_t *value); - - -int -client_ctx_del (client_t *client, xlator_t *xlator, uint64_t *value); - +client_ctx_set (client_t *client, void *key, void *value);  int -_client_ctx_set (client_t *client, xlator_t *xlator, uint64_t value); - +client_ctx_get (client_t *client, void *key, void **value);  int -_client_ctx_get (client_t *client, xlator_t *xlator, uint64_t *value); - - -int -_client_ctx_del (client_t *client, xlator_t *xlator, uint64_t *value); +client_ctx_del (client_t *client, void *key, void **value);  void  client_ctx_dump (client_t *client, char *prefix); @@ -165,4 +129,7 @@ gf_client_dump_inodes_to_dict (xlator_t *this, dict_t *dict);  int  gf_client_dump_inodes (xlator_t *this); +int +gf_client_disconnect (client_t *client); +  #endif /* _CLIENT_T_H */ diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h index ab571004e8a..b38d6d53e2c 100644 --- a/libglusterfs/src/glusterfs.h +++ b/libglusterfs/src/glusterfs.h @@ -392,7 +392,7 @@ struct _glusterfs_ctx {          char                fin;          void               *timer;          void               *ib; -        void               *pool; +        struct call_pool   *pool;          void               *event_pool;          void               *iobuf_pool;          pthread_mutex_t     lock; @@ -430,7 +430,8 @@ struct _glusterfs_ctx {          int                 daemon_pipe[2]; -        struct _clienttable *clienttable; +        struct client_disconnect *client_disconnect; +        struct clienttable *clienttable;  };  typedef struct _glusterfs_ctx glusterfs_ctx_t; diff --git a/libglusterfs/src/lock-table.c b/libglusterfs/src/lock-table.c deleted file mode 100644 index 42b7ed8a785..00000000000 --- a/libglusterfs/src/lock-table.c +++ /dev/null @@ -1,133 +0,0 @@ -/* -  Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com> -  This file is part of GlusterFS. - -  This file is licensed to you under your choice of the GNU Lesser -  General Public License, version 3 or any later version (LGPLv3 or -  later), or the GNU General Public License, version 2 (GPLv2), in all -  cases as published by the Free Software Foundation. -*/ - -#include "lock-table.h" -#include "common-utils.h" - - -struct _lock_table * -gf_lock_table_new (void) -{ -        struct _lock_table *new = NULL; - -        new = GF_CALLOC (1, sizeof (struct _lock_table), gf_common_mt_lock_table); -        if (new == NULL) { -                goto out; -        } -        INIT_LIST_HEAD (&new->entrylk_lockers); -        INIT_LIST_HEAD (&new->inodelk_lockers); -        LOCK_INIT (&new->lock); -out: -        return new; -} - - -int -gf_add_locker (struct _lock_table *table, const char *volume, -               loc_t *loc, fd_t *fd, pid_t pid, gf_lkowner_t *owner, -               glusterfs_fop_t type) -{ -        int32_t         ret = -1; -        struct _locker *new = NULL; - -        GF_VALIDATE_OR_GOTO ("lock-table", table, out); -        GF_VALIDATE_OR_GOTO ("lock-table", volume, out); - -        new = GF_CALLOC (1, sizeof (struct _locker), gf_common_mt_locker); -        if (new == NULL) { -                goto out; -        } -        INIT_LIST_HEAD (&new->lockers); - -        new->volume = gf_strdup (volume); - -        if (fd == NULL) { -                loc_copy (&new->loc, loc); -        } else { -                new->fd = fd_ref (fd); -        } - -        new->pid   = pid; -        new->owner = *owner; - -        LOCK (&table->lock); -        { -                if (type == GF_FOP_ENTRYLK) -                        list_add_tail (&new->lockers, &table->entrylk_lockers); -                else -                        list_add_tail (&new->lockers, &table->inodelk_lockers); -        } -        UNLOCK (&table->lock); -out: -        return ret; -} - -int -gf_del_locker (struct _lock_table *table, const char *volume, -               loc_t *loc, fd_t *fd, gf_lkowner_t *owner, glusterfs_fop_t type) -{ -        struct _locker    *locker = NULL; -        struct _locker    *tmp = NULL; -        int32_t            ret = -1; -        struct list_head  *head = NULL; -        struct list_head   del; - -        GF_VALIDATE_OR_GOTO ("lock-table", table, out); -        GF_VALIDATE_OR_GOTO ("lock-table", volume, out); - -        INIT_LIST_HEAD (&del); - -        LOCK (&table->lock); -        { -                if (type == GF_FOP_ENTRYLK) { -                        head = &table->entrylk_lockers; -                } else { -                        head = &table->inodelk_lockers; -                } - -                list_for_each_entry_safe (locker, tmp, head, lockers) { -                        if (!is_same_lkowner (&locker->owner, owner) || -                            strcmp (locker->volume, volume)) -                                continue; - -                        /* -                         * It is possible for inodelk lock to come on anon-fd -                         * and inodelk unlock to come on normal fd in case of -                         * client re-opens. So don't check for fds to be equal. -                         */ -                        if (locker->fd && fd) -                                list_move_tail (&locker->lockers, &del); -                        else if (locker->loc.inode && loc && -                                 (locker->loc.inode == loc->inode)) -                                list_move_tail (&locker->lockers, &del); -                } -        } -        UNLOCK (&table->lock); - -        tmp = NULL; -        locker = NULL; - -        list_for_each_entry_safe (locker, tmp, &del, lockers) { -                list_del_init (&locker->lockers); -                if (locker->fd) -                        fd_unref (locker->fd); -                else -                        loc_wipe (&locker->loc); - -                GF_FREE (locker->volume); -                GF_FREE (locker); -        } - -        ret = 0; -out: -        return ret; - -} - diff --git a/libglusterfs/src/lock-table.h b/libglusterfs/src/lock-table.h deleted file mode 100644 index 4a9083873f3..00000000000 --- a/libglusterfs/src/lock-table.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -  Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com> -  This file is part of GlusterFS. - -  This file is licensed to you under your choice of the GNU Lesser -  General Public License, version 3 or any later version (LGPLv3 or -  later), or the GNU General Public License, version 2 (GPLv2), in all -  cases as published by the Free Software Foundation. -*/ - -#ifndef _LOCK_TABLE_H -#define _LOCK_TABLE_H - -#ifndef _CONFIG_H -#define _CONFIG_H -#include "config.h" -#endif - -#include "xlator.h" - -struct _locker { -        struct list_head  lockers; -        char             *volume; -        loc_t             loc; -        fd_t             *fd; -        gf_lkowner_t      owner; -        pid_t             pid; -}; - -struct _lock_table { -        struct list_head  inodelk_lockers; -        struct list_head  entrylk_lockers; -        gf_lock_t         lock; -}; - -int32_t -gf_add_locker (struct _lock_table *table, const char *volume, -               loc_t *loc, -               fd_t *fd, -               pid_t pid, -               gf_lkowner_t *owner, -               glusterfs_fop_t type); - -int32_t -gf_del_locker (struct _lock_table *table, const char *volume, -               loc_t *loc, -               fd_t *fd, -               gf_lkowner_t *owner, -               glusterfs_fop_t type); - -struct _lock_table * -gf_lock_table_new (void); - -#endif /* _LOCK_TABLE_H */ diff --git a/libglusterfs/src/stack.h b/libglusterfs/src/stack.h index 0e8b705bdf7..f2d2ef95032 100644 --- a/libglusterfs/src/stack.h +++ b/libglusterfs/src/stack.h @@ -25,8 +25,8 @@ struct _call_stack_t;  typedef struct _call_stack_t call_stack_t;  struct _call_frame_t;  typedef struct _call_frame_t call_frame_t; -struct _call_pool_t; -typedef struct _call_pool_t call_pool_t; +struct call_pool; +typedef struct call_pool call_pool_t;  #include <sys/time.h> @@ -36,6 +36,7 @@ typedef struct _call_pool_t call_pool_t;  #include "common-utils.h"  #include "globals.h"  #include "lkowner.h" +#include "client_t.h"  #define NFS_PID 1  #define LOW_PRIO_PROC_PID -1 @@ -46,7 +47,7 @@ typedef int32_t (*ret_fn_t) (call_frame_t *frame,                               int32_t op_errno,                               ...); -struct _call_pool_t { +struct call_pool {          union {                  struct list_head   all_frames;                  struct { @@ -94,7 +95,7 @@ struct _call_stack_t {          };          call_pool_t                  *pool;          gf_lock_t                     stack_lock; -        void                         *trans; +        client_t                     *client;          uint64_t                      unique;          void                         *state;  /* pointer to request state */          uid_t                         uid; diff --git a/libglusterfs/src/xlator.h b/libglusterfs/src/xlator.h index 84a028fbcab..d6296262a13 100644 --- a/libglusterfs/src/xlator.h +++ b/libglusterfs/src/xlator.h @@ -66,6 +66,7 @@ typedef int32_t (*event_notify_fn_t) (xlator_t *this, int32_t event, void *data,  #include "globals.h"  #include "iatt.h"  #include "options.h" +#include "client_t.h"  struct _loc { @@ -766,11 +767,15 @@ typedef int32_t (*cbk_release_t) (xlator_t *this,  typedef int32_t (*cbk_invalidate_t)(xlator_t *this, inode_t *inode); +typedef int32_t (*cbk_client_t)(xlator_t *this, client_t *client); +  struct xlator_cbks { -        cbk_forget_t    forget; -        cbk_release_t   release; -        cbk_release_t   releasedir; -	cbk_invalidate_t invalidate; +        cbk_forget_t             forget; +        cbk_release_t            release; +        cbk_release_t            releasedir; +	cbk_invalidate_t         invalidate; +        cbk_client_t             client_destroy; +        cbk_client_t             client_disconnect;  };  typedef int32_t (*dumpop_priv_t) (xlator_t *this);  | 
