From 3108d4529d57690f58027da61ac5e56a0987ed57 Mon Sep 17 00:00:00 2001 From: "Kaleb S. KEITHLEY" Date: Wed, 21 Aug 2013 14:11:38 -0400 Subject: 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 Reviewed-on: http://review.gluster.org/5678 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- xlators/protocol/server/src/Makefile.am | 6 +- xlators/protocol/server/src/server-handshake.c | 32 +- xlators/protocol/server/src/server-helpers.c | 307 +++------ xlators/protocol/server/src/server-helpers.h | 4 +- xlators/protocol/server/src/server-resolve.c | 32 +- xlators/protocol/server/src/server-rpc-fops.c | 870 ++++++++++++------------- xlators/protocol/server/src/server.c | 73 ++- xlators/protocol/server/src/server.h | 21 +- 8 files changed, 624 insertions(+), 721 deletions(-) (limited to 'xlators/protocol/server') 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 @@ -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; @@ -129,171 +122,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, @@ -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 +#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, -- cgit