diff options
Diffstat (limited to 'libglusterfs/src/client_t.c')
| -rw-r--r-- | libglusterfs/src/client_t.c | 124 |
1 files changed, 15 insertions, 109 deletions
diff --git a/libglusterfs/src/client_t.c b/libglusterfs/src/client_t.c index 586cbd84e5c..9d377c3c2e1 100644 --- a/libglusterfs/src/client_t.c +++ b/libglusterfs/src/client_t.c @@ -8,13 +8,12 @@ cases as published by the Free Software Foundation. */ -#include "glusterfs.h" -#include "dict.h" -#include "statedump.h" -#include "client_t.h" -#include "list.h" -#include "rpcsvc.h" -#include "libglusterfs-messages.h" +#include "glusterfs/glusterfs.h" +#include "glusterfs/dict.h" +#include "glusterfs/statedump.h" +#include "glusterfs/client_t.h" +#include "glusterfs/list.h" +#include "glusterfs/libglusterfs-messages.h" static int gf_client_chain_client_entries(cliententry_t *entries, uint32_t startidx, @@ -110,50 +109,13 @@ gf_clienttable_alloc(void) return clienttable; } -void -gf_client_clienttable_destroy(clienttable_t *clienttable) -{ - client_t *client = NULL; - cliententry_t *cliententries = NULL; - uint32_t client_count = 0; - int32_t i = 0; - - if (!clienttable) { - gf_msg_callingfn("client_t", GF_LOG_WARNING, EINVAL, LG_MSG_INVALID_ARG, - "!clienttable"); - return; - } - - LOCK(&clienttable->lock); - { - client_count = clienttable->max_clients; - clienttable->max_clients = 0; - cliententries = clienttable->cliententries; - clienttable->cliententries = NULL; - } - UNLOCK(&clienttable->lock); - - if (cliententries != NULL) { - for (i = 0; i < client_count; i++) { - client = cliententries[i].client; - if (client != NULL) { - gf_client_unref(client); - } - } - - GF_FREE(cliententries); - LOCK_DESTROY(&clienttable->lock); - GF_FREE(clienttable); - } -} - /* * Increments ref.bind if the client is already present or creates a new * client with ref.bind = 1,ref.count = 1 it signifies that * as long as ref.bind is > 0 client should be alive. */ client_t * -gf_client_get(xlator_t *this, struct rpcsvc_auth_data *cred, char *client_uid, +gf_client_get(xlator_t *this, client_auth_data_t *cred, char *client_uid, char *subdir_mount) { client_t *client = NULL; @@ -181,11 +143,10 @@ gf_client_get(xlator_t *this, struct rpcsvc_auth_data *cred, char *client_uid, * if auth was used, matching auth flavour and data */ if (strcmp(client_uid, client->client_uid) == 0 && - (cred->flavour != AUTH_NONE && - (cred->flavour == client->auth.flavour && - (size_t)cred->datalen == client->auth.len && - memcmp(cred->authdata, client->auth.data, client->auth.len) == - 0))) { + (cred->flavour && (cred->flavour == client->auth.flavour && + (size_t)cred->datalen == client->auth.len && + memcmp(cred->authdata, client->auth.data, + client->auth.len) == 0))) { GF_ATOMIC_INC(client->bind); goto unlock; } @@ -224,9 +185,10 @@ gf_client_get(xlator_t *this, struct rpcsvc_auth_data *cred, char *client_uid, GF_ATOMIC_INIT(client->bind, 1); GF_ATOMIC_INIT(client->count, 1); + GF_ATOMIC_INIT(client->fd_cnt, 0); client->auth.flavour = cred->flavour; - if (cred->flavour != AUTH_NONE) { + if (cred->flavour) { client->auth.data = GF_MALLOC(cred->datalen, gf_common_mt_client_t); if (client->auth.data == NULL) { GF_FREE(client->scratch_ctx.ctx); @@ -352,8 +314,6 @@ client_destroy(client_t *client) clienttable = client->this->ctx->clienttable; - LOCK_DESTROY(&client->scratch_ctx.lock); - LOCK(&clienttable->lock); { clienttable->cliententries[client->tbl_index].client = NULL; @@ -371,6 +331,8 @@ client_destroy(client_t *client) if (client->subdir_inode) inode_unref(client->subdir_inode); + LOCK_DESTROY(&client->scratch_ctx.lock); + GF_FREE(client->auth.data); GF_FREE(client->auth.username); GF_FREE(client->auth.passwd); @@ -580,62 +542,6 @@ client_ctx_del(client_t *client, void *key, void **value) } void -client_dump(client_t *client, char *prefix) -{ - if (!client) - return; - - gf_proc_dump_write("refcount", "%" GF_PRI_ATOMIC, - GF_ATOMIC_GET(client->count)); -} - -void -cliententry_dump(cliententry_t *cliententry, char *prefix) -{ - if (!cliententry) - return; - - if (GF_CLIENTENTRY_ALLOCATED != cliententry->next_free) - return; - - if (cliententry->client) - client_dump(cliententry->client, prefix); -} - -void -clienttable_dump(clienttable_t *clienttable, char *prefix) -{ - int i = 0; - int ret = -1; - char key[GF_DUMP_MAX_BUF_LEN] = {0}; - - if (!clienttable) - return; - - ret = TRY_LOCK(&clienttable->lock); - { - if (ret) { - gf_msg("client_t", GF_LOG_WARNING, 0, LG_MSG_LOCK_FAILED, - "Unable to acquire lock"); - return; - } - gf_proc_dump_build_key(key, prefix, "maxclients"); - gf_proc_dump_write(key, "%d", clienttable->max_clients); - gf_proc_dump_build_key(key, prefix, "first_free"); - gf_proc_dump_write(key, "%d", clienttable->first_free); - for (i = 0; i < clienttable->max_clients; i++) { - if (GF_CLIENTENTRY_ALLOCATED == - clienttable->cliententries[i].next_free) { - gf_proc_dump_build_key(key, prefix, "cliententry[%d]", i); - gf_proc_dump_add_section("%s", key); - cliententry_dump(&clienttable->cliententries[i], key); - } - } - } - UNLOCK(&clienttable->lock); -} - -void client_ctx_dump(client_t *client, char *prefix) { #if 0 /* TBD, FIXME */ |
