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 | |
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>
24 files changed, 1216 insertions, 1226 deletions
diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c index edda64942e3..3cb8f0f515f 100644 --- a/glusterfsd/src/glusterfsd.c +++ b/glusterfsd/src/glusterfsd.c @@ -1203,10 +1203,9 @@ gf_get_process_mode (char *exec_name) static int glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx) { - cmd_args_t *cmd_args = NULL; - struct rlimit lim = {0, }; - call_pool_t *pool = NULL; - int ret = -1; + cmd_args_t *cmd_args = NULL; + struct rlimit lim = {0, }; + int ret = -1; xlator_mem_acct_init (THIS, gfd_mt_end); @@ -1233,24 +1232,26 @@ glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx) goto out; } - pool = GF_CALLOC (1, sizeof (call_pool_t), - gfd_mt_call_pool_t); - if (!pool) { + ctx->pool = GF_CALLOC (1, sizeof (call_pool_t), gfd_mt_call_pool_t); + if (!ctx->pool) { gf_log ("", GF_LOG_CRITICAL, "ERROR: glusterfs call pool creation failed"); goto out; } + INIT_LIST_HEAD (&ctx->pool->all_frames); + LOCK_INIT (&ctx->pool->lock); + /* frame_mem_pool size 112 * 4k */ - pool->frame_mem_pool = mem_pool_new (call_frame_t, 4096); - if (!pool->frame_mem_pool) { + ctx->pool->frame_mem_pool = mem_pool_new (call_frame_t, 4096); + if (!ctx->pool->frame_mem_pool) { gf_log ("", GF_LOG_CRITICAL, "ERROR: glusterfs frame pool creation failed"); goto out; } /* stack_mem_pool size 256 * 1024 */ - pool->stack_mem_pool = mem_pool_new (call_stack_t, 1024); - if (!pool->stack_mem_pool) { + ctx->pool->stack_mem_pool = mem_pool_new (call_stack_t, 1024); + if (!ctx->pool->stack_mem_pool) { gf_log ("", GF_LOG_CRITICAL, "ERROR: glusterfs stack pool creation failed"); goto out; @@ -1265,24 +1266,22 @@ glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx) ctx->dict_pool = mem_pool_new (dict_t, GF_MEMPOOL_COUNT_OF_DICT_T); if (!ctx->dict_pool) - return -1; + goto out; ctx->dict_pair_pool = mem_pool_new (data_pair_t, GF_MEMPOOL_COUNT_OF_DATA_PAIR_T); if (!ctx->dict_pair_pool) - return -1; + goto out; ctx->dict_data_pool = mem_pool_new (data_t, GF_MEMPOOL_COUNT_OF_DATA_T); if (!ctx->dict_data_pool) - return -1; - - INIT_LIST_HEAD (&pool->all_frames); - LOCK_INIT (&pool->lock); - ctx->pool = pool; + goto out; pthread_mutex_init (&(ctx->lock), NULL); ctx->clienttable = gf_clienttable_alloc(); + if (!ctx->clienttable) + goto out; cmd_args = &ctx->cmd_args; @@ -1312,29 +1311,16 @@ glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx) ret = 0; out: - if (ret && pool) { - - if (pool->frame_mem_pool) - mem_pool_destroy (pool->frame_mem_pool); - - if (pool->stack_mem_pool) - mem_pool_destroy (pool->stack_mem_pool); - - GF_FREE (pool); - } - if (ret && ctx) { - if (ctx->stub_mem_pool) - mem_pool_destroy (ctx->stub_mem_pool); - - if (ctx->dict_pool) - mem_pool_destroy (ctx->dict_pool); - - if (ctx->dict_data_pool) - mem_pool_destroy (ctx->dict_data_pool); - - if (ctx->dict_pair_pool) - mem_pool_destroy (ctx->dict_pair_pool); + if (ctx->pool) { + mem_pool_destroy (ctx->pool->frame_mem_pool); + mem_pool_destroy (ctx->pool->stack_mem_pool); + } + GF_FREE (ctx->pool); + mem_pool_destroy (ctx->stub_mem_pool); + mem_pool_destroy (ctx->dict_pool); + mem_pool_destroy (ctx->dict_data_pool); + mem_pool_destroy (ctx->dict_pair_pool); } return ret; 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); diff --git a/xlators/features/locks/src/Makefile.am b/xlators/features/locks/src/Makefile.am index 8908c1f5235..0f79731b415 100644 --- a/xlators/features/locks/src/Makefile.am +++ b/xlators/features/locks/src/Makefile.am @@ -11,6 +11,7 @@ noinst_HEADERS = locks.h common.h locks-mem-types.h clear.h AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src + AM_CFLAGS = -Wall -fno-strict-aliasing $(GF_CFLAGS) CLEANFILES = diff --git a/xlators/features/locks/src/common.c b/xlators/features/locks/src/common.c index bc4ea53f985..b3309580d3d 100644 --- a/xlators/features/locks/src/common.c +++ b/xlators/features/locks/src/common.c @@ -35,6 +35,7 @@ __insert_and_merge (pl_inode_t *pl_inode, posix_lock_t *lock); static int pl_send_prelock_unlock (xlator_t *this, pl_inode_t *pl_inode, posix_lock_t *old_lock); + static pl_dom_list_t * __allocate_domain (const char *volume) { @@ -75,8 +76,8 @@ get_domain (pl_inode_t *pl_inode, const char *volume) { pl_dom_list_t *dom = NULL; - GF_VALIDATE_OR_GOTO (POSIX_LOCKS, pl_inode, out); - GF_VALIDATE_OR_GOTO (POSIX_LOCKS, volume, out); + GF_VALIDATE_OR_GOTO ("posix-locks", pl_inode, out); + GF_VALIDATE_OR_GOTO ("posix-locks", volume, out); pthread_mutex_lock (&pl_inode->mutex); { @@ -92,9 +93,9 @@ get_domain (pl_inode_t *pl_inode, const char *volume) unlock: pthread_mutex_unlock (&pl_inode->mutex); if (dom) { - gf_log (POSIX_LOCKS, GF_LOG_TRACE, "Domain %s found", volume); + gf_log ("posix-locks", GF_LOG_TRACE, "Domain %s found", volume); } else { - gf_log (POSIX_LOCKS, GF_LOG_TRACE, "Domain %s not found", volume); + gf_log ("posix-locks", GF_LOG_TRACE, "Domain %s not found", volume); } out: return dom; @@ -138,7 +139,7 @@ pl_print_locker (char *str, int size, xlator_t *this, call_frame_t *frame) snprintf (str, size, "Pid=%llu, lk-owner=%s, Client=%p, Frame=%llu", (unsigned long long) frame->root->pid, lkowner_utoa (&frame->root->lk_owner), - frame->root->trans, + frame->root->client, (unsigned long long) frame->root->unique); } @@ -462,14 +463,14 @@ unlock: /* Create a new posix_lock_t */ posix_lock_t * -new_posix_lock (struct gf_flock *flock, void *transport, pid_t client_pid, +new_posix_lock (struct gf_flock *flock, client_t *client, pid_t client_pid, gf_lkowner_t *owner, fd_t *fd) { posix_lock_t *lock = NULL; - GF_VALIDATE_OR_GOTO (POSIX_LOCKS, flock, out); - GF_VALIDATE_OR_GOTO (POSIX_LOCKS, transport, out); - GF_VALIDATE_OR_GOTO (POSIX_LOCKS, fd, out); + GF_VALIDATE_OR_GOTO ("posix-locks", flock, out); + GF_VALIDATE_OR_GOTO ("posix-locks", client, out); + GF_VALIDATE_OR_GOTO ("posix-locks", fd, out); lock = GF_CALLOC (1, sizeof (posix_lock_t), gf_locks_mt_posix_lock_t); @@ -485,7 +486,7 @@ new_posix_lock (struct gf_flock *flock, void *transport, pid_t client_pid, else lock->fl_end = flock->l_start + flock->l_len - 1; - lock->transport = transport; + lock->client = client; lock->fd_num = fd_to_fdnum (fd); lock->fd = fd; lock->client_pid = client_pid; @@ -565,7 +566,7 @@ same_owner (posix_lock_t *l1, posix_lock_t *l2) { return (is_same_lkowner (&l1->owner, &l2->owner) && - (l1->transport == l2->transport)); + (l1->client == l2->client)); } @@ -694,7 +695,7 @@ subtract_locks (posix_lock_t *big, posix_lock_t *small) } GF_ASSERT (0); - gf_log (POSIX_LOCKS, GF_LOG_ERROR, "Unexpected case in subtract_locks"); + gf_log ("posix-locks", GF_LOG_ERROR, "Unexpected case in subtract_locks"); out: if (v.locks[0]) { @@ -812,7 +813,7 @@ __insert_and_merge (pl_inode_t *pl_inode, posix_lock_t *lock) sum = add_locks (lock, conf); sum->fl_type = lock->fl_type; - sum->transport = lock->transport; + sum->client = lock->client; sum->fd_num = lock->fd_num; sum->client_pid = lock->client_pid; sum->owner = lock->owner; @@ -830,7 +831,7 @@ __insert_and_merge (pl_inode_t *pl_inode, posix_lock_t *lock) sum = add_locks (lock, conf); sum->fl_type = conf->fl_type; - sum->transport = conf->transport; + sum->client = conf->client; sum->fd_num = conf->fd_num; sum->client_pid = conf->client_pid; sum->owner = conf->owner; @@ -988,7 +989,7 @@ pl_send_prelock_unlock (xlator_t *this, pl_inode_t *pl_inode, flock.l_len = old_lock->user_flock.l_len; - unlock_lock = new_posix_lock (&flock, old_lock->transport, + unlock_lock = new_posix_lock (&flock, old_lock->client, old_lock->client_pid, &old_lock->owner, old_lock->fd); GF_VALIDATE_OR_GOTO (this->name, unlock_lock, out); @@ -1097,3 +1098,124 @@ pl_getlk (pl_inode_t *pl_inode, posix_lock_t *lock) return conf; } + + +struct _lock_table * +pl_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 +pl_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 +pl_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/xlators/features/locks/src/common.h b/xlators/features/locks/src/common.h index 4fbac5935fd..db19ec978b4 100644 --- a/xlators/features/locks/src/common.h +++ b/xlators/features/locks/src/common.h @@ -14,7 +14,7 @@ /*dump locks format strings */ #define RANGE_FMT "type=%s, whence=%hd, start=%llu, len=%llu" #define ENTRY_FMT "type=%s on basename=%s" -#define DUMP_GEN_FMT "pid = %llu, owner=%s, transport=%p" +#define DUMP_GEN_FMT "pid = %llu, owner=%s, client=%p" #define GRNTD_AT "granted at %s" #define BLKD_AT "blocked at %s" #define CONN_ID "connection-id=%s" @@ -31,8 +31,24 @@ #define RANGE_BLKD_GRNTD_FMT RANGE_FMT", "DUMP_BLKD_GRNTD_FMT #define SET_FLOCK_PID(flock, lock) ((flock)->l_pid = lock->client_pid) + +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; +}; + posix_lock_t * -new_posix_lock (struct gf_flock *flock, void *transport, pid_t client_pid, +new_posix_lock (struct gf_flock *flock, client_t *client, pid_t client_pid, gf_lkowner_t *owner, fd_t *fd); pl_inode_t * @@ -146,6 +162,26 @@ pl_verify_reservelk (xlator_t *this, pl_inode_t *pl_inode, posix_lock_t *lock, int can_block); int pl_reserve_unlock (xlator_t *this, pl_inode_t *pl_inode, posix_lock_t *reqlock); + uint32_t check_entrylk_on_basename (xlator_t *this, inode_t *parent, char *basename); + +int32_t +pl_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 +pl_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 * +pl_lock_table_new (void); + #endif /* __COMMON_H__ */ diff --git a/xlators/features/locks/src/entrylk.c b/xlators/features/locks/src/entrylk.c index 6b649437e4a..0785dc547fc 100644 --- a/xlators/features/locks/src/entrylk.c +++ b/xlators/features/locks/src/entrylk.c @@ -25,7 +25,7 @@ static pl_entry_lock_t * new_entrylk_lock (pl_inode_t *pinode, const char *basename, entrylk_type type, - void *trans, pid_t client_pid, gf_lkowner_t *owner, + client_t *client, pid_t client_pid, gf_lkowner_t *owner, const char *volume) { @@ -39,7 +39,7 @@ new_entrylk_lock (pl_inode_t *pinode, const char *basename, entrylk_type type, newlock->basename = basename ? gf_strdup (basename) : NULL; newlock->type = type; - newlock->trans = trans; + newlock->trans = client; newlock->volume = volume; newlock->client_pid = client_pid; newlock->owner = *owner; @@ -310,14 +310,10 @@ __lock_name (pl_inode_t *pinode, const char *basename, entrylk_type type, { pl_entry_lock_t *lock = NULL; pl_entry_lock_t *conf = NULL; - void *trans = NULL; - pid_t client_pid = 0; int ret = -EINVAL; - trans = frame->root->trans; - client_pid = frame->root->pid; - - lock = new_entrylk_lock (pinode, basename, type, trans, client_pid, + lock = new_entrylk_lock (pinode, basename, type, + frame->root->client, frame->root->pid, &frame->root->lk_owner, dom->domain); if (!lock) { ret = -ENOMEM; @@ -326,7 +322,7 @@ __lock_name (pl_inode_t *pinode, const char *basename, entrylk_type type, lock->frame = frame; lock->this = this; - lock->trans = trans; + lock->trans = frame->root->client; if (conn_id) { lock->connection_id = gf_strdup (conn_id); @@ -531,8 +527,8 @@ grant_blocked_entry_locks (xlator_t *this, pl_inode_t *pl_inode, STACK_UNWIND_STRICT (entrylk, lock->frame, 0, 0, NULL); GF_FREE (lock->connection_id); - GF_FREE ((char *)lock->basename); - GF_FREE (lock); + GF_FREE ((char *)lock->basename); + GF_FREE (lock); } GF_FREE ((char *)unlocked->basename); @@ -543,13 +539,13 @@ grant_blocked_entry_locks (xlator_t *this, pl_inode_t *pl_inode, } /** - * release_entry_locks_for_transport: release all entry locks from this - * transport for this loc_t + * release_entry_locks_for_client: release all entry locks from this + * client for this loc_t */ static int -release_entry_locks_for_transport (xlator_t *this, pl_inode_t *pinode, - pl_dom_list_t *dom, void *trans) +release_entry_locks_for_client (xlator_t *this, pl_inode_t *pinode, + pl_dom_list_t *dom, client_t *client) { pl_entry_lock_t *lock = NULL; pl_entry_lock_t *tmp = NULL; @@ -563,14 +559,14 @@ release_entry_locks_for_transport (xlator_t *this, pl_inode_t *pinode, { list_for_each_entry_safe (lock, tmp, &dom->blocked_entrylks, blocked_locks) { - if (lock->trans != trans) + if (lock->trans != client) continue; list_del_init (&lock->blocked_locks); gf_log (this->name, GF_LOG_TRACE, "releasing lock on held by " - "{transport=%p}",trans); + "{client=%p}", client); list_add (&lock->blocked_locks, &released); @@ -578,14 +574,14 @@ release_entry_locks_for_transport (xlator_t *this, pl_inode_t *pinode, list_for_each_entry_safe (lock, tmp, &dom->entrylk_list, domain_list) { - if (lock->trans != trans) + if (lock->trans != client) continue; list_del_init (&lock->domain_list); gf_log (this->name, GF_LOG_TRACE, "releasing lock on held by " - "{transport=%p}",trans); + "{client=%p}", client); GF_FREE ((char *)lock->basename); GF_FREE (lock->connection_id); @@ -630,19 +626,16 @@ pl_common_entrylk (call_frame_t *frame, xlator_t *this, dict_t *xdata) { - int32_t op_ret = -1; - int32_t op_errno = 0; - - void * transport = NULL; - - pl_inode_t * pinode = NULL; + int32_t op_ret = -1; + int32_t op_errno = 0; int ret = -1; - pl_entry_lock_t *unlocked = NULL; char unwind = 1; - - pl_dom_list_t *dom = NULL; - char *conn_id = NULL; GF_UNUSED int dict_ret = -1; + pl_inode_t *pinode = NULL; + pl_entry_lock_t *unlocked = NULL; + pl_dom_list_t *dom = NULL; + char *conn_id = NULL; + pl_ctx_t *ctx = NULL; if (xdata) dict_ret = dict_get_str (xdata, "connection-id", &conn_id); @@ -661,19 +654,17 @@ pl_common_entrylk (call_frame_t *frame, xlator_t *this, entrylk_trace_in (this, frame, volume, fd, loc, basename, cmd, type); - transport = frame->root->trans; - if (frame->root->lk_owner.len == 0) { /* this is a special case that means release - all locks from this transport + all locks from this client */ gf_log (this->name, GF_LOG_TRACE, - "Releasing locks for transport %p", transport); + "Releasing locks for client %p", frame->root->client); - release_entry_locks_for_transport (this, pinode, dom, - transport); + release_entry_locks_for_client (this, pinode, dom, + frame->root->client); op_ret = 0; goto out; @@ -746,6 +737,24 @@ out: entrylk_trace_out (this, frame, volume, fd, loc, basename, cmd, type, op_ret, op_errno); + ctx = pl_ctx_get (frame->root->client, this); + + if (ctx == NULL) { + gf_log (this->name, GF_LOG_INFO, "pl_ctx_get() failed"); + goto unwind; + } + + if (cmd == ENTRYLK_UNLOCK) + pl_del_locker (ctx->ltable, volume, loc, fd, + &frame->root->lk_owner, + GF_FOP_ENTRYLK); + else + pl_add_locker (ctx->ltable, volume, loc, fd, + frame->root->pid, + &frame->root->lk_owner, + GF_FOP_ENTRYLK); + +unwind: STACK_UNWIND_STRICT (entrylk, frame, op_ret, op_errno, NULL); } else { entrylk_trace_block (this, frame, volume, fd, loc, basename, @@ -767,7 +776,6 @@ pl_entrylk (call_frame_t *frame, xlator_t *this, const char *volume, loc_t *loc, const char *basename, entrylk_cmd cmd, entrylk_type type, dict_t *xdata) { - pl_common_entrylk (frame, this, volume, loc->inode, basename, cmd, type, loc, NULL, xdata); @@ -786,7 +794,6 @@ pl_fentrylk (call_frame_t *frame, xlator_t *this, const char *volume, fd_t *fd, const char *basename, entrylk_cmd cmd, entrylk_type type, dict_t *xdata) { - pl_common_entrylk (frame, this, volume, fd->inode, basename, cmd, type, NULL, fd, xdata); diff --git a/xlators/features/locks/src/inodelk.c b/xlators/features/locks/src/inodelk.c index 7b5c170337e..508523e1106 100644 --- a/xlators/features/locks/src/inodelk.c +++ b/xlators/features/locks/src/inodelk.c @@ -124,7 +124,7 @@ static inline int same_inodelk_owner (pl_inode_lock_t *l1, pl_inode_lock_t *l2) { return (is_same_lkowner (&l1->owner, &l2->owner) && - (l1->transport == l2->transport)); + (l1->client == l2->client)); } /* Returns true if the 2 inodelks conflict with each other */ @@ -294,7 +294,7 @@ __inode_unlock_lock (xlator_t *this, pl_inode_lock_t *lock, pl_dom_list_t *dom) " Matching lock not found for unlock %llu-%llu, by %s " "on %p", (unsigned long long)lock->fl_start, (unsigned long long)lock->fl_end, - lkowner_utoa (&lock->owner), lock->transport); + lkowner_utoa (&lock->owner), lock->client); goto out; } __delete_inode_lock (conf); @@ -302,7 +302,7 @@ __inode_unlock_lock (xlator_t *this, pl_inode_lock_t *lock, pl_dom_list_t *dom) " Matching lock found for unlock %llu-%llu, by %s on %p", (unsigned long long)lock->fl_start, (unsigned long long)lock->fl_end, lkowner_utoa (&lock->owner), - lock->transport); + lock->client); out: return conf; @@ -375,10 +375,10 @@ grant_blocked_inode_locks (xlator_t *this, pl_inode_t *pl_inode, pthread_mutex_unlock (&pl_inode->mutex); } -/* Release all inodelks from this transport */ +/* Release all inodelks from this client */ static int -release_inode_locks_of_transport (xlator_t *this, pl_dom_list_t *dom, - inode_t *inode, void *trans) +release_inode_locks_of_client (xlator_t *this, pl_dom_list_t *dom, + inode_t *inode, client_t *client) { pl_inode_lock_t *tmp = NULL; pl_inode_lock_t *l = NULL; @@ -398,7 +398,7 @@ release_inode_locks_of_transport (xlator_t *this, pl_dom_list_t *dom, { list_for_each_entry_safe (l, tmp, &dom->blocked_inodelks, blocked_locks) { - if (l->transport != trans) + if (l->client != client) continue; list_del_init (&l->blocked_locks); @@ -411,8 +411,8 @@ release_inode_locks_of_transport (xlator_t *this, pl_dom_list_t *dom, gf_log (this->name, GF_LOG_DEBUG, "releasing blocking lock on %s held by " - "{transport=%p, pid=%"PRId64" lk-owner=%s}", - file, trans, (uint64_t) l->client_pid, + "{client=%p, pid=%"PRId64" lk-owner=%s}", + file, client, (uint64_t) l->client_pid, lkowner_utoa (&l->owner)); list_add (&l->blocked_locks, &released); @@ -423,7 +423,7 @@ release_inode_locks_of_transport (xlator_t *this, pl_dom_list_t *dom, } list_for_each_entry_safe (l, tmp, &dom->inodelk_list, list) { - if (l->transport != trans) + if (l->client != client) continue; inode_path (inode, NULL, &path); @@ -434,8 +434,8 @@ release_inode_locks_of_transport (xlator_t *this, pl_dom_list_t *dom, gf_log (this->name, GF_LOG_DEBUG, "releasing granted lock on %s held by " - "{transport=%p, pid=%"PRId64" lk-owner=%s}", - file, trans, (uint64_t) l->client_pid, + "{client=%p, pid=%"PRId64" lk-owner=%s}", + file, client, (uint64_t) l->client_pid, lkowner_utoa (&l->owner)); if (path) { @@ -518,7 +518,7 @@ out: /* Create a new inode_lock_t */ pl_inode_lock_t * -new_inode_lock (struct gf_flock *flock, void *transport, pid_t client_pid, +new_inode_lock (struct gf_flock *flock, client_t *client, pid_t client_pid, call_frame_t *frame, xlator_t *this, const char *volume, char *conn_id) @@ -539,7 +539,7 @@ new_inode_lock (struct gf_flock *flock, void *transport, pid_t client_pid, else lock->fl_end = flock->l_start + flock->l_len - 1; - lock->transport = transport; + lock->client = client; lock->client_pid = client_pid; lock->volume = volume; lock->owner = frame->root->lk_owner; @@ -599,14 +599,13 @@ pl_common_inodelk (call_frame_t *frame, xlator_t *this, int ret = -1; GF_UNUSED int dict_ret = -1; int can_block = 0; - pid_t client_pid = -1; - void * transport = NULL; pl_inode_t * pinode = NULL; pl_inode_lock_t * reqlock = NULL; pl_dom_list_t * dom = NULL; char *res = NULL; char *res1 = NULL; - char *conn_id = NULL; + char *conn_id = NULL; + pl_ctx_t *ctx = NULL; if (xdata) dict_ret = dict_get_str (xdata, "connection-id", &conn_id); @@ -628,9 +627,6 @@ pl_common_inodelk (call_frame_t *frame, xlator_t *this, pl_trace_in (this, frame, fd, loc, cmd, flock, volume); - transport = frame->root->trans; - client_pid = frame->root->pid; - pinode = pl_inode_get (this, inode); if (!pinode) { op_errno = ENOMEM; @@ -646,25 +642,25 @@ pl_common_inodelk (call_frame_t *frame, xlator_t *this, if (frame->root->lk_owner.len == 0) { /* special case: this means release all locks - from this transport + from this client */ gf_log (this->name, GF_LOG_TRACE, - "Releasing all locks from transport %p", transport); + "Releasing all locks from client %p", frame->root->client); - release_inode_locks_of_transport (this, dom, inode, transport); + release_inode_locks_of_client (this, dom, inode, frame->root->client); _pl_convert_volume (volume, &res1); if (res1) { dom = get_domain (pinode, res1); if (dom) - release_inode_locks_of_transport (this, dom, - inode, transport); + release_inode_locks_of_client (this, dom, + inode, frame->root->client); } op_ret = 0; goto unwind; } - reqlock = new_inode_lock (flock, transport, client_pid, + reqlock = new_inode_lock (flock, frame->root->client, frame->root->pid, frame, this, volume, conn_id); if (!reqlock) { @@ -708,6 +704,23 @@ pl_common_inodelk (call_frame_t *frame, xlator_t *this, op_ret = 0; + ctx = pl_ctx_get (frame->root->client, this); + + if (ctx == NULL) { + gf_log (this->name, GF_LOG_INFO, "pl_ctx_get() failed"); + goto unwind; + } + + if (flock->l_type == F_UNLCK) + pl_del_locker (ctx->ltable, volume, loc, fd, + &frame->root->lk_owner, + GF_FOP_INODELK); + else + pl_add_locker (ctx->ltable, volume, loc, fd, + frame->root->pid, + &frame->root->lk_owner, + GF_FOP_INODELK); + unwind: if ((inode != NULL) && (flock !=NULL)) { pl_update_refkeeper (this, inode); @@ -726,9 +739,8 @@ pl_inodelk (call_frame_t *frame, xlator_t *this, const char *volume, loc_t *loc, int32_t cmd, struct gf_flock *flock, dict_t *xdata) { - - pl_common_inodelk (frame, this, volume, loc->inode, cmd, flock, loc, NULL, - xdata); + pl_common_inodelk (frame, this, volume, loc->inode, cmd, flock, + loc, NULL, xdata); return 0; } @@ -738,9 +750,8 @@ pl_finodelk (call_frame_t *frame, xlator_t *this, const char *volume, fd_t *fd, int32_t cmd, struct gf_flock *flock, dict_t *xdata) { - - pl_common_inodelk (frame, this, volume, fd->inode, cmd, flock, NULL, fd, - xdata); + pl_common_inodelk (frame, this, volume, fd->inode, cmd, flock, + NULL, fd, xdata); return 0; diff --git a/xlators/features/locks/src/locks.h b/xlators/features/locks/src/locks.h index 5bd0b05e05f..76fc941d74c 100644 --- a/xlators/features/locks/src/locks.h +++ b/xlators/features/locks/src/locks.h @@ -19,10 +19,10 @@ #include "stack.h" #include "call-stub.h" #include "locks-mem-types.h" +#include "client_t.h" #include "lkowner.h" -#define POSIX_LOCKS "posix-locks" struct __pl_fd; struct __posix_lock { @@ -33,7 +33,7 @@ struct __posix_lock { off_t fl_end; short blocked; /* waiting to acquire */ - struct gf_flock user_flock; /* the flock supplied by the user */ + struct gf_flock user_flock; /* the flock supplied by the user */ xlator_t *this; /* required for blocked locks */ unsigned long fd_num; @@ -46,7 +46,7 @@ struct __posix_lock { /* These two together serve to uniquely identify each process across nodes */ - void *transport; /* to identify client node */ + void *client; /* to identify client node */ gf_lkowner_t owner; pid_t client_pid; /* pid of client process */ }; @@ -63,7 +63,7 @@ struct __pl_inode_lock { const char *volume; - struct gf_flock user_flock; /* the flock supplied by the user */ + struct gf_flock user_flock; /* the flock supplied by the user */ xlator_t *this; /* required for blocked locks */ fd_t *fd; @@ -75,7 +75,7 @@ struct __pl_inode_lock { /* These two together serve to uniquely identify each process across nodes */ - void *transport; /* to identify client node */ + void *client; /* to identify client node */ gf_lkowner_t owner; pid_t client_pid; /* pid of client process */ @@ -156,6 +156,7 @@ typedef struct { char *brickname; } posix_locks_private_t; + typedef struct { gf_boolean_t entrylk_count_req; gf_boolean_t inodelk_count_req; @@ -171,8 +172,21 @@ typedef struct { enum {TRUNCATE, FTRUNCATE} op; } pl_local_t; + typedef struct { struct list_head locks_list; } pl_fdctx_t; + +typedef struct _locks_ctx { + gf_lock_t ltable_lock; /* only for replace, + ltable has its own internal + lock for operations */ + struct _lock_table *ltable; +} pl_ctx_t; + + +pl_ctx_t * +pl_ctx_get (client_t *client, xlator_t *xlator); + #endif /* __POSIX_LOCKS_H__ */ diff --git a/xlators/features/locks/src/posix.c b/xlators/features/locks/src/posix.c index 0d6f32fa328..7bfb38a51ac 100644 --- a/xlators/features/locks/src/posix.c +++ b/xlators/features/locks/src/posix.c @@ -51,7 +51,7 @@ pl_new_fdctx () fdctx = GF_CALLOC (1, sizeof (*fdctx), gf_locks_mt_pl_fdctx_t); - GF_VALIDATE_OR_GOTO (POSIX_LOCKS, fdctx, out); + GF_VALIDATE_OR_GOTO ("posix-locks", fdctx, out); INIT_LIST_HEAD (&fdctx->locks_list); @@ -66,7 +66,7 @@ pl_check_n_create_fdctx (xlator_t *this, fd_t *fd) uint64_t tmp = 0; pl_fdctx_t *fdctx = NULL; - GF_VALIDATE_OR_GOTO (POSIX_LOCKS, this, out); + GF_VALIDATE_OR_GOTO ("posix-locks", this, out); GF_VALIDATE_OR_GOTO (this->name, fd, out); LOCK (&fd->lock); @@ -119,7 +119,7 @@ pl_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, static int truncate_allowed (pl_inode_t *pl_inode, - void *transport, pid_t client_pid, + client_t *client, pid_t client_pid, gf_lkowner_t *owner, off_t offset) { posix_lock_t *l = NULL; @@ -128,7 +128,7 @@ truncate_allowed (pl_inode_t *pl_inode, region.fl_start = offset; region.fl_end = LLONG_MAX; - region.transport = transport; + region.client = client; region.client_pid = client_pid; region.owner = *owner; @@ -139,7 +139,7 @@ truncate_allowed (pl_inode_t *pl_inode, && locks_overlap (®ion, l) && !same_owner (®ion, l)) { ret = 0; - gf_log (POSIX_LOCKS, GF_LOG_TRACE, "Truncate " + gf_log ("posix-locks", GF_LOG_TRACE, "Truncate " "allowed"); break; } @@ -186,7 +186,7 @@ truncate_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if (priv->mandatory && pl_inode->mandatory - && !truncate_allowed (pl_inode, frame->root->trans, + && !truncate_allowed (pl_inode, frame->root->client, frame->root->pid, &frame->root->lk_owner, local->offset)) { op_ret = -1; @@ -347,7 +347,7 @@ delete_locks_of_fd (xlator_t *this, pl_inode_t *pl_inode, fd_t *fd) static void __delete_locks_of_owner (pl_inode_t *pl_inode, - void *transport, gf_lkowner_t *owner) + client_t *client, gf_lkowner_t *owner) { posix_lock_t *tmp = NULL; posix_lock_t *l = NULL; @@ -357,7 +357,7 @@ __delete_locks_of_owner (pl_inode_t *pl_inode, list_for_each_entry_safe (l, tmp, &pl_inode->ext_list, list) { if (l->blocked) continue; - if ((l->transport == transport) && + if ((l->client == client) && is_same_lkowner (&l->owner, owner)) { gf_log ("posix-locks", GF_LOG_TRACE, " Flushing lock" @@ -810,7 +810,7 @@ pl_migrate_locks (call_frame_t *frame, fd_t *newfd, uint64_t oldfd_num, list_for_each_entry (l, &pl_inode->ext_list, list) { if (l->fd_num == oldfd_num) { l->fd_num = newfd_num; - l->transport = frame->root->trans; + l->client = frame->root->client; } } } @@ -983,7 +983,7 @@ pl_flush (call_frame_t *frame, xlator_t *this, } pthread_mutex_lock (&pl_inode->mutex); { - __delete_locks_of_owner (pl_inode, frame->root->trans, + __delete_locks_of_owner (pl_inode, frame->root->client, &frame->root->lk_owner); } pthread_mutex_unlock (&pl_inode->mutex); @@ -1178,7 +1178,7 @@ pl_readv (call_frame_t *frame, xlator_t *this, if (priv->mandatory && pl_inode->mandatory) { region.fl_start = offset; region.fl_end = offset + size - 1; - region.transport = frame->root->trans; + region.client = frame->root->client; region.fd_num = fd_to_fdnum(fd); region.client_pid = frame->root->pid; region.owner = frame->root->lk_owner; @@ -1272,7 +1272,7 @@ pl_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, if (priv->mandatory && pl_inode->mandatory) { region.fl_start = offset; region.fl_end = offset + iov_length (vector, count) - 1; - region.transport = frame->root->trans; + region.client = frame->root->client; region.fd_num = fd_to_fdnum(fd); region.client_pid = frame->root->pid; region.owner = frame->root->lk_owner; @@ -1353,7 +1353,7 @@ lock_dup (posix_lock_t *lock) { posix_lock_t *new_lock = NULL; - new_lock = new_posix_lock (&lock->user_flock, lock->transport, + new_lock = new_posix_lock (&lock->user_flock, lock->client, lock->client_pid, &lock->owner, (fd_t *)lock->fd_num); return new_lock; @@ -1513,8 +1513,6 @@ int pl_lk (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t cmd, struct gf_flock *flock, dict_t *xdata) { - void *transport = NULL; - pid_t client_pid = 0; pl_inode_t *pl_inode = NULL; int op_ret = 0; int op_errno = 0; @@ -1523,9 +1521,6 @@ pl_lk (call_frame_t *frame, xlator_t *this, posix_lock_t *conf = NULL; int ret = 0; - transport = frame->root->trans; - client_pid = frame->root->pid; - if ((flock->l_start < 0) || (flock->l_len < 0)) { op_ret = -1; op_errno = EINVAL; @@ -1539,7 +1534,7 @@ pl_lk (call_frame_t *frame, xlator_t *this, goto unwind; } - reqlock = new_posix_lock (flock, transport, client_pid, + reqlock = new_posix_lock (flock, frame->root->client, frame->root->pid, &frame->root->lk_owner, fd); if (!reqlock) { @@ -2328,7 +2323,7 @@ __dump_inodelks (pl_inode_t *pl_inode) SET_FLOCK_PID (&lock->user_flock, lock); pl_dump_lock (tmp, 256, &lock->user_flock, &lock->owner, - lock->transport, lock->connection_id, + lock->client, lock->connection_id, &lock->granted_time.tv_sec, &lock->blkd_time.tv_sec, _gf_true); @@ -2345,7 +2340,7 @@ __dump_inodelks (pl_inode_t *pl_inode) SET_FLOCK_PID (&lock->user_flock, lock); pl_dump_lock (tmp, 256, &lock->user_flock, &lock->owner, - lock->transport, lock->connection_id, + lock->client, lock->connection_id, 0, &lock->blkd_time.tv_sec, _gf_false); gf_proc_dump_write(key, tmp); @@ -2386,7 +2381,7 @@ __dump_posixlks (pl_inode_t *pl_inode) count, lock->blocked ? "BLOCKED" : "ACTIVE"); pl_dump_lock (tmp, 256, &lock->user_flock, - &lock->owner, lock->transport, NULL, + &lock->owner, lock->client, NULL, &lock->granted_time.tv_sec, &lock->blkd_time.tv_sec, (lock->blocked)? _gf_false: _gf_true); gf_proc_dump_write(key, tmp); @@ -2510,6 +2505,124 @@ mem_acct_init (xlator_t *this) return ret; } + +pl_ctx_t* +pl_ctx_get (client_t *client, xlator_t *xlator) +{ + void *tmp = NULL; + pl_ctx_t *ctx = NULL; + + client_ctx_get (client, xlator, &tmp); + + ctx = tmp; + + if (ctx != NULL) + goto out; + + ctx = GF_CALLOC (1, sizeof (pl_ctx_t), gf_locks_mt_posix_lock_t); + + if (ctx == NULL) + goto out; + + ctx->ltable = pl_lock_table_new(); + + if (ctx->ltable == NULL) { + GF_FREE (ctx); + ctx = NULL; + goto out; + } + + LOCK_INIT (&ctx->ltable_lock); + + if (client_ctx_set (client, xlator, ctx) != 0) { + LOCK_DESTROY (&ctx->ltable_lock); + GF_FREE (ctx->ltable); + GF_FREE (ctx); + ctx = NULL; + } +out: + return ctx; +} + +static void +ltable_delete_locks (struct _lock_table *ltable) +{ + struct _locker *locker = NULL; + struct _locker *tmp = NULL; + + list_for_each_entry_safe (locker, tmp, <able->inodelk_lockers, lockers) { + if (locker->fd) + pl_del_locker (ltable, locker->volume, &locker->loc, + locker->fd, &locker->owner, + GF_FOP_INODELK); + GF_FREE (locker->volume); + GF_FREE (locker); + } + + list_for_each_entry_safe (locker, tmp, <able->entrylk_lockers, lockers) { + if (locker->fd) + pl_del_locker (ltable, locker->volume, &locker->loc, + locker->fd, &locker->owner, + GF_FOP_ENTRYLK); + GF_FREE (locker->volume); + GF_FREE (locker); + } + GF_FREE (ltable); +} + + +static int32_t +destroy_cbk (xlator_t *this, client_t *client) +{ + void *tmp = NULL; + pl_ctx_t *locks_ctx = NULL; + + client_ctx_del (client, this, &tmp); + + if (tmp == NULL) + return 0 +; + locks_ctx = tmp; + if (locks_ctx->ltable) + ltable_delete_locks (locks_ctx->ltable); + + LOCK_DESTROY (&locks_ctx->ltable_lock); + GF_FREE (locks_ctx); + + return 0; +} + + +static int32_t +disconnect_cbk (xlator_t *this, client_t *client) +{ + int32_t ret = 0; + pl_ctx_t *locks_ctx = NULL; + struct _lock_table *ltable = NULL; + + locks_ctx = pl_ctx_get (client, this); + if (locks_ctx == NULL) { + gf_log (this->name, GF_LOG_INFO, "pl_ctx_get() failed"); + goto out; + } + + LOCK (&locks_ctx->ltable_lock); + { + if (locks_ctx->ltable) { + ltable = locks_ctx->ltable; + locks_ctx->ltable = pl_lock_table_new (); + } + } + UNLOCK (&locks_ctx->ltable_lock); + + if (ltable) + ltable_delete_locks (ltable); + +out: + return ret; +} + + int init (xlator_t *this) { @@ -2538,7 +2651,7 @@ init (xlator_t *this) gf_log (this->name, GF_LOG_CRITICAL, "'locks' translator is not loaded over a storage " "translator"); - goto out;; + goto out; } priv = GF_CALLOC (1, sizeof (*priv), @@ -2640,9 +2753,11 @@ struct xlator_dumpops dumpops = { }; struct xlator_cbks cbks = { - .forget = pl_forget, - .release = pl_release, - .releasedir = pl_releasedir, + .forget = pl_forget, + .release = pl_release, + .releasedir = pl_releasedir, + .client_destroy = destroy_cbk, + .client_disconnect = disconnect_cbk, }; diff --git a/xlators/protocol/server/src/Makefile.am b/xlators/protocol/server/src/Makefile.am index 25d6706cc82..6a18bf02561 100644 --- a/xlators/protocol/server/src/Makefile.am +++ b/xlators/protocol/server/src/Makefile.am @@ -16,9 +16,9 @@ AM_CPPFLAGS = $(GF_CPPFLAGS) \ -I$(top_srcdir)/libglusterfs/src \ -DCONFDIR=\"$(sysconfdir)/glusterfs\" \ -DLIBDIR=\"$(libdir)/glusterfs/$(PACKAGE_VERSION)/auth\" \ - -I$(top_srcdir)/xlators/protocol/lib/src \ - -I$(top_srcdir)/rpc/rpc-lib/src/ \ - -I$(top_srcdir)/rpc/xdr/src/ + -I$(top_srcdir)/xlators/protocol/lib/src \ + -I$(top_srcdir)/rpc/rpc-lib/src \ + -I$(top_srcdir)/rpc/xdr/src AM_CFLAGS = -Wall $(GF_CFLAGS) \ -DDATADIR=\"$(localstatedir)\" diff --git a/xlators/protocol/server/src/server-handshake.c b/xlators/protocol/server/src/server-handshake.c index b2d50e106b6..d4941011da9 100644 --- a/xlators/protocol/server/src/server-handshake.c +++ b/xlators/protocol/server/src/server-handshake.c @@ -20,7 +20,6 @@ #include "compat-errno.h" #include "glusterfs3.h" #include "authenticate.h" -#include "client_t.h" struct __get_xl_struct { const char *name; @@ -331,6 +330,7 @@ server_setvolume (rpcsvc_request_t *req) gf_setvolume_req args = {{0,},}; gf_setvolume_rsp rsp = {0,}; client_t *client = NULL; + server_ctx_t *serv_ctx = NULL; server_conf_t *conf = NULL; peer_info_t *peerinfo = NULL; dict_t *reply = NULL; @@ -428,13 +428,19 @@ server_setvolume (rpcsvc_request_t *req) goto fail; } - gf_log (this->name, GF_LOG_DEBUG, "Connected to %s", - client->server_ctx.client_uid); + gf_log (this->name, GF_LOG_DEBUG, "Connected to %s", client->client_uid); cancelled = server_cancel_grace_timer (this, client); if (cancelled)//Do gf_client_put on behalf of grace-timer-handler. gf_client_put (client, NULL); - if (client->server_ctx.lk_version != 0 && - client->server_ctx.lk_version != lk_version) { + + serv_ctx = server_ctx_get (client, client->this); + if (serv_ctx == NULL) { + gf_log (this->name, GF_LOG_INFO, "server_ctx_get() failed"); + goto fail; + } + + if (serv_ctx->lk_version != 0 && + serv_ctx->lk_version != lk_version) { (void) server_connection_cleanup (this, client, INTERNAL_LOCKS | POSIX_LOCKS); } @@ -565,7 +571,7 @@ server_setvolume (rpcsvc_request_t *req) gf_log (this->name, GF_LOG_INFO, "accepted client from %s (version: %s)", - client->server_ctx.client_uid, + client->client_uid, (clnt_version) ? clnt_version : "old"); op_ret = 0; client->bound_xl = xl; @@ -576,7 +582,7 @@ server_setvolume (rpcsvc_request_t *req) } else { gf_log (this->name, GF_LOG_ERROR, "Cannot authenticate client from %s %s", - client->server_ctx.client_uid, + client->client_uid, (clnt_version) ? clnt_version : "old"); op_ret = -1; @@ -624,8 +630,7 @@ server_setvolume (rpcsvc_request_t *req) gf_log (this->name, GF_LOG_DEBUG, "failed to set 'process-uuid'"); - ret = dict_set_uint32 (reply, "clnt-lk-version", - client->server_ctx.lk_version); + ret = dict_set_uint32 (reply, "clnt-lk-version", serv_ctx->lk_version); if (ret) gf_log (this->name, GF_LOG_WARNING, "failed to set 'clnt-lk-version'"); @@ -717,6 +722,7 @@ server_set_lk_version (rpcsvc_request_t *req) gf_set_lk_ver_req args = {0,}; gf_set_lk_ver_rsp rsp = {0,}; client_t *client = NULL; + server_ctx_t *serv_ctx = NULL; xlator_t *this = NULL; this = req->svc->mydata; @@ -734,7 +740,13 @@ server_set_lk_version (rpcsvc_request_t *req) } client = gf_client_get (this, &req->cred, args.uid); - client->server_ctx.lk_version = args.lk_ver; + serv_ctx = server_ctx_get (client, client->this); + if (serv_ctx == NULL) { + gf_log (this->name, GF_LOG_INFO, "server_ctx_get() failed"); + goto fail; + } + + serv_ctx->lk_version = args.lk_ver; gf_client_put (client, NULL); rsp.lk_ver = args.lk_ver; diff --git a/xlators/protocol/server/src/server-helpers.c b/xlators/protocol/server/src/server-helpers.c index 14d07412497..b2b6c486fe1 100644 --- a/xlators/protocol/server/src/server-helpers.c +++ b/xlators/protocol/server/src/server-helpers.c @@ -15,8 +15,6 @@ #include "server.h" #include "server-helpers.h" -#include "client_t.h" -#include "lock-table.h" #include <fnmatch.h> @@ -76,11 +74,6 @@ server_resolve_wipe (server_resolve_t *resolve) void free_state (server_state_t *state) { - if (state->client) { - /* should we gf_client_unref(state->client) here? */ - state->client = NULL; - } - if (state->xprt) { rpc_transport_unref (state->xprt); state->xprt = NULL; @@ -130,171 +123,6 @@ free_state (server_state_t *state) static int -server_nop_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, dict_t *xdata) -{ - int ret = -1; - server_state_t *state = NULL; - - GF_VALIDATE_OR_GOTO ("server", frame, out); - GF_VALIDATE_OR_GOTO ("server", cookie, out); - GF_VALIDATE_OR_GOTO ("server", this, out); - - state = CALL_STATE(frame); - - if (state) { - gf_client_unref (state->client); - free_state (state); - } - - STACK_DESTROY (frame->root); - - ret = 0; -out: - return ret; -} - - -static int -do_lock_table_cleanup (xlator_t *this, client_t *client, struct _lock_table *ltable) -{ - call_frame_t *tmp_frame = NULL; - xlator_t *bound_xl = NULL; - struct _locker *locker = NULL, *tmp = NULL; - char *path = NULL; - int ret = -1; - struct gf_flock flock = {0, }; - struct list_head inodelk_lockers, entrylk_lockers; - - GF_VALIDATE_OR_GOTO ("server", this, out); - GF_VALIDATE_OR_GOTO ("server", ltable, out); - - bound_xl = client->bound_xl; - INIT_LIST_HEAD (&inodelk_lockers); - INIT_LIST_HEAD (&entrylk_lockers); - - list_splice_init (<able->inodelk_lockers, - &inodelk_lockers); - - list_splice_init (<able->entrylk_lockers, &entrylk_lockers); - GF_FREE (ltable); - - flock.l_type = F_UNLCK; - flock.l_start = 0; - flock.l_len = 0; - list_for_each_entry_safe (locker, tmp, &inodelk_lockers, lockers) { - tmp_frame = create_frame (this, this->ctx->pool); - if (tmp_frame == NULL) { - goto out; - } - /* - lock owner = 0 is a special case that tells posix-locks - to release all locks from this transport - */ - tmp_frame->root->pid = 0; - gf_client_ref (client); - tmp_frame->root->trans = client; - - memset (&tmp_frame->root->lk_owner, 0, sizeof (gf_lkowner_t)); - - if (locker->fd) { - GF_ASSERT (locker->fd->inode); - - ret = inode_path (locker->fd->inode, NULL, &path); - - if (ret > 0) { - gf_log (this->name, GF_LOG_INFO, - "finodelk released on %s", path); - GF_FREE (path); - } else { - - gf_log (this->name, GF_LOG_INFO, - "finodelk released on inode with gfid %s", - uuid_utoa (locker->fd->inode->gfid)); - } - - STACK_WIND (tmp_frame, server_nop_cbk, bound_xl, - bound_xl->fops->finodelk, - locker->volume, - locker->fd, F_SETLK, &flock, NULL); - fd_unref (locker->fd); - } else { - gf_log (this->name, GF_LOG_INFO, - "inodelk released on %s", locker->loc.path); - - STACK_WIND (tmp_frame, server_nop_cbk, bound_xl, - bound_xl->fops->inodelk, - locker->volume, - &(locker->loc), F_SETLK, &flock, NULL); - loc_wipe (&locker->loc); - } - - GF_FREE (locker->volume); - - list_del_init (&locker->lockers); - GF_FREE (locker); - } - - tmp = NULL; - locker = NULL; - list_for_each_entry_safe (locker, tmp, &entrylk_lockers, lockers) { - tmp_frame = create_frame (this, this->ctx->pool); - if (tmp_frame == NULL) { - goto out; - } - - tmp_frame->root->pid = 0; - gf_client_ref (client); - tmp_frame->root->trans = client; - memset (&tmp_frame->root->lk_owner, 0, sizeof (gf_lkowner_t)); - - if (locker->fd) { - GF_ASSERT (locker->fd->inode); - - ret = inode_path (locker->fd->inode, NULL, &path); - - if (ret > 0) { - gf_log (this->name, GF_LOG_INFO, - "fentrylk released on %s", path); - GF_FREE (path); - } else { - - gf_log (this->name, GF_LOG_INFO, - "fentrylk released on inode with gfid %s", - uuid_utoa (locker->fd->inode->gfid)); - } - - STACK_WIND (tmp_frame, server_nop_cbk, bound_xl, - bound_xl->fops->fentrylk, - locker->volume, - locker->fd, NULL, - ENTRYLK_UNLOCK, ENTRYLK_WRLCK, NULL); - fd_unref (locker->fd); - } else { - gf_log (this->name, GF_LOG_INFO, - "entrylk released on %s", locker->loc.path); - - STACK_WIND (tmp_frame, server_nop_cbk, bound_xl, - bound_xl->fops->entrylk, - locker->volume, - &(locker->loc), NULL, - ENTRYLK_UNLOCK, ENTRYLK_WRLCK, NULL); - loc_wipe (&locker->loc); - } - - GF_FREE (locker->volume); - - list_del_init (&locker->lockers); - GF_FREE (locker); - } - ret = 0; - -out: - return ret; -} - - -static int server_connection_cleanup_flush_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, dict_t *xdata) @@ -308,7 +136,7 @@ server_connection_cleanup_flush_cbk (call_frame_t *frame, void *cookie, GF_VALIDATE_OR_GOTO ("server", frame, out); fd = frame->local; - client = frame->root->trans; + client = frame->root->client; fd_unref (fd); frame->local = NULL; @@ -363,7 +191,6 @@ do_fd_cleanup (xlator_t *this, client_t* client, fdentry_t *fdentries, int fd_co tmp_frame->root->pid = 0; gf_client_ref (client); - tmp_frame->root->trans = client; memset (&tmp_frame->root->lk_owner, 0, sizeof (gf_lkowner_t)); @@ -381,66 +208,49 @@ out: } -static int -do_connection_cleanup (xlator_t *this, client_t *client, - struct _lock_table *ltable, - fdentry_t *fdentries, int fd_count) -{ - int ret = 0; - int saved_ret = 0; - - GF_VALIDATE_OR_GOTO ("server", this, out); - - if (!ltable && !fdentries) - goto out; - - if (ltable) - saved_ret = do_lock_table_cleanup (this, client, ltable); - - if (fdentries != NULL) - ret = do_fd_cleanup (this, client, fdentries, fd_count); - - if (saved_ret || ret) { - ret = -1; - } - -out: - return ret; -} - int server_connection_cleanup (xlator_t *this, client_t *client, int32_t flags) { - struct _lock_table *ltable = NULL; + server_ctx_t *serv_ctx = NULL; fdentry_t *fdentries = NULL; uint32_t fd_count = 0; + int cd_ret = 0; int ret = 0; GF_VALIDATE_OR_GOTO (this->name, this, out); GF_VALIDATE_OR_GOTO (this->name, client, out); GF_VALIDATE_OR_GOTO (this->name, flags, out); - LOCK (&client->locks_ctx.ltable_lock); - { - if (client->locks_ctx.ltable && (flags & INTERNAL_LOCKS)) { - ltable = client->locks_ctx.ltable; - client->locks_ctx.ltable = gf_lock_table_new (); - } + serv_ctx = server_ctx_get (client, client->this); + + if (serv_ctx == NULL) { + gf_log (this->name, GF_LOG_INFO, "server_ctx_get() failed"); + goto out; } - UNLOCK (&client->locks_ctx.ltable_lock); - LOCK (&client->server_ctx.fdtable_lock); + LOCK (&serv_ctx->fdtable_lock); { - if (client->server_ctx.fdtable && (flags & POSIX_LOCKS)) - fdentries = gf_fd_fdtable_get_all_fds (client->server_ctx.fdtable, + if (serv_ctx->fdtable && (flags & POSIX_LOCKS)) + fdentries = gf_fd_fdtable_get_all_fds (serv_ctx->fdtable, &fd_count); } - UNLOCK (&client->server_ctx.fdtable_lock); + UNLOCK (&serv_ctx->fdtable_lock); - if (client->bound_xl) - ret = do_connection_cleanup (this, client, ltable, fdentries, - fd_count); + if (client->bound_xl == NULL) + goto out; + + if (flags & INTERNAL_LOCKS) { + cd_ret = gf_client_disconnect (client); + } + + if (fdentries != NULL) + ret = do_fd_cleanup (this, client, fdentries, fd_count); + else + gf_log (this->name, GF_LOG_INFO, "no fdentries to clean"); + + if (cd_ret || ret) + ret = -1; out: return ret; @@ -474,11 +284,10 @@ server_alloc_frame (rpcsvc_request_t *req) state->itable = client->bound_xl->itable; state->xprt = rpc_transport_ref (req->trans); - state->client = client; - state->resolve.fd_no = -1; state->resolve2.fd_no = -1; + frame->root->client = client; frame->root->state = state; /* which socket */ frame->root->unique = 0; /* which call */ @@ -510,7 +319,7 @@ get_frame_from_request (rpcsvc_request_t *req) frame->root->gid = req->gid; frame->root->pid = req->pid; gf_client_ref (client); - frame->root->trans = client; + frame->root->client = client; frame->root->lk_owner = req->lk_owner; server_decode_groups (frame, req); @@ -721,8 +530,10 @@ server_print_params (char *str, int size, server_state_t *state) filled += snprintf (str + filled, size - filled, "volume=%s,", state->volume); +/* FIXME snprintf (str + filled, size - filled, "bound_xl=%s}", state->client->bound_xl->name); +*/ out: return; } @@ -1052,6 +863,7 @@ gf_server_check_setxattr_cmd (call_frame_t *frame, dict_t *dict) gf_boolean_t server_cancel_grace_timer (xlator_t *this, client_t *client) { + server_ctx_t *serv_ctx = NULL; gf_timer_t *timer = NULL; gf_boolean_t cancelled = _gf_false; @@ -1061,18 +873,65 @@ server_cancel_grace_timer (xlator_t *this, client_t *client) return cancelled; } - LOCK (&client->server_ctx.fdtable_lock); + serv_ctx = server_ctx_get (client, client->this); + + if (serv_ctx == NULL) { + gf_log (this->name, GF_LOG_INFO, "server_ctx_get() failed"); + goto out; + } + + LOCK (&serv_ctx->fdtable_lock); { - if (client->server_ctx.grace_timer) { - timer = client->server_ctx.grace_timer; - client->server_ctx.grace_timer = NULL; + if (serv_ctx->grace_timer) { + timer = serv_ctx->grace_timer; + serv_ctx->grace_timer = NULL; } } - UNLOCK (&client->server_ctx.fdtable_lock); + UNLOCK (&serv_ctx->fdtable_lock); if (timer) { gf_timer_call_cancel (this->ctx, timer); cancelled = _gf_true; } +out: return cancelled; } + +server_ctx_t* +server_ctx_get (client_t *client, xlator_t *xlator) +{ + void *tmp = NULL; + server_ctx_t *ctx = NULL; + + client_ctx_get (client, xlator, &tmp); + + ctx = tmp; + + if (ctx != NULL) + goto out; + + ctx = GF_CALLOC (1, sizeof (server_ctx_t), gf_server_mt_server_conf_t); + + if (ctx == NULL) + goto out; + + /* ctx->lk_version = 0; redundant */ + ctx->fdtable = gf_fd_fdtable_alloc (); + + if (ctx->fdtable == NULL) { + GF_FREE (ctx); + ctx = NULL; + goto out; + } + + LOCK_INIT (&ctx->fdtable_lock); + + if (client_ctx_set (client, xlator, ctx) != 0) { + LOCK_DESTROY (&ctx->fdtable_lock); + GF_FREE (ctx); + ctx = NULL; + } + +out: + return ctx; +} diff --git a/xlators/protocol/server/src/server-helpers.h b/xlators/protocol/server/src/server-helpers.h index 987528fbdf4..93ea3585102 100644 --- a/xlators/protocol/server/src/server-helpers.h +++ b/xlators/protocol/server/src/server-helpers.h @@ -15,8 +15,6 @@ #define CALL_STATE(frame) ((server_state_t *)frame->root->state) -#define BOUND_XL(frame) ((xlator_t *) CALL_STATE(frame)->client->bound_xl) - #define XPRT_FROM_FRAME(frame) ((rpc_transport_t *) CALL_STATE(frame)->xprt) #define SERVER_CONF(frame) \ @@ -56,4 +54,6 @@ int serialize_rsp_direntp (gf_dirent_t *entries, gfs3_readdirp_rsp *rsp); int readdirp_rsp_cleanup (gfs3_readdirp_rsp *rsp); int readdir_rsp_cleanup (gfs3_readdir_rsp *rsp); +server_ctx_t *server_ctx_get (client_t *client, xlator_t *xlator); + #endif /* !_SERVER_HELPERS_H */ diff --git a/xlators/protocol/server/src/server-resolve.c b/xlators/protocol/server/src/server-resolve.c index 0c2644fc8b4..cc4686a0399 100644 --- a/xlators/protocol/server/src/server-resolve.c +++ b/xlators/protocol/server/src/server-resolve.c @@ -15,7 +15,6 @@ #include "server.h" #include "server-helpers.h" -#include "client_t.h" int @@ -148,7 +147,8 @@ resolve_gfid_cbk (call_frame_t *frame, void *cookie, xlator_t *this, (char **) &resolve_loc->path); STACK_WIND (frame, resolve_gfid_entry_cbk, - BOUND_XL (frame), BOUND_XL (frame)->fops->lookup, + frame->root->client->bound_xl, + frame->root->client->bound_xl->fops->lookup, &resolve->resolve_loc, NULL); return 0; out: @@ -180,7 +180,8 @@ resolve_gfid (call_frame_t *frame) ret = loc_path (resolve_loc, NULL); STACK_WIND (frame, resolve_gfid_cbk, - BOUND_XL (frame), BOUND_XL (frame)->fops->lookup, + frame->root->client->bound_xl, + frame->root->client->bound_xl->fops->lookup, &resolve->resolve_loc, NULL); return 0; } @@ -450,9 +451,11 @@ server_resolve_anonfd (call_frame_t *frame) int server_resolve_fd (call_frame_t *frame) { - server_state_t *state = NULL; - server_resolve_t *resolve = NULL; - uint64_t fd_no = -1; + server_ctx_t *serv_ctx = NULL; + server_state_t *state = NULL; + client_t *client = NULL; + server_resolve_t *resolve = NULL; + uint64_t fd_no = -1; state = CALL_STATE (frame); resolve = state->resolve_now; @@ -464,7 +467,18 @@ server_resolve_fd (call_frame_t *frame) return 0; } - state->fd = gf_fd_fdptr_get (state->client->server_ctx.fdtable, fd_no); + client = frame->root->client; + + serv_ctx = server_ctx_get (client, client->this); + + if (serv_ctx == NULL) { + gf_log ("", GF_LOG_INFO, "server_ctx_get() failed"); + resolve->op_ret = -1; + resolve->op_errno = ENOMEM; + return 0; + } + + state->fd = gf_fd_fdptr_get (serv_ctx->fdtable, fd_no); if (!state->fd) { gf_log ("", GF_LOG_INFO, "fd not found in context"); @@ -519,14 +533,12 @@ int server_resolve_done (call_frame_t *frame) { server_state_t *state = NULL; - xlator_t *bound_xl = NULL; state = CALL_STATE (frame); - bound_xl = BOUND_XL (frame); server_print_request (frame); - state->resume_fn (frame, bound_xl); + state->resume_fn (frame, frame->root->client->bound_xl); return 0; } diff --git a/xlators/protocol/server/src/server-rpc-fops.c b/xlators/protocol/server/src/server-rpc-fops.c index a7995b4c3d4..59e808b2f14 100644 --- a/xlators/protocol/server/src/server-rpc-fops.c +++ b/xlators/protocol/server/src/server-rpc-fops.c @@ -20,8 +20,6 @@ #include "server-helpers.h" #include "glusterfs3-xdr.h" #include "glusterfs3.h" -#include "client_t.h" -#include "lock-table.h" #include "compat-errno.h" #include "xdr-nfs3.h" @@ -41,9 +39,7 @@ server_statfs_cbk (call_frame_t *frame, void *cookie, xlator_t *this, gfs3_statfs_rsp rsp = {0,}; rpcsvc_request_t *req = NULL; - req = frame->local; - - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); if (op_ret < 0) { @@ -58,7 +54,7 @@ out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); - + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_statfs_rsp); @@ -81,8 +77,7 @@ server_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, gfs3_lookup_rsp rsp = {0,}; uuid_t rootgfid = {0,}; - req = frame->local; - state = CALL_STATE(frame); + state = CALL_STATE (frame); if (state->is_revalidate == 1 && op_ret == -1) { state->is_revalidate = 2; @@ -90,8 +85,9 @@ server_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, inode_unref (fresh_loc.inode); fresh_loc.inode = inode_new (state->itable); - STACK_WIND (frame, server_lookup_cbk, BOUND_XL (frame), - BOUND_XL (frame)->fops->lookup, + STACK_WIND (frame, server_lookup_cbk, + frame->root->client->bound_xl, + frame->root->client->bound_xl->fops->lookup, &fresh_loc, state->xdata); loc_wipe (&fresh_loc); @@ -100,7 +96,7 @@ server_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, gf_stat_from_iatt (&rsp.postparent, postparent); - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); if (op_ret) { @@ -114,7 +110,7 @@ server_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, goto out; } - root_inode = BOUND_XL(frame)->itable->root; + root_inode = frame->root->client->bound_xl->itable->root; if (inode == root_inode) { /* we just looked up root ("/") */ stbuf->ia_ino = 1; @@ -159,6 +155,7 @@ out: } } + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_lookup_rsp); @@ -177,14 +174,12 @@ server_lk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, rpcsvc_request_t *req = NULL; server_state_t *state = NULL; - req = frame->local; - state = CALL_STATE(frame); - - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); if (op_ret) { if ((op_errno != ENOSYS) && (op_errno != EAGAIN)) { + state = CALL_STATE (frame); gf_log (this->name, GF_LOG_INFO, "%"PRId64": LK %"PRId64" (%s) ==> " "(%s)", frame->root->unique, @@ -217,6 +212,7 @@ out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_lk_rsp); @@ -230,15 +226,15 @@ int server_inodelk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, dict_t *xdata) { - gf_common_rsp rsp = {0,}; - server_state_t *state = NULL; - rpcsvc_request_t *req = NULL; - req = frame->local; - state = CALL_STATE(frame); + gf_common_rsp rsp = {0,}; + server_state_t *state = NULL; + rpcsvc_request_t *req = NULL; - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); + state = CALL_STATE (frame); + if (op_ret < 0) { if ((op_errno != ENOSYS) && (op_errno != EAGAIN)) { gf_log (this->name, GF_LOG_INFO, @@ -250,21 +246,11 @@ server_inodelk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, goto out; } - if (state->flock.l_type == F_UNLCK) - gf_del_locker (state->client->locks_ctx.ltable, - state->volume, &state->loc, NULL, - &frame->root->lk_owner, - GF_FOP_INODELK); - else - gf_add_locker (state->client->locks_ctx.ltable, - state->volume, &state->loc, NULL, - frame->root->pid, &frame->root->lk_owner, - GF_FOP_INODELK); - out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gf_common_rsp); @@ -278,16 +264,15 @@ int server_finodelk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, dict_t *xdata) { - gf_common_rsp rsp = {0,}; - server_state_t *state = NULL; - rpcsvc_request_t *req = NULL; - - req = frame->local; - state = CALL_STATE(frame); + gf_common_rsp rsp = {0,}; + server_state_t *state = NULL; + rpcsvc_request_t *req = NULL; - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); + state = CALL_STATE (frame); + if (op_ret < 0) { if ((op_errno != ENOSYS) && (op_errno != EAGAIN)) { gf_log (this->name, GF_LOG_INFO, @@ -300,21 +285,11 @@ server_finodelk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, goto out; } - if (state->flock.l_type == F_UNLCK) - gf_del_locker (state->client->locks_ctx.ltable, - state->volume, NULL, state->fd, - &frame->root->lk_owner, - GF_FOP_INODELK); - else - gf_add_locker (state->client->locks_ctx.ltable, - state->volume, NULL, state->fd, - frame->root->pid, &frame->root->lk_owner, - GF_FOP_INODELK); - out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gf_common_rsp); @@ -327,16 +302,15 @@ int server_entrylk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, dict_t *xdata) { - server_state_t *state = NULL; - rpcsvc_request_t *req = NULL; - gf_common_rsp rsp = {0,}; + gf_common_rsp rsp = {0,}; + server_state_t *state = NULL; + rpcsvc_request_t *req = NULL; - req = frame->local; - state = CALL_STATE(frame); - - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); + state = CALL_STATE (frame); + if (op_ret < 0) { if ((op_errno != ENOSYS) && (op_errno != EAGAIN)) { gf_log (this->name, GF_LOG_INFO, @@ -348,21 +322,11 @@ server_entrylk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, goto out; } - if (state->cmd == ENTRYLK_UNLOCK) - gf_del_locker (state->client->locks_ctx.ltable, - state->volume, &state->loc, NULL, - &frame->root->lk_owner, - GF_FOP_ENTRYLK); - else - gf_add_locker (state->client->locks_ctx.ltable, - state->volume, &state->loc, NULL, - frame->root->pid, &frame->root->lk_owner, - GF_FOP_ENTRYLK); - out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gf_common_rsp); @@ -376,16 +340,15 @@ int server_fentrylk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, dict_t *xdata) { - gf_common_rsp rsp = {0,}; - server_state_t *state = NULL; - rpcsvc_request_t *req = NULL; + gf_common_rsp rsp = {0,}; + server_state_t *state = NULL; + rpcsvc_request_t *req = NULL; - req = frame->local; - state = CALL_STATE(frame); - - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); + state = CALL_STATE (frame); + if (op_ret < 0) { if ((op_errno != ENOSYS) && (op_errno != EAGAIN)) { gf_log (this->name, GF_LOG_INFO, @@ -397,21 +360,11 @@ server_fentrylk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, goto out; } - if (state->cmd == ENTRYLK_UNLOCK) - gf_del_locker (state->client->locks_ctx.ltable, - state->volume, NULL, state->fd, - &frame->root->lk_owner, - GF_FOP_ENTRYLK); - else - gf_add_locker (state->client->locks_ctx.ltable, - state->volume, NULL, state->fd, - frame->root->pid, &frame->root->lk_owner, - GF_FOP_ENTRYLK); - out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gf_common_rsp); @@ -429,13 +382,11 @@ server_access_cbk (call_frame_t *frame, void *cookie, xlator_t *this, rpcsvc_request_t *req = NULL; server_state_t *state = NULL; - req = frame->local; - state = CALL_STATE(frame); - - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); if (op_ret) { + state = CALL_STATE (frame); gf_log (this->name, GF_LOG_INFO, "%"PRId64": ACCESS %s (%s) ==> (%s)", frame->root->unique, state->loc.path, @@ -448,6 +399,7 @@ out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gf_common_rsp); @@ -466,12 +418,11 @@ server_rmdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, inode_t *parent = NULL; rpcsvc_request_t *req = NULL; - req = frame->local; - state = CALL_STATE(frame); - - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); + state = CALL_STATE (frame); + if (op_ret) { gf_log (this->name, GF_LOG_INFO, "%"PRId64": RMDIR %s (%s/%s) ==> (%s)", @@ -500,6 +451,7 @@ out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_rmdir_rsp); @@ -519,12 +471,11 @@ server_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, inode_t *link_inode = NULL; rpcsvc_request_t *req = NULL; - req = frame->local; - state = CALL_STATE(frame); - - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); + state = CALL_STATE (frame); + if (op_ret < 0) { gf_log (this->name, GF_LOG_INFO, "%"PRId64": MKDIR %s (%s/%s) ==> (%s)", @@ -547,6 +498,7 @@ out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_mkdir_rsp); @@ -566,12 +518,11 @@ server_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this, inode_t *link_inode = NULL; rpcsvc_request_t *req = NULL; - req = frame->local; - state = CALL_STATE(frame); - - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); + state = CALL_STATE (frame); + if (op_ret < 0) { gf_log (this->name, GF_LOG_INFO, "%"PRId64": MKNOD %s (%s/%s) ==> (%s)", @@ -594,6 +545,7 @@ out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_mknod_rsp); @@ -610,13 +562,11 @@ server_fsyncdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, server_state_t *state = NULL; rpcsvc_request_t *req = NULL; - req = frame->local; - state = CALL_STATE(frame); - - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); if (op_ret < 0) { + state = CALL_STATE (frame); gf_log (this->name, GF_LOG_INFO, "%"PRId64": FSYNCDIR %"PRId64" (%s) ==> (%s)", frame->root->unique, state->resolve.fd_no, @@ -629,6 +579,7 @@ out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gf_common_rsp); @@ -647,13 +598,11 @@ server_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, rpcsvc_request_t *req = NULL; int ret = 0; - req = frame->local; - state = CALL_STATE(frame); - - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); if (op_ret < 0) { + state = CALL_STATE (frame); gf_log (this->name, GF_LOG_INFO, "%"PRId64": READDIR %"PRId64" (%s) ==> (%s)", frame->root->unique, state->resolve.fd_no, @@ -676,6 +625,7 @@ out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_readdir_rsp); @@ -690,18 +640,17 @@ int server_opendir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, fd_t *fd, dict_t *xdata) { - server_state_t *state = NULL; - rpcsvc_request_t *req = NULL; - gfs3_opendir_rsp rsp = {0,}; - uint64_t fd_no = 0; - - req = frame->local; - state = CALL_STATE (frame); + server_state_t *state = NULL; + server_ctx_t *serv_ctx = NULL; + rpcsvc_request_t *req = NULL; + gfs3_opendir_rsp rsp = {0,}; + uint64_t fd_no = 0; - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); if (op_ret < 0) { + state = CALL_STATE (frame); gf_log (this->name, GF_LOG_INFO, "%"PRId64": OPENDIR %s (%s) ==> (%s)", frame->root->unique, state->loc.path, @@ -709,8 +658,14 @@ server_opendir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, goto out; } + serv_ctx = server_ctx_get (frame->root->client, this); + if (serv_ctx == NULL) { + gf_log (this->name, GF_LOG_INFO, "server_ctx_get() failed"); + goto out; + } + fd_bind (fd); - fd_no = gf_fd_unused_get (state->client->server_ctx.fdtable, fd); + fd_no = gf_fd_unused_get (serv_ctx->fdtable, fd); fd_ref (fd); // on behalf of the client out: @@ -718,6 +673,7 @@ out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_opendir_rsp); @@ -734,13 +690,11 @@ server_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, rpcsvc_request_t *req = NULL; server_state_t *state = NULL; - req = frame->local; - state = CALL_STATE(frame); - - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); if (op_ret == -1) { + state = CALL_STATE (frame); gf_log (this->name, GF_LOG_INFO, "%"PRId64": REMOVEXATTR %s (%s) of key %s ==> (%s)", frame->root->unique, state->loc.path, @@ -753,6 +707,7 @@ out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gf_common_rsp); @@ -769,13 +724,11 @@ server_fremovexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, rpcsvc_request_t *req = NULL; server_state_t *state = NULL; - req = frame->local; - state = CALL_STATE(frame); - - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); if (op_ret == -1) { + state = CALL_STATE (frame); gf_log (this->name, GF_LOG_INFO, "%"PRId64": FREMOVEXATTR %"PRId64" (%s) (%s) ==> (%s)", frame->root->unique, state->resolve.fd_no, @@ -788,6 +741,7 @@ out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gf_common_rsp); @@ -805,13 +759,11 @@ server_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, rpcsvc_request_t *req = NULL; server_state_t *state = NULL; - req = frame->local; - state = CALL_STATE (frame); - - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); if (op_ret == -1) { + state = CALL_STATE (frame); gf_log (this->name, (((op_errno == ENOTSUP) || (op_errno == ENODATA) || (op_errno == ENOENT)) ? @@ -823,13 +775,14 @@ server_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, goto out; } - GF_PROTOCOL_DICT_SERIALIZE (this, dict, (&rsp.dict.dict_val), + GF_PROTOCOL_DICT_SERIALIZE (this, dict, &rsp.dict.dict_val, rsp.dict.dict_len, op_errno, out); out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_getxattr_rsp); @@ -850,13 +803,11 @@ server_fgetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, server_state_t *state = NULL; rpcsvc_request_t *req = NULL; - req = frame->local; - state = CALL_STATE (frame); - - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); if (op_ret == -1) { + state = CALL_STATE (frame); gf_log (this->name, ((op_errno == ENOTSUP) ? GF_LOG_DEBUG : GF_LOG_INFO), "%"PRId64": FGETXATTR %"PRId64" (%s) (%s) ==> (%s)", @@ -866,7 +817,7 @@ server_fgetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, goto out; } - GF_PROTOCOL_DICT_SERIALIZE (this, dict, (&rsp.dict.dict_val), + GF_PROTOCOL_DICT_SERIALIZE (this, dict, &rsp.dict.dict_val, rsp.dict.dict_len, op_errno, out); out: @@ -874,6 +825,7 @@ out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_fgetxattr_rsp); @@ -893,7 +845,7 @@ _gf_server_log_setxattr_failure (dict_t *d, char *k, data_t *v, call_frame_t *frame = NULL; frame = tmp; - state = CALL_STATE(frame); + state = CALL_STATE (frame); gf_log (THIS->name, GF_LOG_INFO, "%"PRId64": SETXATTR %s (%s) ==> %s", @@ -910,13 +862,11 @@ server_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, rpcsvc_request_t *req = NULL; server_state_t *state = NULL; - req = frame->local; - state = CALL_STATE(frame); - - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); if (op_ret == -1) { + state = CALL_STATE (frame); if (op_errno != ENOTSUP) dict_foreach (state->dict, _gf_server_log_setxattr_failure, @@ -932,6 +882,7 @@ out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gf_common_rsp); @@ -949,7 +900,7 @@ _gf_server_log_fsetxattr_failure (dict_t *d, char *k, data_t *v, server_state_t *state = NULL; frame = tmp; - state = CALL_STATE(frame); + state = CALL_STATE (frame); gf_log (THIS->name, GF_LOG_INFO, "%"PRId64": FSETXATTR %"PRId64" (%s) ==> %s", @@ -967,13 +918,11 @@ server_fsetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, rpcsvc_request_t *req = NULL; server_state_t *state = NULL; - req = frame->local; - state = CALL_STATE(frame); - - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); if (op_ret == -1) { + state = CALL_STATE (frame); if (op_errno != ENOTSUP) { dict_foreach (state->dict, _gf_server_log_fsetxattr_failure, @@ -989,6 +938,7 @@ out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gf_common_rsp); @@ -1012,12 +962,11 @@ server_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this, char oldpar_str[50] = {0,}; char newpar_str[50] = {0,}; - req = frame->local; - state = CALL_STATE(frame); - - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); + state = CALL_STATE (frame); + if (op_ret == -1) { uuid_utoa_r (state->resolve.gfid, oldpar_str); uuid_utoa_r (state->resolve2.gfid, newpar_str); @@ -1032,7 +981,7 @@ server_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this, stbuf->ia_type = state->loc.inode->ia_type; /* TODO: log gfid of the inodes */ - gf_log (state->client->bound_xl->name, GF_LOG_TRACE, + gf_log (frame->root->client->bound_xl->name, GF_LOG_TRACE, "%"PRId64": RENAME_CBK %s ==> %s", frame->root->unique, state->loc.name, state->loc2.name); @@ -1074,6 +1023,7 @@ out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_rename_rsp); @@ -1092,12 +1042,11 @@ server_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, inode_t *parent = NULL; rpcsvc_request_t *req = NULL; - req = frame->local; - state = CALL_STATE(frame); - - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); + state = CALL_STATE (frame); + if (op_ret) { gf_log (this->name, (op_errno == ENOENT)? GF_LOG_DEBUG:GF_LOG_ERROR, @@ -1109,7 +1058,7 @@ server_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, } /* TODO: log gfid of the inodes */ - gf_log (state->client->bound_xl->name, GF_LOG_TRACE, + gf_log (frame->root->client->bound_xl->name, GF_LOG_TRACE, "%"PRId64": UNLINK_CBK %s", frame->root->unique, state->loc.name); @@ -1129,6 +1078,7 @@ out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_unlink_rsp); @@ -1148,12 +1098,11 @@ server_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, inode_t *link_inode = NULL; rpcsvc_request_t *req = NULL; - req = frame->local; - state = CALL_STATE(frame); - - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); + state = CALL_STATE (frame); + if (op_ret < 0) { gf_log (this->name, GF_LOG_INFO, "%"PRId64": SYMLINK %s (%s/%s) ==> (%s)", @@ -1176,6 +1125,7 @@ out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_symlink_rsp); @@ -1198,12 +1148,11 @@ server_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this, char gfid_str[50] = {0,}; char newpar_str[50] = {0,}; - req = frame->local; - state = CALL_STATE(frame); - - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); + state = CALL_STATE (frame); + if (op_ret) { uuid_utoa_r (state->resolve.gfid, gfid_str); uuid_utoa_r (state->resolve2.pargfid, newpar_str); @@ -1228,6 +1177,7 @@ out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_link_rsp); @@ -1245,13 +1195,11 @@ server_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, server_state_t *state = NULL; rpcsvc_request_t *req = NULL; - req = frame->local; - state = CALL_STATE (frame); - - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); if (op_ret) { + state = CALL_STATE (frame); gf_log (this->name, GF_LOG_INFO, "%"PRId64": TRUNCATE %s (%s) ==> (%s)", frame->root->unique, state->loc.path, @@ -1266,6 +1214,7 @@ out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_truncate_rsp); @@ -1283,13 +1232,11 @@ server_fstat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, server_state_t *state = NULL; rpcsvc_request_t *req = NULL; - req = frame->local; - state = CALL_STATE(frame); - - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); if (op_ret) { + state = CALL_STATE (frame); gf_log (this->name, GF_LOG_INFO, "%"PRId64": FSTAT %"PRId64" (%s) ==> (%s)", frame->root->unique, state->resolve.fd_no, @@ -1303,6 +1250,7 @@ out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_fstat_rsp); @@ -1320,13 +1268,11 @@ server_ftruncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, server_state_t *state = NULL; rpcsvc_request_t *req = NULL; - req = frame->local; - state = CALL_STATE (frame); - - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); if (op_ret) { + state = CALL_STATE (frame); gf_log (this->name, GF_LOG_INFO, "%"PRId64": FTRUNCATE %"PRId64" (%s)==> (%s)", frame->root->unique, state->resolve.fd_no, @@ -1341,6 +1287,7 @@ out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_ftruncate_rsp); @@ -1357,13 +1304,11 @@ server_flush_cbk (call_frame_t *frame, void *cookie, xlator_t *this, server_state_t *state = NULL; rpcsvc_request_t *req = NULL; - req = frame->local; - state = CALL_STATE(frame); - - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); if (op_ret < 0) { + state = CALL_STATE (frame); gf_log (this->name, GF_LOG_INFO, "%"PRId64": FLUSH %"PRId64" (%s) ==> (%s)", frame->root->unique, state->resolve.fd_no, @@ -1375,6 +1320,7 @@ out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gf_common_rsp); @@ -1392,13 +1338,11 @@ server_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this, server_state_t *state = NULL; rpcsvc_request_t *req = NULL; - req = frame->local; - state = CALL_STATE(frame); - - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); if (op_ret < 0) { + state = CALL_STATE (frame); gf_log (this->name, GF_LOG_INFO, "%"PRId64": FSYNC %"PRId64" (%s) ==> (%s)", frame->root->unique, state->resolve.fd_no, @@ -1413,6 +1357,7 @@ out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_fsync_rsp); @@ -1430,13 +1375,11 @@ server_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, server_state_t *state = NULL; rpcsvc_request_t *req = NULL; - req = frame->local; - state = CALL_STATE(frame); - - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); if (op_ret < 0) { + state = CALL_STATE (frame); gf_log (this->name, GF_LOG_INFO, "%"PRId64": WRITEV %"PRId64" (%s) ==> (%s)", frame->root->unique, state->resolve.fd_no, @@ -1451,6 +1394,7 @@ out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_write_rsp); @@ -1470,9 +1414,6 @@ server_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this, server_state_t *state = NULL; rpcsvc_request_t *req = NULL; - req = frame->local; - state = CALL_STATE(frame); - #ifdef GF_TESTING_IO_XDATA { int ret = 0; @@ -1483,10 +1424,11 @@ server_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this, "testing-xdata-value"); } #endif - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); if (op_ret < 0) { + state = CALL_STATE (frame); gf_log (this->name, GF_LOG_INFO, "%"PRId64": READV %"PRId64" (%s) ==> (%s)", frame->root->unique, state->resolve.fd_no, @@ -1501,6 +1443,7 @@ out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply (frame, req, &rsp, vector, count, iobref, (xdrproc_t)xdr_gfs3_read_rsp); @@ -1519,13 +1462,11 @@ server_rchecksum_cbk (call_frame_t *frame, void *cookie, xlator_t *this, rpcsvc_request_t *req = NULL; server_state_t *state = NULL; - req = frame->local; - state = CALL_STATE(frame); - - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); if (op_ret < 0) { + state = CALL_STATE (frame); gf_log (this->name, GF_LOG_INFO, "%"PRId64": RCHECKSUM %"PRId64" (%s)==> (%s)", frame->root->unique, state->resolve.fd_no, @@ -1542,6 +1483,7 @@ out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_rchecksum_rsp); @@ -1555,18 +1497,17 @@ int server_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, fd_t *fd, dict_t *xdata) { - server_state_t *state = NULL; - rpcsvc_request_t *req = NULL; - uint64_t fd_no = 0; - gfs3_open_rsp rsp = {0,}; - - req = frame->local; - state = CALL_STATE (frame); + server_state_t *state = NULL; + server_ctx_t *serv_ctx = NULL; + rpcsvc_request_t *req = NULL; + uint64_t fd_no = 0; + gfs3_open_rsp rsp = {0,}; - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); if (op_ret < 0) { + state = CALL_STATE (frame); gf_log (this->name, GF_LOG_INFO, "%"PRId64": OPEN %s (%s) ==> (%s)", frame->root->unique, state->loc.path, @@ -1575,8 +1516,14 @@ server_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, goto out; } + serv_ctx = server_ctx_get (frame->root->client, this); + if (serv_ctx == NULL) { + gf_log (this->name, GF_LOG_INFO, "server_ctx_get() failed"); + goto out; + } + fd_bind (fd); - fd_no = gf_fd_unused_get (state->client->server_ctx.fdtable, fd); + fd_no = gf_fd_unused_get (serv_ctx->fdtable, fd); fd_ref (fd); rsp.fd = fd_no; @@ -1584,6 +1531,7 @@ out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_open_rsp); GF_FREE (rsp.xdata.xdata_val); @@ -1599,17 +1547,17 @@ server_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, struct iatt *postparent, dict_t *xdata) { server_state_t *state = NULL; + server_ctx_t *serv_ctx = NULL; inode_t *link_inode = NULL; rpcsvc_request_t *req = NULL; uint64_t fd_no = 0; gfs3_create_rsp rsp = {0,}; - req = frame->local; - state = CALL_STATE (frame); - - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); + state = CALL_STATE (frame); + if (op_ret < 0) { gf_log (this->name, GF_LOG_INFO, "%"PRId64": CREATE %s (%s/%s) ==> (%s)", @@ -1620,7 +1568,7 @@ server_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, } /* TODO: log gfid too */ - gf_log (state->client->bound_xl->name, GF_LOG_TRACE, + gf_log (frame->root->client->bound_xl->name, GF_LOG_TRACE, "%"PRId64": CREATE %s (%s)", frame->root->unique, state->loc.name, uuid_utoa (stbuf->ia_gfid)); @@ -1647,9 +1595,14 @@ server_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, inode_lookup (link_inode); inode_unref (link_inode); - fd_bind (fd); + serv_ctx = server_ctx_get (frame->root->client, this); + if (serv_ctx == NULL) { + gf_log (this->name, GF_LOG_INFO, "server_ctx_get() failed"); + goto out; + } - fd_no = gf_fd_unused_get (state->client->server_ctx.fdtable, fd); + fd_bind (fd); + fd_no = gf_fd_unused_get (serv_ctx->fdtable, fd); fd_ref (fd); if ((fd_no < 0) || (fd == 0)) { @@ -1666,6 +1619,7 @@ out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_create_rsp); @@ -1683,13 +1637,11 @@ server_readlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, server_state_t *state = NULL; rpcsvc_request_t *req = NULL; - req = frame->local; - state = CALL_STATE(frame); - - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); if (op_ret < 0) { + state = CALL_STATE (frame); gf_log (this->name, GF_LOG_INFO, "%"PRId64": READLINK %s (%s) ==> (%s)", frame->root->unique, state->loc.path, @@ -1708,6 +1660,7 @@ out: if (!rsp.path) rsp.path = ""; + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_readlink_rsp); @@ -1725,13 +1678,11 @@ server_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, server_state_t *state = NULL; rpcsvc_request_t *req = NULL; - req = frame->local; - state = CALL_STATE (frame); - - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); if (op_ret) { + state = CALL_STATE (frame); gf_log (this->name, GF_LOG_INFO, "%"PRId64": STAT %s (%s) ==> (%s)", frame->root->unique, state->loc.path, @@ -1746,6 +1697,7 @@ out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_stat_rsp); @@ -1764,13 +1716,11 @@ server_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, server_state_t *state = NULL; rpcsvc_request_t *req = NULL; - req = frame->local; - state = CALL_STATE (frame); - - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); if (op_ret) { + state = CALL_STATE (frame); gf_log (this->name, GF_LOG_INFO, "%"PRId64": SETATTR %s (%s) ==> (%s)", frame->root->unique, state->loc.path, @@ -1786,6 +1736,7 @@ out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_setattr_rsp); @@ -1803,13 +1754,11 @@ server_fsetattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, server_state_t *state = NULL; rpcsvc_request_t *req = NULL; - req = frame->local; - state = CALL_STATE (frame); - - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); if (op_ret) { + state = CALL_STATE (frame); gf_log (this->name, GF_LOG_INFO, "%"PRId64": FSETATTR %"PRId64" (%s) ==> (%s)", frame->root->unique, state->resolve.fd_no, @@ -1825,6 +1774,7 @@ out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_fsetattr_rsp); @@ -1843,13 +1793,11 @@ server_xattrop_cbk (call_frame_t *frame, void *cookie, xlator_t *this, server_state_t *state = NULL; rpcsvc_request_t *req = NULL; - req = frame->local; - state = CALL_STATE (frame); - - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); if (op_ret < 0) { + state = CALL_STATE (frame); gf_log (this->name, GF_LOG_INFO, "%"PRId64": XATTROP %s (%s) ==> (%s)", frame->root->unique, state->loc.path, @@ -1858,13 +1806,14 @@ server_xattrop_cbk (call_frame_t *frame, void *cookie, xlator_t *this, goto out; } - GF_PROTOCOL_DICT_SERIALIZE (this, dict, (&rsp.dict.dict_val), + GF_PROTOCOL_DICT_SERIALIZE (this, dict, &rsp.dict.dict_val, rsp.dict.dict_len, op_errno, out); out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_xattrop_rsp); @@ -1885,13 +1834,11 @@ server_fxattrop_cbk (call_frame_t *frame, void *cookie, xlator_t *this, server_state_t *state = NULL; rpcsvc_request_t *req = NULL; - req = frame->local; - state = CALL_STATE(frame); - - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); if (op_ret < 0) { + state = CALL_STATE (frame); gf_log (this->name, GF_LOG_INFO, "%"PRId64": FXATTROP %"PRId64" (%s) ==> (%s)", frame->root->unique, state->resolve.fd_no, @@ -1900,13 +1847,14 @@ server_fxattrop_cbk (call_frame_t *frame, void *cookie, xlator_t *this, goto out; } - GF_PROTOCOL_DICT_SERIALIZE (this, dict, (&rsp.dict.dict_val), + GF_PROTOCOL_DICT_SERIALIZE (this, dict, &rsp.dict.dict_val, rsp.dict.dict_len, op_errno, out); out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_fxattrop_rsp); @@ -1928,13 +1876,11 @@ server_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this, rpcsvc_request_t *req = NULL; int ret = 0; - req = frame->local; - state = CALL_STATE(frame); - - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); if (op_ret < 0) { + state = CALL_STATE (frame); gf_log (this->name, GF_LOG_INFO, "%"PRId64": READDIRP %"PRId64" (%s) ==> (%s)", frame->root->unique, state->resolve.fd_no, @@ -1960,6 +1906,7 @@ out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_readdirp_rsp); @@ -1979,13 +1926,11 @@ server_fallocate_cbk(call_frame_t *frame, void *cookie, xlator_t *this, server_state_t *state = NULL; rpcsvc_request_t *req = NULL; - req = frame->local; - state = CALL_STATE (frame); - - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); if (op_ret) { + state = CALL_STATE (frame); gf_log (this->name, GF_LOG_INFO, "%"PRId64": FALLOCATE %"PRId64" (%s) ==> (%s)", frame->root->unique, state->resolve.fd_no, @@ -2001,6 +1946,7 @@ out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply(frame, req, &rsp, NULL, 0, NULL, (xdrproc_t) xdr_gfs3_fallocate_rsp); @@ -2018,13 +1964,11 @@ server_discard_cbk(call_frame_t *frame, void *cookie, xlator_t *this, server_state_t *state = NULL; rpcsvc_request_t *req = NULL; - req = frame->local; - state = CALL_STATE (frame); - - GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val), + GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val, rsp.xdata.xdata_len, op_errno, out); if (op_ret) { + state = CALL_STATE (frame); gf_log (this->name, GF_LOG_INFO, "%"PRId64": DISCARD %"PRId64" (%s) ==> (%s)", frame->root->unique, state->resolve.fd_no, @@ -2040,6 +1984,7 @@ out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); + req = frame->local; server_submit_reply(frame, req, &rsp, NULL, 0, NULL, (xdrproc_t) xdr_gfs3_discard_rsp); @@ -2224,7 +2169,7 @@ server_fentrylk_resume (call_frame_t *frame, xlator_t *bound_xl) if (state->xdata) ret = dict_set_str (state->xdata, "connection-id", - state->client->server_ctx.client_uid); + frame->root->client->client_uid); STACK_WIND (frame, server_fentrylk_cbk, bound_xl, bound_xl->fops->fentrylk, @@ -2255,7 +2200,7 @@ server_entrylk_resume (call_frame_t *frame, xlator_t *bound_xl) if (state->xdata) ret = dict_set_str (state->xdata, "connection-id", - state->client->server_ctx.client_uid); + frame->root->client->client_uid); STACK_WIND (frame, server_entrylk_cbk, bound_xl, bound_xl->fops->entrylk, @@ -2275,6 +2220,9 @@ server_finodelk_resume (call_frame_t *frame, xlator_t *bound_xl) GF_UNUSED int ret = -1; server_state_t *state = NULL; + gf_log (bound_xl->name, GF_LOG_WARNING, "frame %p, xlator %p", + frame, bound_xl); + state = CALL_STATE (frame); if (state->resolve.op_ret != 0) @@ -2285,7 +2233,7 @@ server_finodelk_resume (call_frame_t *frame, xlator_t *bound_xl) if (state->xdata) ret = dict_set_str (state->xdata, "connection-id", - state->client->server_ctx.client_uid); + frame->root->client->client_uid); STACK_WIND (frame, server_finodelk_cbk, bound_xl, bound_xl->fops->finodelk, state->volume, state->fd, @@ -2305,6 +2253,9 @@ server_inodelk_resume (call_frame_t *frame, xlator_t *bound_xl) GF_UNUSED int ret = -1; server_state_t *state = NULL; + gf_log (bound_xl->name, GF_LOG_WARNING, "frame %p, xlator %p", + frame, bound_xl); + state = CALL_STATE (frame); if (state->resolve.op_ret != 0) @@ -2315,7 +2266,7 @@ server_inodelk_resume (call_frame_t *frame, xlator_t *bound_xl) if (state->xdata) ret = dict_set_str (state->xdata, "connection-id", - state->client->server_ctx.client_uid); + frame->root->client->client_uid); STACK_WIND (frame, server_inodelk_cbk, bound_xl, bound_xl->fops->inodelk, state->volume, &state->loc, @@ -3100,7 +3051,7 @@ server3_3_stat (rpcsvc_request_t *req) frame->root->op = GF_FOP_STAT; state = CALL_STATE (frame); - if (!state->client->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -3109,10 +3060,10 @@ server3_3_stat (rpcsvc_request_t *req) state->resolve.type = RESOLVE_MUST; memcpy (state->resolve.gfid, args.gfid, 16); - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); @@ -3158,7 +3109,7 @@ server3_3_setattr (rpcsvc_request_t *req) frame->root->op = GF_FOP_SETATTR; state = CALL_STATE (frame); - if (!state->client->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -3170,10 +3121,10 @@ server3_3_setattr (rpcsvc_request_t *req) gf_stat_to_iatt (&args.stbuf, &state->stbuf); state->valid = args.valid; - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -3217,7 +3168,7 @@ server3_3_fsetattr (rpcsvc_request_t *req) frame->root->op = GF_FOP_FSETATTR; state = CALL_STATE (frame); - if (!state->client->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -3229,10 +3180,10 @@ server3_3_fsetattr (rpcsvc_request_t *req) gf_stat_to_iatt (&args.stbuf, &state->stbuf); state->valid = args.valid; - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -3276,7 +3227,7 @@ server3_3_fallocate(rpcsvc_request_t *req) frame->root->op = GF_FOP_FALLOCATE; state = CALL_STATE (frame); - if (!state->client->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -3290,9 +3241,10 @@ server3_3_fallocate(rpcsvc_request_t *req) state->size = args.size; memcpy(state->resolve.gfid, args.gfid, 16); - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, + state->xdata, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -3337,7 +3289,7 @@ server3_3_discard(rpcsvc_request_t *req) frame->root->op = GF_FOP_DISCARD; state = CALL_STATE (frame); - if (!state->client->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -3350,9 +3302,10 @@ server3_3_discard(rpcsvc_request_t *req) state->size = args.size; memcpy(state->resolve.gfid, args.gfid, 16); - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, + state->xdata, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -3397,7 +3350,7 @@ server3_3_readlink (rpcsvc_request_t *req) frame->root->op = GF_FOP_READLINK; state = CALL_STATE (frame); - if (!state->client->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -3408,10 +3361,10 @@ server3_3_readlink (rpcsvc_request_t *req) state->size = args.size; - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -3458,7 +3411,7 @@ server3_3_create (rpcsvc_request_t *req) frame->root->op = GF_FOP_CREATE; state = CALL_STATE (frame); - if (!state->client->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -3478,10 +3431,10 @@ server3_3_create (rpcsvc_request_t *req) } /* TODO: can do alloca for xdata field instead of stdalloc */ - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -3526,7 +3479,7 @@ server3_3_open (rpcsvc_request_t *req) frame->root->op = GF_FOP_OPEN; state = CALL_STATE (frame); - if (!state->client->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -3537,10 +3490,10 @@ server3_3_open (rpcsvc_request_t *req) state->flags = gf_flags_to_flags (args.flags); - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -3583,7 +3536,7 @@ server3_3_readv (rpcsvc_request_t *req) frame->root->op = GF_FOP_READ; state = CALL_STATE (frame); - if (!state->client->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -3597,10 +3550,10 @@ server3_3_readv (rpcsvc_request_t *req) memcpy (state->resolve.gfid, args.gfid, 16); - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -3647,7 +3600,7 @@ server3_3_writev (rpcsvc_request_t *req) frame->root->op = GF_FOP_WRITE; state = CALL_STATE (frame); - if (!state->client->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -3677,10 +3630,10 @@ server3_3_writev (rpcsvc_request_t *req) state->size += state->payload_vector[i].iov_len; } - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); #ifdef GF_TESTING_IO_XDATA @@ -3759,10 +3712,11 @@ server3_3_writev_vecsizer (int state, ssize_t *readsize, char *base_addr, int server3_3_release (rpcsvc_request_t *req) { - client_t *client; - gfs3_release_req args = {{0,},}; - gf_common_rsp rsp = {0,}; - int ret = -1; + client_t *client = NULL; + server_ctx_t *serv_ctx = NULL; + gfs3_release_req args = {{0,},}; + gf_common_rsp rsp = {0,}; + int ret = -1; ret = xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_release_req); @@ -3778,7 +3732,16 @@ server3_3_release (rpcsvc_request_t *req) req->rpc_err = SYSTEM_ERR; goto out; } - gf_fd_put (client->server_ctx.fdtable, args.fd); + + serv_ctx = server_ctx_get (client, client->this); + if (serv_ctx == NULL) { + gf_log (req->trans->name, GF_LOG_INFO, + "server_ctx_get() failed"); + req->rpc_err = SYSTEM_ERR; + goto out; + } + + gf_fd_put (serv_ctx->fdtable, args.fd); server_submit_reply (NULL, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gf_common_rsp); @@ -3791,10 +3754,11 @@ out: int server3_3_releasedir (rpcsvc_request_t *req) { - client_t *client = NULL; - gfs3_releasedir_req args = {{0,},}; - gf_common_rsp rsp = {0,}; - int ret = -1; + client_t *client = NULL; + server_ctx_t *serv_ctx = NULL; + gfs3_releasedir_req args = {{0,},}; + gf_common_rsp rsp = {0,}; + int ret = -1; ret = xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_release_req); @@ -3810,7 +3774,15 @@ server3_3_releasedir (rpcsvc_request_t *req) goto out; } - gf_fd_put (client->server_ctx.fdtable, args.fd); + serv_ctx = server_ctx_get (client, client->this); + if (serv_ctx == NULL) { + gf_log (req->trans->name, GF_LOG_INFO, + "server_ctx_get() failed"); + req->rpc_err = SYSTEM_ERR; + goto out; + } + + gf_fd_put (serv_ctx->fdtable, args.fd); server_submit_reply (NULL, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gf_common_rsp); @@ -3850,7 +3822,7 @@ server3_3_fsync (rpcsvc_request_t *req) frame->root->op = GF_FOP_FSYNC; state = CALL_STATE (frame); - if (!state->client->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -3861,10 +3833,10 @@ server3_3_fsync (rpcsvc_request_t *req) state->flags = args.data; memcpy (state->resolve.gfid, args.gfid, 16); - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -3909,7 +3881,7 @@ server3_3_flush (rpcsvc_request_t *req) frame->root->op = GF_FOP_FLUSH; state = CALL_STATE (frame); - if (!state->client->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -3919,10 +3891,10 @@ server3_3_flush (rpcsvc_request_t *req) state->resolve.fd_no = args.fd; memcpy (state->resolve.gfid, args.gfid, 16); - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -3967,7 +3939,7 @@ server3_3_ftruncate (rpcsvc_request_t *req) frame->root->op = GF_FOP_FTRUNCATE; state = CALL_STATE (frame); - if (!state->client->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -3978,10 +3950,10 @@ server3_3_ftruncate (rpcsvc_request_t *req) state->offset = args.offset; memcpy (state->resolve.gfid, args.gfid, 16); - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -4025,7 +3997,7 @@ server3_3_fstat (rpcsvc_request_t *req) frame->root->op = GF_FOP_FSTAT; state = CALL_STATE (frame); - if (!state->client->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -4035,10 +4007,10 @@ server3_3_fstat (rpcsvc_request_t *req) state->resolve.fd_no = args.fd; memcpy (state->resolve.gfid, args.gfid, 16); - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -4082,7 +4054,7 @@ server3_3_truncate (rpcsvc_request_t *req) frame->root->op = GF_FOP_TRUNCATE; state = CALL_STATE (frame); - if (!state->client->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -4092,10 +4064,10 @@ server3_3_truncate (rpcsvc_request_t *req) memcpy (state->resolve.gfid, args.gfid, 16); state->offset = args.offset; - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -4142,7 +4114,7 @@ server3_3_unlink (rpcsvc_request_t *req) frame->root->op = GF_FOP_UNLINK; state = CALL_STATE (frame); - if (!state->client->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -4154,10 +4126,10 @@ server3_3_unlink (rpcsvc_request_t *req) state->flags = args.xflags; - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -4204,7 +4176,7 @@ server3_3_setxattr (rpcsvc_request_t *req) frame->root->op = GF_FOP_SETXATTR; state = CALL_STATE (frame); - if (!state->client->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -4214,7 +4186,7 @@ server3_3_setxattr (rpcsvc_request_t *req) state->flags = args.flags; memcpy (state->resolve.gfid, args.gfid, 16); - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, dict, (args.dict.dict_val), (args.dict.dict_len), ret, @@ -4225,10 +4197,10 @@ server3_3_setxattr (rpcsvc_request_t *req) /* There can be some commands hidden in key, check and proceed */ gf_server_check_setxattr_cmd (frame, dict); - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -4280,7 +4252,7 @@ server3_3_fsetxattr (rpcsvc_request_t *req) frame->root->op = GF_FOP_FSETXATTR; state = CALL_STATE (frame); - if (!state->client->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -4291,7 +4263,7 @@ server3_3_fsetxattr (rpcsvc_request_t *req) state->flags = args.flags; memcpy (state->resolve.gfid, args.gfid, 16); - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, dict, (args.dict.dict_val), (args.dict.dict_len), ret, @@ -4299,10 +4271,10 @@ server3_3_fsetxattr (rpcsvc_request_t *req) state->dict = dict; - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -4353,8 +4325,8 @@ server3_3_fxattrop (rpcsvc_request_t *req) } frame->root->op = GF_FOP_FXATTROP; - state = CALL_STATE(frame); - if (!state->client->bound_xl) { + state = CALL_STATE (frame); + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -4365,7 +4337,7 @@ server3_3_fxattrop (rpcsvc_request_t *req) state->flags = args.flags; memcpy (state->resolve.gfid, args.gfid, 16); - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, dict, (args.dict.dict_val), (args.dict.dict_len), ret, @@ -4373,10 +4345,10 @@ server3_3_fxattrop (rpcsvc_request_t *req) state->dict = dict; - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -4429,8 +4401,8 @@ server3_3_xattrop (rpcsvc_request_t *req) } frame->root->op = GF_FOP_XATTROP; - state = CALL_STATE(frame); - if (!state->client->bound_xl) { + state = CALL_STATE (frame); + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -4440,7 +4412,7 @@ server3_3_xattrop (rpcsvc_request_t *req) state->flags = args.flags; memcpy (state->resolve.gfid, args.gfid, 16); - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, dict, (args.dict.dict_val), (args.dict.dict_len), ret, @@ -4448,10 +4420,10 @@ server3_3_xattrop (rpcsvc_request_t *req) state->dict = dict; - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -4502,7 +4474,7 @@ server3_3_getxattr (rpcsvc_request_t *req) frame->root->op = GF_FOP_GETXATTR; state = CALL_STATE (frame); - if (!state->client->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -4517,10 +4489,10 @@ server3_3_getxattr (rpcsvc_request_t *req) gf_server_check_getxattr_cmd (frame, state->name); } - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -4565,7 +4537,7 @@ server3_3_fgetxattr (rpcsvc_request_t *req) frame->root->op = GF_FOP_FGETXATTR; state = CALL_STATE (frame); - if (!state->client->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -4578,10 +4550,10 @@ server3_3_fgetxattr (rpcsvc_request_t *req) if (args.namelen) state->name = gf_strdup (args.name); - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -4628,7 +4600,7 @@ server3_3_removexattr (rpcsvc_request_t *req) frame->root->op = GF_FOP_REMOVEXATTR; state = CALL_STATE (frame); - if (!state->client->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -4638,10 +4610,10 @@ server3_3_removexattr (rpcsvc_request_t *req) memcpy (state->resolve.gfid, args.gfid, 16); state->name = gf_strdup (args.name); - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -4686,7 +4658,7 @@ server3_3_fremovexattr (rpcsvc_request_t *req) frame->root->op = GF_FOP_FREMOVEXATTR; state = CALL_STATE (frame); - if (!state->client->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -4697,10 +4669,10 @@ server3_3_fremovexattr (rpcsvc_request_t *req) memcpy (state->resolve.gfid, args.gfid, 16); state->name = gf_strdup (args.name); - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -4746,7 +4718,7 @@ server3_3_opendir (rpcsvc_request_t *req) frame->root->op = GF_FOP_OPENDIR; state = CALL_STATE (frame); - if (!state->client->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -4755,10 +4727,10 @@ server3_3_opendir (rpcsvc_request_t *req) state->resolve.type = RESOLVE_MUST; memcpy (state->resolve.gfid, args.gfid, 16); - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -4802,8 +4774,8 @@ server3_3_readdirp (rpcsvc_request_t *req) } frame->root->op = GF_FOP_READDIRP; - state = CALL_STATE(frame); - if (!state->client->bound_xl) { + state = CALL_STATE (frame); + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -4826,7 +4798,7 @@ server3_3_readdirp (rpcsvc_request_t *req) memcpy (state->resolve.gfid, args.gfid, 16); /* here, dict itself works as xdata */ - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->dict, (args.dict.dict_val), (args.dict.dict_len), ret, @@ -4873,8 +4845,8 @@ server3_3_readdir (rpcsvc_request_t *req) } frame->root->op = GF_FOP_READDIR; - state = CALL_STATE(frame); - if (!state->client->bound_xl) { + state = CALL_STATE (frame); + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -4896,10 +4868,10 @@ server3_3_readdir (rpcsvc_request_t *req) state->offset = args.offset; memcpy (state->resolve.gfid, args.gfid, 16); - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -4941,8 +4913,8 @@ server3_3_fsyncdir (rpcsvc_request_t *req) } frame->root->op = GF_FOP_FSYNCDIR; - state = CALL_STATE(frame); - if (!state->client->bound_xl) { + state = CALL_STATE (frame); + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -4953,10 +4925,10 @@ server3_3_fsyncdir (rpcsvc_request_t *req) state->flags = args.data; memcpy (state->resolve.gfid, args.gfid, 16); - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -5003,7 +4975,7 @@ server3_3_mknod (rpcsvc_request_t *req) frame->root->op = GF_FOP_MKNOD; state = CALL_STATE (frame); - if (!state->client->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -5017,10 +4989,10 @@ server3_3_mknod (rpcsvc_request_t *req) state->dev = args.dev; state->umask = args.umask; - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -5069,7 +5041,7 @@ server3_3_mkdir (rpcsvc_request_t *req) frame->root->op = GF_FOP_MKDIR; state = CALL_STATE (frame); - if (!state->client->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -5083,10 +5055,10 @@ server3_3_mkdir (rpcsvc_request_t *req) state->umask = args.umask; /* TODO: can do alloca for xdata field instead of stdalloc */ - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -5133,7 +5105,7 @@ server3_3_rmdir (rpcsvc_request_t *req) frame->root->op = GF_FOP_RMDIR; state = CALL_STATE (frame); - if (!state->client->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -5145,10 +5117,10 @@ server3_3_rmdir (rpcsvc_request_t *req) state->flags = args.xflags; - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -5196,7 +5168,7 @@ server3_3_inodelk (rpcsvc_request_t *req) frame->root->op = GF_FOP_INODELK; state = CALL_STATE (frame); - if (!state->client->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -5235,10 +5207,10 @@ server3_3_inodelk (rpcsvc_request_t *req) break; } - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -5283,8 +5255,8 @@ server3_3_finodelk (rpcsvc_request_t *req) } frame->root->op = GF_FOP_FINODELK; - state = CALL_STATE(frame); - if (!state->client->bound_xl) { + state = CALL_STATE (frame); + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -5324,10 +5296,10 @@ server3_3_finodelk (rpcsvc_request_t *req) break; } - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -5376,7 +5348,7 @@ server3_3_entrylk (rpcsvc_request_t *req) frame->root->op = GF_FOP_ENTRYLK; state = CALL_STATE (frame); - if (!state->client->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -5392,10 +5364,10 @@ server3_3_entrylk (rpcsvc_request_t *req) state->cmd = args.cmd; state->type = args.type; - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -5440,8 +5412,8 @@ server3_3_fentrylk (rpcsvc_request_t *req) } frame->root->op = GF_FOP_FENTRYLK; - state = CALL_STATE(frame); - if (!state->client->bound_xl) { + state = CALL_STATE (frame); + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -5457,10 +5429,10 @@ server3_3_fentrylk (rpcsvc_request_t *req) state->name = gf_strdup (args.name); state->volume = gf_strdup (args.volume); - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -5503,7 +5475,7 @@ server3_3_access (rpcsvc_request_t *req) frame->root->op = GF_FOP_ACCESS; state = CALL_STATE (frame); - if (!state->client->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -5513,10 +5485,10 @@ server3_3_access (rpcsvc_request_t *req) memcpy (state->resolve.gfid, args.gfid, 16); state->mask = args.mask; - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -5564,7 +5536,7 @@ server3_3_symlink (rpcsvc_request_t *req) frame->root->op = GF_FOP_SYMLINK; state = CALL_STATE (frame); - if (!state->client->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -5576,10 +5548,10 @@ server3_3_symlink (rpcsvc_request_t *req) state->name = gf_strdup (args.linkname); state->umask = args.umask; - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -5627,7 +5599,7 @@ server3_3_link (rpcsvc_request_t *req) frame->root->op = GF_FOP_LINK; state = CALL_STATE (frame); - if (!state->client->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -5640,10 +5612,10 @@ server3_3_link (rpcsvc_request_t *req) state->resolve2.bname = gf_strdup (args.newbname); memcpy (state->resolve2.pargfid, args.newgfid, 16); - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -5690,7 +5662,7 @@ server3_3_rename (rpcsvc_request_t *req) frame->root->op = GF_FOP_RENAME; state = CALL_STATE (frame); - if (!state->client->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -5704,10 +5676,10 @@ server3_3_rename (rpcsvc_request_t *req) state->resolve2.bname = gf_strdup (args.newbname); memcpy (state->resolve2.pargfid, args.newgfid, 16); - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -5749,7 +5721,7 @@ server3_3_lk (rpcsvc_request_t *req) frame->root->op = GF_FOP_LK; state = CALL_STATE (frame); - if (!state->client->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -5799,7 +5771,7 @@ server3_3_lk (rpcsvc_request_t *req) state->flock.l_type = F_UNLCK; break; default: - gf_log (state->client->bound_xl->name, GF_LOG_ERROR, + gf_log (frame->root->client->bound_xl->name, GF_LOG_ERROR, "fd - %"PRId64" (%s): Unknown lock type: %"PRId32"!", state->resolve.fd_no, uuid_utoa (state->fd->inode->gfid), state->type); @@ -5807,10 +5779,10 @@ server3_3_lk (rpcsvc_request_t *req) } - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -5855,8 +5827,8 @@ server3_3_rchecksum (rpcsvc_request_t *req) } frame->root->op = GF_FOP_RCHECKSUM; - state = CALL_STATE(frame); - if (!state->client->bound_xl) { + state = CALL_STATE (frame); + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -5867,10 +5839,10 @@ server3_3_rchecksum (rpcsvc_request_t *req) state->offset = args.offset; state->size = args.len; - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -5933,7 +5905,7 @@ server3_3_lookup (rpcsvc_request_t *req) */ state = CALL_STATE (frame); - if (!state->client->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -5948,10 +5920,10 @@ server3_3_lookup (rpcsvc_request_t *req) memcpy (state->resolve.gfid, args.gfid, 16); } - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; @@ -5996,7 +5968,7 @@ server3_3_statfs (rpcsvc_request_t *req) frame->root->op = GF_FOP_STATFS; state = CALL_STATE (frame); - if (!state->client->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ SERVER_REQ_SET_ERROR (req, ret); goto out; @@ -6005,10 +5977,10 @@ server3_3_statfs (rpcsvc_request_t *req) state->resolve.type = RESOLVE_MUST; memcpy (state->resolve.gfid, args.gfid, 16); - GF_PROTOCOL_DICT_UNSERIALIZE (state->client->bound_xl, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, state->xdata, - (args.xdata.xdata_val), - (args.xdata.xdata_len), ret, + args.xdata.xdata_val, + args.xdata.xdata_len, ret, op_errno, out); ret = 0; diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c index 7e6e2c0915b..65ea0bb5541 100644 --- a/xlators/protocol/server/src/server.c +++ b/xlators/protocol/server/src/server.c @@ -25,8 +25,6 @@ #include "statedump.h" #include "defaults.h" #include "authenticate.h" -#include "rpcsvc.h" -#include "client_t.h" void grace_time_handler (void *data) @@ -34,6 +32,7 @@ grace_time_handler (void *data) client_t *client = NULL; xlator_t *this = NULL; gf_timer_t *timer = NULL; + server_ctx_t *serv_ctx = NULL; gf_boolean_t cancelled = _gf_false; gf_boolean_t detached = _gf_false; @@ -43,16 +42,23 @@ grace_time_handler (void *data) GF_VALIDATE_OR_GOTO (THIS->name, this, out); gf_log (this->name, GF_LOG_INFO, "grace timer expired for %s", - client->server_ctx.client_uid); + client->client_uid); - LOCK (&client->server_ctx.fdtable_lock); + serv_ctx = server_ctx_get (client, this); + + if (serv_ctx == NULL) { + gf_log (this->name, GF_LOG_INFO, "server_ctx_get() failed"); + goto out; + } + + LOCK (&serv_ctx->fdtable_lock); { - if (client->server_ctx.grace_timer) { - timer = client->server_ctx.grace_timer; - client->server_ctx.grace_timer = NULL; + if (serv_ctx->grace_timer) { + timer = serv_ctx->grace_timer; + serv_ctx->grace_timer = NULL; } } - UNLOCK (&client->server_ctx.fdtable_lock); + UNLOCK (&serv_ctx->fdtable_lock); if (timer) { gf_timer_call_cancel (this->ctx, timer); cancelled = _gf_true; @@ -67,7 +73,7 @@ grace_time_handler (void *data) gf_client_put (client, &detached); if (detached)//reconnection did not happen :-( server_connection_cleanup (this, client, - INTERNAL_LOCKS | POSIX_LOCKS); + INTERNAL_LOCKS | POSIX_LOCKS); gf_client_unref (client); } out: @@ -144,7 +150,7 @@ server_submit_reply (call_frame_t *frame, rpcsvc_request_t *req, void *arg, if (frame) { state = CALL_STATE (frame); frame->local = NULL; - client = state->client; + client = frame->root->client; } if (client) @@ -463,6 +469,7 @@ server_rpc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event, rpc_transport_t *trans = NULL; server_conf_t *conf = NULL; client_t *client = NULL; + server_ctx_t *serv_ctx = NULL; if (!xl || !data) { gf_log_callingfn ("server", GF_LOG_WARNING, @@ -471,7 +478,7 @@ server_rpc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event, } this = xl; - trans= data; + trans = data; conf = this->private; switch (event) { @@ -511,7 +518,7 @@ server_rpc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event, break; gf_log (this->name, GF_LOG_INFO, "disconnecting connection" - "from %s", client->server_ctx.client_uid); + "from %s", client->client_uid); /* If lock self heal is off, then destroy the conn object, else register a grace timer event */ @@ -527,22 +534,30 @@ server_rpc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event, trans->xl_private = NULL; server_connection_cleanup (this, client, INTERNAL_LOCKS); - LOCK (&client->server_ctx.fdtable_lock); + serv_ctx = server_ctx_get (client, this); + + if (serv_ctx == NULL) { + gf_log (this->name, GF_LOG_INFO, + "server_ctx_get() failed"); + goto out; + } + + LOCK (&serv_ctx->fdtable_lock); { - if (!client->server_ctx.grace_timer) { + if (!serv_ctx->grace_timer) { gf_log (this->name, GF_LOG_INFO, "starting a grace timer for %s", - client->server_ctx.client_uid); + client->client_uid); - client->server_ctx.grace_timer = + serv_ctx->grace_timer = gf_timer_call_after (this->ctx, conf->grace_ts, grace_time_handler, client); } } - UNLOCK (&client->server_ctx.fdtable_lock); + UNLOCK (&serv_ctx->fdtable_lock); break; case RPCSVC_EVENT_TRANSPORT_DESTROY: /*- conn obj has been disassociated from trans on first @@ -753,6 +768,26 @@ out: return ret; } +static int32_t +client_destroy_cbk (xlator_t *this, client_t *client) +{ + void *tmp = NULL; + server_ctx_t *ctx = NULL; + + client_ctx_del (client, this, &tmp); + + ctx = tmp; + + if (ctx == NULL) + return 0; + + gf_fd_fdtable_destroy (ctx->fdtable); + LOCK_DESTROY (&ctx->fdtable_lock); + GF_FREE (ctx); + + return 0; +} + int init (xlator_t *this) { @@ -965,7 +1000,9 @@ notify (xlator_t *this, int32_t event, void *data, ...) struct xlator_fops fops; -struct xlator_cbks cbks; +struct xlator_cbks cbks = { + .client_destroy = client_destroy_cbk, +}; struct xlator_dumpops dumpops = { .priv = server_priv, diff --git a/xlators/protocol/server/src/server.h b/xlators/protocol/server/src/server.h index 3238f6f40e2..43e84921c8a 100644 --- a/xlators/protocol/server/src/server.h +++ b/xlators/protocol/server/src/server.h @@ -13,6 +13,7 @@ #include <pthread.h> +#include "fd.h" #include "rpcsvc.h" #include "fd.h" @@ -20,6 +21,7 @@ #include "server-mem-types.h" #include "glusterfs3.h" #include "timer.h" +#include "client_t.h" #define DEFAULT_BLOCK_SIZE 4194304 /* 4MB */ #define DEFAULT_VOLUME_FILE_PATH CONFDIR "/glusterfs.vol" @@ -92,11 +94,10 @@ int resolve_and_resume (call_frame_t *frame, server_resume_fn_t fn); struct _server_state { - struct _client_t *client; - rpc_transport_t *xprt; - inode_table_t *itable; + rpc_transport_t *xprt; + inode_table_t *itable; - server_resume_fn_t resume_fn; + server_resume_fn_t resume_fn; loc_t loc; loc_t loc2; @@ -132,7 +133,7 @@ struct _server_state { int mask; char is_revalidate; dict_t *dict; - struct gf_flock flock; + struct gf_flock flock; const char *volume; dir_entry_t *entry; @@ -140,10 +141,20 @@ struct _server_state { mode_t umask; }; + extern struct rpcsvc_program gluster_handshake_prog; extern struct rpcsvc_program glusterfs3_3_fop_prog; extern struct rpcsvc_program gluster_ping_prog; + +typedef struct _server_ctx { + gf_lock_t fdtable_lock; + fdtable_t *fdtable; + struct _gf_timer *grace_timer; + uint32_t lk_version; +} server_ctx_t; + + int server_submit_reply (call_frame_t *frame, rpcsvc_request_t *req, void *arg, struct iovec *payload, int payloadcount, |