diff options
Diffstat (limited to 'xlators/protocol')
| -rw-r--r-- | xlators/protocol/auth/addr/src/addr.c | 17 | ||||
| -rw-r--r-- | xlators/protocol/auth/login/src/login.c | 17 | ||||
| -rw-r--r-- | xlators/protocol/client/src/client-handshake.c | 13 | ||||
| -rw-r--r-- | xlators/protocol/client/src/client-rpc-fops.c | 310 | ||||
| -rw-r--r-- | xlators/protocol/client/src/client.c | 147 | ||||
| -rw-r--r-- | xlators/protocol/client/src/client.h | 6 | ||||
| -rw-r--r-- | xlators/protocol/server/src/Makefile.am | 6 | ||||
| -rw-r--r-- | xlators/protocol/server/src/server-handshake.c | 111 | ||||
| -rw-r--r-- | xlators/protocol/server/src/server-helpers.c | 1114 | ||||
| -rw-r--r-- | xlators/protocol/server/src/server-helpers.h | 55 | ||||
| -rw-r--r-- | xlators/protocol/server/src/server-resolve.c | 33 | ||||
| -rw-r--r-- | xlators/protocol/server/src/server-rpc-fops.c | 1982 | ||||
| -rw-r--r-- | xlators/protocol/server/src/server.c | 586 | ||||
| -rw-r--r-- | xlators/protocol/server/src/server.h | 107 |
14 files changed, 2531 insertions, 1973 deletions
diff --git a/xlators/protocol/auth/addr/src/addr.c b/xlators/protocol/auth/addr/src/addr.c index 199fc6db0..64e8d0fc6 100644 --- a/xlators/protocol/auth/addr/src/addr.c +++ b/xlators/protocol/auth/addr/src/addr.c @@ -2,19 +2,10 @@ Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com> This file is part of GlusterFS. - GlusterFS is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published - by the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - GlusterFS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see - <http://www.gnu.org/licenses/>. + This file is licensed to you under your choice of the GNU Lesser + General Public License, version 3 or any later version (LGPLv3 or + later), or the GNU General Public License, version 2 (GPLv2), in all + cases as published by the Free Software Foundation. */ diff --git a/xlators/protocol/auth/login/src/login.c b/xlators/protocol/auth/login/src/login.c index 702a876ac..c2f0bf0d0 100644 --- a/xlators/protocol/auth/login/src/login.c +++ b/xlators/protocol/auth/login/src/login.c @@ -2,19 +2,10 @@ Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com> This file is part of GlusterFS. - GlusterFS is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published - by the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - GlusterFS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see - <http://www.gnu.org/licenses/>. + This file is licensed to you under your choice of the GNU Lesser + General Public License, version 3 or any later version (LGPLv3 or + later), or the GNU General Public License, version 2 (GPLv2), in all + cases as published by the Free Software Foundation. */ #ifndef _CONFIG_H diff --git a/xlators/protocol/client/src/client-handshake.c b/xlators/protocol/client/src/client-handshake.c index ff0e162c6..5668fea53 100644 --- a/xlators/protocol/client/src/client-handshake.c +++ b/xlators/protocol/client/src/client-handshake.c @@ -53,7 +53,7 @@ rpc_client_ping_timer_expired (void *data) rpc_clnt_connection_t *conn = NULL; int disconnect = 0; int transport_activity = 0; - struct timeval timeout = {0, }; + struct timespec timeout = {0, }; struct timeval current = {0, }; struct rpc_clnt *clnt = NULL; xlator_t *this = NULL; @@ -101,7 +101,7 @@ rpc_client_ping_timer_expired (void *data) "ping timer expired but transport activity " "detected - not bailing transport"); timeout.tv_sec = conf->opt.ping_timeout; - timeout.tv_usec = 0; + timeout.tv_nsec = 0; conn->ping_timer = gf_timer_call_after (this->ctx, timeout, @@ -140,7 +140,7 @@ client_start_ping (void *data) clnt_conf_t *conf = NULL; rpc_clnt_connection_t *conn = NULL; int32_t ret = -1; - struct timeval timeout = {0, }; + struct timespec timeout = {0, }; call_frame_t *frame = NULL; int frame_count = 0; @@ -196,7 +196,7 @@ client_start_ping (void *data) } timeout.tv_sec = conf->opt.ping_timeout; - timeout.tv_usec = 0; + timeout.tv_nsec = 0; conn->ping_timer = gf_timer_call_after (this->ctx, timeout, @@ -241,7 +241,7 @@ client_ping_cbk (struct rpc_req *req, struct iovec *iov, int count, { xlator_t *this = NULL; rpc_clnt_connection_t *conn = NULL; - struct timeval timeout = {0, }; + struct timespec timeout = {0, }; call_frame_t *frame = NULL; clnt_conf_t *conf = NULL; @@ -281,7 +281,7 @@ client_ping_cbk (struct rpc_req *req, struct iovec *iov, int count, timeout.tv_sec = conf->opt.ping_timeout; - timeout.tv_usec = 0; + timeout.tv_nsec = 0; gf_timer_call_cancel (this->ctx, conn->ping_timer); @@ -1744,6 +1744,7 @@ client_query_portmap_cbk (struct rpc_req *req, struct iovec *iov, int count, voi } conf->portmap_err_logged = 0; + conf->disconnect_err_logged = 0; config.remote_port = rsp.port; rpc_clnt_reconfig (conf->rpc, &config); diff --git a/xlators/protocol/client/src/client-rpc-fops.c b/xlators/protocol/client/src/client-rpc-fops.c index a6d0a591a..6355450c3 100644 --- a/xlators/protocol/client/src/client-rpc-fops.c +++ b/xlators/protocol/client/src/client-rpc-fops.c @@ -1936,6 +1936,172 @@ out: return 0; } +int +client3_3_fallocate_cbk (struct rpc_req *req, struct iovec *iov, int count, + void *myframe) +{ + call_frame_t *frame = NULL; + gfs3_fallocate_rsp rsp = {0,}; + struct iatt prestat = {0,}; + struct iatt poststat = {0,}; + int ret = 0; + xlator_t *this = NULL; + dict_t *xdata = NULL; + + + this = THIS; + + frame = myframe; + + if (-1 == req->rpc_status) { + rsp.op_ret = -1; + rsp.op_errno = ENOTCONN; + goto out; + } + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_fallocate_rsp); + if (ret < 0) { + gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; + } + + if (-1 != rsp.op_ret) { + gf_stat_to_iatt (&rsp.statpre, &prestat); + gf_stat_to_iatt (&rsp.statpost, &poststat); + } + + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + +out: + if (rsp.op_ret == -1) { + gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", + strerror (gf_error_to_errno (rsp.op_errno))); + } + CLIENT_STACK_UNWIND (fallocate, frame, rsp.op_ret, + gf_error_to_errno (rsp.op_errno), &prestat, + &poststat, xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); + + return 0; +} + +int +client3_3_discard_cbk(struct rpc_req *req, struct iovec *iov, int count, + void *myframe) +{ + call_frame_t *frame = NULL; + gfs3_discard_rsp rsp = {0,}; + struct iatt prestat = {0,}; + struct iatt poststat = {0,}; + int ret = 0; + xlator_t *this = NULL; + dict_t *xdata = NULL; + + this = THIS; + + frame = myframe; + + if (-1 == req->rpc_status) { + rsp.op_ret = -1; + rsp.op_errno = ENOTCONN; + goto out; + } + ret = xdr_to_generic(*iov, &rsp, (xdrproc_t) xdr_gfs3_discard_rsp); + if (ret < 0) { + gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; + } + + if (-1 != rsp.op_ret) { + gf_stat_to_iatt (&rsp.statpre, &prestat); + gf_stat_to_iatt (&rsp.statpost, &poststat); + } + + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + +out: + if (rsp.op_ret == -1) { + gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", + strerror (gf_error_to_errno (rsp.op_errno))); + } + CLIENT_STACK_UNWIND (discard, frame, rsp.op_ret, + gf_error_to_errno (rsp.op_errno), &prestat, + &poststat, xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); + + return 0; +} + +int +client3_3_zerofill_cbk(struct rpc_req *req, struct iovec *iov, int count, + void *myframe) +{ + call_frame_t *frame = NULL; + gfs3_zerofill_rsp rsp = {0,}; + struct iatt prestat = {0,}; + struct iatt poststat = {0,}; + int ret = 0; + xlator_t *this = NULL; + dict_t *xdata = NULL; + + this = THIS; + + frame = myframe; + + if (-1 == req->rpc_status) { + rsp.op_ret = -1; + rsp.op_errno = ENOTCONN; + goto out; + } + ret = xdr_to_generic(*iov, &rsp, (xdrproc_t) xdr_gfs3_zerofill_rsp); + if (ret < 0) { + gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; + } + + if (-1 != rsp.op_ret) { + gf_stat_to_iatt (&rsp.statpre, &prestat); + gf_stat_to_iatt (&rsp.statpost, &poststat); + } + + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + +out: + if (rsp.op_ret == -1) { + gf_log (this->name, GF_LOG_WARNING, + "remote operation failed: %s", + strerror (gf_error_to_errno (rsp.op_errno))); + } + CLIENT_STACK_UNWIND (zerofill, frame, rsp.op_ret, + gf_error_to_errno (rsp.op_errno), &prestat, + &poststat, xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); + + return 0; +} int client3_3_setattr_cbk (struct rpc_req *req, struct iovec *iov, int count, @@ -2757,7 +2923,7 @@ client_fdctx_destroy (xlator_t *this, clnt_fd_ctx_t *fdctx) if (fdctx->is_dir) { gfs3_releasedir_req req = {{0,},}; req.fd = fdctx->remote_fd; - gf_log (this->name, GF_LOG_DEBUG, "sending releasedir on fd"); + gf_log (this->name, GF_LOG_TRACE, "sending releasedir on fd"); client_submit_request (this, &req, fr, &clnt3_3_fop_prog, GFS3_OP_RELEASEDIR, client3_3_releasedir_cbk, @@ -2766,7 +2932,7 @@ client_fdctx_destroy (xlator_t *this, clnt_fd_ctx_t *fdctx) } else { gfs3_release_req req = {{0,},}; req.fd = fdctx->remote_fd; - gf_log (this->name, GF_LOG_DEBUG, "sending release on fd"); + gf_log (this->name, GF_LOG_TRACE, "sending release on fd"); client_submit_request (this, &req, fr, &clnt3_3_fop_prog, GFS3_OP_RELEASE, client3_3_release_cbk, NULL, @@ -5786,7 +5952,140 @@ unwind: return 0; } +int32_t +client3_3_fallocate(call_frame_t *frame, xlator_t *this, void *data) +{ + clnt_args_t *args = NULL; + int64_t remote_fd = -1; + clnt_conf_t *conf = NULL; + gfs3_fallocate_req req = {{0},}; + int op_errno = ESTALE; + int ret = 0; + + if (!frame || !this || !data) + goto unwind; + + args = data; + conf = this->private; + + CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD, + remote_fd, op_errno, unwind); + + req.fd = remote_fd; + req.flags = args->flags; + req.offset = args->offset; + req.size = args->size; + memcpy(req.gfid, args->fd->inode->gfid, 16); + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + + ret = client_submit_request (this, &req, frame, conf->fops, + GFS3_OP_FALLOCATE, + client3_3_fallocate_cbk, NULL, + NULL, 0, NULL, 0, + NULL, (xdrproc_t)xdr_gfs3_fallocate_req); + if (ret) { + gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); + } + + GF_FREE (req.xdata.xdata_val); + + return 0; +unwind: + CLIENT_STACK_UNWIND (fallocate, frame, -1, op_errno, NULL, NULL, NULL); + GF_FREE (req.xdata.xdata_val); + + return 0; +} + +int32_t +client3_3_discard(call_frame_t *frame, xlator_t *this, void *data) +{ + clnt_args_t *args = NULL; + int64_t remote_fd = -1; + clnt_conf_t *conf = NULL; + gfs3_discard_req req = {{0},}; + int op_errno = ESTALE; + int ret = 0; + + if (!frame || !this || !data) + goto unwind; + + args = data; + conf = this->private; + + CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD, + remote_fd, op_errno, unwind); + + req.fd = remote_fd; + req.offset = args->offset; + req.size = args->size; + memcpy(req.gfid, args->fd->inode->gfid, 16); + + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + + ret = client_submit_request(this, &req, frame, conf->fops, + GFS3_OP_DISCARD, client3_3_discard_cbk, + NULL, NULL, 0, NULL, 0, NULL, + (xdrproc_t) xdr_gfs3_discard_req); + if (ret) + gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); + + GF_FREE (req.xdata.xdata_val); + + return 0; +unwind: + CLIENT_STACK_UNWIND(discard, frame, -1, op_errno, NULL, NULL, NULL); + GF_FREE (req.xdata.xdata_val); + + return 0; +} + +int32_t +client3_3_zerofill(call_frame_t *frame, xlator_t *this, void *data) +{ + clnt_args_t *args = NULL; + int64_t remote_fd = -1; + clnt_conf_t *conf = NULL; + gfs3_zerofill_req req = {{0},}; + int op_errno = ESTALE; + int ret = 0; + + if (!frame || !this || !data) + goto unwind; + + args = data; + conf = this->private; + + CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD, + remote_fd, op_errno, unwind); + + req.fd = remote_fd; + req.offset = args->offset; + req.size = args->size; + memcpy(req.gfid, args->fd->inode->gfid, 16); + + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + + ret = client_submit_request(this, &req, frame, conf->fops, + GFS3_OP_ZEROFILL, client3_3_zerofill_cbk, + NULL, NULL, 0, NULL, 0, NULL, + (xdrproc_t) xdr_gfs3_zerofill_req); + if (ret) + gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); + + GF_FREE (req.xdata.xdata_val); + + return 0; +unwind: + CLIENT_STACK_UNWIND(zerofill, frame, -1, op_errno, NULL, NULL, NULL); + GF_FREE (req.xdata.xdata_val); + + return 0; +} /* Table Specific to FOPS */ @@ -5833,6 +6132,9 @@ rpc_clnt_procedure_t clnt3_3_fop_actors[GF_FOP_MAXVALUE] = { [GF_FOP_SETATTR] = { "SETATTR", client3_3_setattr }, [GF_FOP_FSETATTR] = { "FSETATTR", client3_3_fsetattr }, [GF_FOP_READDIRP] = { "READDIRP", client3_3_readdirp }, + [GF_FOP_FALLOCATE] = { "FALLOCATE", client3_3_fallocate }, + [GF_FOP_DISCARD] = { "DISCARD", client3_3_discard }, + [GF_FOP_ZEROFILL] = { "ZEROFILL", client3_3_zerofill}, [GF_FOP_RELEASE] = { "RELEASE", client3_3_release }, [GF_FOP_RELEASEDIR] = { "RELEASEDIR", client3_3_releasedir }, [GF_FOP_GETSPEC] = { "GETSPEC", client3_getspec }, @@ -5885,6 +6187,10 @@ char *clnt3_3_fop_names[GFS3_OP_MAXVALUE] = { [GFS3_OP_RELEASE] = "RELEASE", [GFS3_OP_RELEASEDIR] = "RELEASEDIR", [GFS3_OP_FREMOVEXATTR] = "FREMOVEXATTR", + [GFS3_OP_FALLOCATE] = "FALLOCATE", + [GFS3_OP_DISCARD] = "DISCARD", + [GFS3_OP_ZEROFILL] = "ZEROFILL", + }; rpc_clnt_prog_t clnt3_3_fop_prog = { diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c index 931c67156..1f7d13ea4 100644 --- a/xlators/protocol/client/src/client.c +++ b/xlators/protocol/client/src/client.c @@ -130,7 +130,7 @@ client_register_grace_timer (xlator_t *this, clnt_conf_t *conf) conf->grace_timer = gf_timer_call_after (this->ctx, - conf->grace_tv, + conf->grace_ts, client_grace_timeout, conf->rpc); } @@ -1961,6 +1961,110 @@ out: return 0; } +int32_t +client_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t mode, + off_t offset, size_t len, dict_t *xdata) +{ + int ret = -1; + clnt_conf_t *conf = NULL; + rpc_clnt_procedure_t *proc = NULL; + clnt_args_t args = {0,}; + + conf = this->private; + if (!conf || !conf->fops) + goto out; + + args.fd = fd; + args.flags = mode; + args.offset = offset; + args.size = len; + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_FALLOCATE]; + if (!proc) { + gf_log (this->name, GF_LOG_ERROR, + "rpc procedure not found for %s", + gf_fop_list[GF_FOP_FALLOCATE]); + goto out; + } + if (proc->fn) + ret = proc->fn (frame, this, &args); +out: + if (ret) + STACK_UNWIND_STRICT (fallocate, frame, -1, ENOTCONN, NULL, NULL, NULL); + + return 0; +} + +int32_t +client_discard(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, + size_t len, dict_t *xdata) +{ + int ret = -1; + clnt_conf_t *conf = NULL; + rpc_clnt_procedure_t *proc = NULL; + clnt_args_t args = {0,}; + + conf = this->private; + if (!conf || !conf->fops) + goto out; + + args.fd = fd; + args.offset = offset; + args.size = len; + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_DISCARD]; + if (!proc) { + gf_log (this->name, GF_LOG_ERROR, + "rpc procedure not found for %s", + gf_fop_list[GF_FOP_DISCARD]); + goto out; + } + if (proc->fn) + ret = proc->fn (frame, this, &args); +out: + if (ret) + STACK_UNWIND_STRICT(discard, frame, -1, ENOTCONN, NULL, NULL, NULL); + + return 0; +} + +int32_t +client_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, + size_t len, dict_t *xdata) +{ + int ret = -1; + clnt_conf_t *conf = NULL; + rpc_clnt_procedure_t *proc = NULL; + clnt_args_t args = {0,}; + + conf = this->private; + if (!conf || !conf->fops) + goto out; + + args.fd = fd; + args.offset = offset; + args.size = len; + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_ZEROFILL]; + if (!proc) { + gf_log (this->name, GF_LOG_ERROR, + "rpc procedure not found for %s", + gf_fop_list[GF_FOP_ZEROFILL]); + goto out; + } + if (proc->fn) + ret = proc->fn (frame, this, &args); +out: + if (ret) + STACK_UNWIND_STRICT(zerofill, frame, -1, ENOTCONN, + NULL, NULL, NULL); + + return 0; +} + int32_t client_getspec (call_frame_t *frame, xlator_t *this, const char *key, @@ -2050,7 +2154,7 @@ client_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, gf_log (this->name, GF_LOG_DEBUG, "got RPC_CLNT_CONNECT"); if ((ret < 0) || (strcasecmp (handshake, "on"))) { - ret = client_handshake (this, conf->rpc); + ret = client_handshake (this, rpc); if (ret) gf_log (this->name, GF_LOG_WARNING, "handshake msg returned %d", ret); @@ -2092,9 +2196,19 @@ client_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, client_register_grace_timer (this, conf); if (!conf->skip_notify) { - if (conf->connected) - gf_log (this->name, GF_LOG_INFO, - "disconnected"); + if (conf->connected) { + gf_log (this->name, + ((!conf->disconnect_err_logged) + ? GF_LOG_INFO : GF_LOG_DEBUG), + "disconnected from %s. Client process " + "will keep trying to connect to " + "glusterd until brick's port is " + "available", + conf->rpc->conn.trans->peerinfo.identifier); + + if (conf->portmap_err_logged) + conf->disconnect_err_logged = 1; + } /* If the CHILD_DOWN event goes to parent xlator multiple times, the logic of parent xlator notify @@ -2118,10 +2232,14 @@ client_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, conf->connected = 0; conf->skip_notify = 0; - if (conf->quick_reconnect) { - conf->quick_reconnect = 0; - rpc_clnt_start (conf->rpc); - } + if (conf->quick_reconnect) { + conf->quick_reconnect = 0; + rpc_clnt_start (rpc); + + } else { + rpc->conn.config.remote_port = 0; + + } break; @@ -2332,14 +2450,14 @@ client_init_grace_timer (xlator_t *this, dict_t *options, ret = dict_get_int32 (options, "grace-timeout", &grace_timeout); if (!ret) - conf->grace_tv.tv_sec = grace_timeout; + conf->grace_ts.tv_sec = grace_timeout; else - conf->grace_tv.tv_sec = 10; + conf->grace_ts.tv_sec = 10; - conf->grace_tv.tv_usec = 0; + conf->grace_ts.tv_nsec = 0; gf_log (this->name, GF_LOG_DEBUG, "Client grace timeout " - "value = %"PRIu64, conf->grace_tv.tv_sec); + "value = %"PRIu64, conf->grace_ts.tv_sec); ret = 0; out: @@ -2665,6 +2783,9 @@ struct xlator_fops fops = { .fxattrop = client_fxattrop, .setattr = client_setattr, .fsetattr = client_fsetattr, + .fallocate = client_fallocate, + .discard = client_discard, + .zerofill = client_zerofill, .getspec = client_getspec, }; diff --git a/xlators/protocol/client/src/client.h b/xlators/protocol/client/src/client.h index 0a27c095c..afab2d74f 100644 --- a/xlators/protocol/client/src/client.h +++ b/xlators/protocol/client/src/client.h @@ -93,6 +93,10 @@ typedef struct clnt_conf { which was sent earlier */ char portmap_err_logged; /* flag used to prevent excessive logging */ + char disconnect_err_logged; /* flag used to prevent + excessive disconnect + logging */ + char need_different_port; /* flag used to change the portmap path in case of 'tcp,rdma' on server */ @@ -100,7 +104,7 @@ typedef struct clnt_conf { uint16_t lk_version; /* this variable is used to distinguish client-server transaction while performing lock healing */ - struct timeval grace_tv; + struct timespec grace_ts; gf_timer_t *grace_timer; gf_boolean_t grace_timer_needed; /* The state of this flag will be used to decide whether diff --git a/xlators/protocol/server/src/Makefile.am b/xlators/protocol/server/src/Makefile.am index 25d6706cc..6a18bf025 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 ed3d75860..d4941011d 100644 --- a/xlators/protocol/server/src/server-handshake.c +++ b/xlators/protocol/server/src/server-handshake.c @@ -94,9 +94,9 @@ _volfile_update_checksum (xlator_t *this, char *key, uint32_t checksum) if (temp_volfile->checksum != checksum) { gf_log (this->name, GF_LOG_INFO, - "the volume file got modified between earlier access " - "and now, this may lead to inconsistency between " - "clients, advised to remount client"); + "the volume file was modified between a prior access " + "and now. This may lead to inconsistency between " + "clients, you are advised to remount client"); temp_volfile->checksum = checksum; } @@ -109,10 +109,10 @@ static size_t getspec_build_volfile_path (xlator_t *this, const char *key, char *path, size_t path_len) { - int ret = -1; + char *filename = NULL; + server_conf_t *conf = NULL; + int ret = -1; int free_filename = 0; - char *filename = NULL; - server_conf_t *conf = NULL; char data_key[256] = {0,}; conf = this->private; @@ -329,14 +329,15 @@ server_setvolume (rpcsvc_request_t *req) { gf_setvolume_req args = {{0,},}; gf_setvolume_rsp rsp = {0,}; - server_connection_t *conn = NULL; + client_t *client = NULL; + server_ctx_t *serv_ctx = NULL; server_conf_t *conf = NULL; peer_info_t *peerinfo = NULL; dict_t *reply = NULL; dict_t *config_params = NULL; dict_t *params = NULL; char *name = NULL; - char *process_uuid = NULL; + char *client_uid = NULL; char *clnt_version = NULL; xlator_t *xl = NULL; char *msg = NULL; @@ -393,7 +394,7 @@ server_setvolume (rpcsvc_request_t *req) params->extra_free = buf; buf = NULL; - ret = dict_get_str (params, "process-uuid", &process_uuid); + ret = dict_get_str (params, "process-uuid", &client_uid); if (ret < 0) { ret = dict_set_str (reply, "ERROR", "UUID not specified"); @@ -420,25 +421,32 @@ server_setvolume (rpcsvc_request_t *req) goto fail; } - conn = server_connection_get (this, process_uuid); - if (!conn) { + client = gf_client_get (this, &req->cred, client_uid); + if (client == NULL) { op_ret = -1; op_errno = ENOMEM; goto fail; } - gf_log (this->name, GF_LOG_DEBUG, "Connected to %s", conn->id); - cancelled = server_cancel_conn_timer (this, conn); - if (cancelled)//Do connection_put on behalf of grace-timer-handler. - server_connection_put (this, conn, NULL); - if (conn->lk_version != 0 && - conn->lk_version != lk_version) { - (void) server_connection_cleanup (this, conn, + 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); + + 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); } - if (req->trans->xl_private != conn) - req->trans->xl_private = conn; + if (req->trans->xl_private != client) + req->trans->xl_private = client; ret = dict_get_int32 (params, "fops-version", &fop_version); if (ret < 0) { @@ -563,10 +571,10 @@ server_setvolume (rpcsvc_request_t *req) gf_log (this->name, GF_LOG_INFO, "accepted client from %s (version: %s)", - conn->id, + client->client_uid, (clnt_version) ? clnt_version : "old"); op_ret = 0; - conn->bound_xl = xl; + client->bound_xl = xl; ret = dict_set_str (reply, "ERROR", "Success"); if (ret < 0) gf_log (this->name, GF_LOG_DEBUG, @@ -574,7 +582,7 @@ server_setvolume (rpcsvc_request_t *req) } else { gf_log (this->name, GF_LOG_ERROR, "Cannot authenticate client from %s %s", - conn->id, + client->client_uid, (clnt_version) ? clnt_version : "old"); op_ret = -1; @@ -586,7 +594,7 @@ server_setvolume (rpcsvc_request_t *req) goto fail; } - if (conn->bound_xl == NULL) { + if (client->bound_xl == NULL) { ret = dict_set_str (reply, "ERROR", "Check volfile and handshake " "options in protocol/client"); @@ -599,20 +607,21 @@ server_setvolume (rpcsvc_request_t *req) goto fail; } - if ((conn->bound_xl != NULL) && + if ((client->bound_xl != NULL) && (ret >= 0) && - (conn->bound_xl->itable == NULL)) { + (client->bound_xl->itable == NULL)) { /* create inode table for this bound_xl, if one doesn't already exist */ gf_log (this->name, GF_LOG_TRACE, "creating inode table with lru_limit=%"PRId32", " "xlator=%s", conf->inode_lru_limit, - conn->bound_xl->name); + client->bound_xl->name); /* TODO: what is this ? */ - conn->bound_xl->itable = inode_table_new (conf->inode_lru_limit, - conn->bound_xl); + client->bound_xl->itable = + inode_table_new (conf->inode_lru_limit, + client->bound_xl); } ret = dict_set_str (reply, "process-uuid", @@ -621,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", - conn->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'"); @@ -664,15 +672,15 @@ fail: * list of connections the server is maintaining and might segfault * during statedump when bound_xl of the connection is accessed. */ - if (op_ret && conn && !xl) { + if (op_ret && !xl) { /* We would have set the xl_private of the transport to the * @conn. But if we have put the connection i.e shutting down * the connection, then we should set xl_private to NULL as it * would be pointing to a freed memory and would segfault when * accessed upon getting DISCONNECT. */ - if (server_connection_put (this, conn, NULL) == NULL) - req->trans->xl_private = NULL; + gf_client_put (client, NULL); + req->trans->xl_private = NULL; } server_submit_reply (NULL, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gf_setvolume_rsp); @@ -709,12 +717,13 @@ server_ping (rpcsvc_request_t *req) int server_set_lk_version (rpcsvc_request_t *req) { - int op_ret = -1; - int op_errno = EINVAL; - gf_set_lk_ver_req args = {0, }; - gf_set_lk_ver_rsp rsp = {0,}; - server_connection_t *conn = NULL; - xlator_t *this = NULL; + int op_ret = -1; + int op_errno = EINVAL; + 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; //TODO: Decide on an appropriate errno for the error-path @@ -730,9 +739,15 @@ server_set_lk_version (rpcsvc_request_t *req) goto fail; } - conn = server_connection_get (this, args.uid); - conn->lk_version = args.lk_ver; - server_connection_put (this, conn, NULL); + client = gf_client_get (this, &req->cred, args.uid); + 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; @@ -749,11 +764,11 @@ fail: } rpcsvc_actor_t gluster_handshake_actors[] = { - [GF_HNDSK_NULL] = {"NULL", GF_HNDSK_NULL, server_null, NULL, 0}, - [GF_HNDSK_SETVOLUME] = {"SETVOLUME", GF_HNDSK_SETVOLUME, server_setvolume, NULL, 0}, - [GF_HNDSK_GETSPEC] = {"GETSPEC", GF_HNDSK_GETSPEC, server_getspec, NULL, 0}, - [GF_HNDSK_PING] = {"PING", GF_HNDSK_PING, server_ping, NULL, 0}, - [GF_HNDSK_SET_LK_VER] = {"SET_LK_VER", GF_HNDSK_SET_LK_VER, server_set_lk_version, NULL, 0}, + [GF_HNDSK_NULL] = {"NULL", GF_HNDSK_NULL, server_null, NULL, 0, DRC_NA}, + [GF_HNDSK_SETVOLUME] = {"SETVOLUME", GF_HNDSK_SETVOLUME, server_setvolume, NULL, 0, DRC_NA}, + [GF_HNDSK_GETSPEC] = {"GETSPEC", GF_HNDSK_GETSPEC, server_getspec, NULL, 0, DRC_NA}, + [GF_HNDSK_PING] = {"PING", GF_HNDSK_PING, server_ping, NULL, 0, DRC_NA}, + [GF_HNDSK_SET_LK_VER] = {"SET_LK_VER", GF_HNDSK_SET_LK_VER, server_set_lk_version, NULL, 0, DRC_NA}, }; diff --git a/xlators/protocol/server/src/server-helpers.c b/xlators/protocol/server/src/server-helpers.c index e2bbf4bcb..f0b040c74 100644 --- a/xlators/protocol/server/src/server-helpers.c +++ b/xlators/protocol/server/src/server-helpers.c @@ -26,6 +26,9 @@ server_decode_groups (call_frame_t *frame, rpcsvc_request_t *req) GF_VALIDATE_OR_GOTO ("server", frame, out); GF_VALIDATE_OR_GOTO ("server", req, out); + if (call_stack_alloc_groups (frame->root, req->auxgidcount) != 0) + return -1; + frame->root->ngrps = req->auxgidcount; if (frame->root->ngrps == 0) return 0; @@ -39,6 +42,7 @@ out: return 0; } + void server_loc_wipe (loc_t *loc) { @@ -70,11 +74,6 @@ server_resolve_wipe (server_resolve_t *resolve) void free_state (server_state_t *state) { - if (state->conn) { - //xprt_svc_unref (state->conn); - state->conn = NULL; - } - if (state->xprt) { rpc_transport_unref (state->xprt); state->xprt = NULL; @@ -123,301 +122,26 @@ free_state (server_state_t *state) } -int -gf_add_locker (server_connection_t *conn, const char *volume, - loc_t *loc, fd_t *fd, pid_t pid, gf_lkowner_t *owner, - glusterfs_fop_t type) -{ - int32_t ret = -1; - struct _locker *new = NULL; - struct _lock_table *table = NULL; - - GF_VALIDATE_OR_GOTO ("server", volume, out); - - new = GF_CALLOC (1, sizeof (struct _locker), gf_server_mt_locker_t); - if (new == NULL) { - goto out; - } - INIT_LIST_HEAD (&new->lockers); - - new->volume = gf_strdup (volume); - - if (fd == NULL) { - loc_copy (&new->loc, loc); - } else { - new->fd = fd_ref (fd); - } - - new->pid = pid; - new->owner = *owner; - - pthread_mutex_lock (&conn->lock); - { - table = conn->ltable; - if (type == GF_FOP_ENTRYLK) - list_add_tail (&new->lockers, &table->entrylk_lockers); - else - list_add_tail (&new->lockers, &table->inodelk_lockers); - } - pthread_mutex_unlock (&conn->lock); -out: - return ret; -} - - -int -gf_del_locker (server_connection_t *conn, const char *volume, - loc_t *loc, fd_t *fd, gf_lkowner_t *owner, - glusterfs_fop_t type) -{ - struct _locker *locker = NULL; - struct _locker *tmp = NULL; - int32_t ret = -1; - struct list_head *head = NULL; - struct _lock_table *table = NULL; - int found = 0; - - GF_VALIDATE_OR_GOTO ("server", volume, out); - - pthread_mutex_lock (&conn->lock); - { - table = conn->ltable; - if (type == GF_FOP_ENTRYLK) { - head = &table->entrylk_lockers; - } else { - head = &table->inodelk_lockers; - } - - list_for_each_entry_safe (locker, tmp, head, lockers) { - if (!is_same_lkowner (&locker->owner, owner) || - strcmp (locker->volume, volume)) - continue; - - if (locker->fd && fd && (locker->fd == fd)) - found = 1; - else if (locker->loc.inode && loc && - (locker->loc.inode == loc->inode)) - found = 1; - if (found) { - list_del_init (&locker->lockers); - break; - } - } - if (!found) - locker = NULL; - } - pthread_mutex_unlock (&conn->lock); - - if (locker) { - if (locker->fd) - fd_unref (locker->fd); - else - loc_wipe (&locker->loc); - - GF_FREE (locker->volume); - GF_FREE (locker); - } - - ret = 0; -out: - return ret; -} - -static struct _lock_table * -gf_lock_table_new (void) -{ - struct _lock_table *new = NULL; - - new = GF_CALLOC (1, sizeof (struct _lock_table), gf_server_mt_lock_table_t); - if (new == NULL) { - goto out; - } - INIT_LIST_HEAD (&new->entrylk_lockers); - INIT_LIST_HEAD (&new->inodelk_lockers); -out: - return new; -} - -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); - - if (frame->root->trans) - server_conn_unref (frame->root->trans); - state = CALL_STATE(frame); - - if (state) - free_state (state); - STACK_DESTROY (frame->root); - - ret = 0; -out: - return ret; -} - -int -do_lock_table_cleanup (xlator_t *this, server_connection_t *conn, - call_frame_t *frame, struct _lock_table *ltable) -{ - struct list_head inodelk_lockers, entrylk_lockers; - call_frame_t *tmp_frame = NULL; - struct gf_flock flock = {0, }; - xlator_t *bound_xl = NULL; - struct _locker *locker = NULL, *tmp = NULL; - int ret = -1; - char *path = NULL; - - GF_VALIDATE_OR_GOTO ("server", this, out); - GF_VALIDATE_OR_GOTO ("server", conn, out); - GF_VALIDATE_OR_GOTO ("server", frame, out); - GF_VALIDATE_OR_GOTO ("server", ltable, out); - - bound_xl = conn->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 = copy_frame (frame); - 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; - tmp_frame->root->trans = server_conn_ref (conn); - 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 = copy_frame (frame); - - tmp_frame->root->pid = 0; - tmp_frame->root->trans = server_conn_ref (conn); - memset (&tmp_frame->root->lk_owner, 0, sizeof (gf_lkowner_t)); - - if (locker->fd) { - GF_ASSERT (locker->fd->inode); - - ret = inode_path (locker->fd->inode, NULL, &path); - - if (ret > 0) { - gf_log (this->name, GF_LOG_INFO, "fentrylk " - "released on %s", path); - GF_FREE (path); - } else { - - gf_log (this->name, GF_LOG_INFO, "fentrylk " - "released on inode with gfid %s", - uuid_utoa (locker->fd->inode->gfid)); - } - - STACK_WIND (tmp_frame, server_nop_cbk, bound_xl, - bound_xl->fops->fentrylk, - locker->volume, - locker->fd, NULL, - ENTRYLK_UNLOCK, ENTRYLK_WRLCK, NULL); - fd_unref (locker->fd); - } else { - gf_log (this->name, GF_LOG_INFO, "entrylk released " - "on %s", locker->loc.path); - - STACK_WIND (tmp_frame, server_nop_cbk, bound_xl, - bound_xl->fops->entrylk, - locker->volume, - &(locker->loc), NULL, - ENTRYLK_UNLOCK, ENTRYLK_WRLCK, NULL); - loc_wipe (&locker->loc); - } - - GF_FREE (locker->volume); - - list_del_init (&locker->lockers); - GF_FREE (locker); - } - ret = 0; - -out: - return ret; -} - - static int server_connection_cleanup_flush_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, dict_t *xdata) { - int32_t ret = -1; - fd_t *fd = NULL; + int32_t ret = -1; + fd_t *fd = NULL; + client_t *client = NULL; GF_VALIDATE_OR_GOTO ("server", this, out); GF_VALIDATE_OR_GOTO ("server", cookie, out); GF_VALIDATE_OR_GOTO ("server", frame, out); fd = frame->local; + client = frame->root->client; fd_unref (fd); frame->local = NULL; - if (frame->root->trans) - server_conn_unref (frame->root->trans); + gf_client_unref (client); STACK_DESTROY (frame->root); ret = 0; @@ -426,9 +150,8 @@ out: } -int -do_fd_cleanup (xlator_t *this, server_connection_t *conn, call_frame_t *frame, - fdentry_t *fdentries, int fd_count) +static int +do_fd_cleanup (xlator_t *this, client_t* client, fdentry_t *fdentries, int fd_count) { fd_t *fd = NULL; int i = 0, ret = -1; @@ -437,16 +160,14 @@ do_fd_cleanup (xlator_t *this, server_connection_t *conn, call_frame_t *frame, char *path = NULL; GF_VALIDATE_OR_GOTO ("server", this, out); - GF_VALIDATE_OR_GOTO ("server", conn, out); - GF_VALIDATE_OR_GOTO ("server", frame, out); GF_VALIDATE_OR_GOTO ("server", fdentries, out); - bound_xl = conn->bound_xl; + bound_xl = client->bound_xl; for (i = 0;i < fd_count; i++) { fd = fdentries[i].fd; if (fd != NULL) { - tmp_frame = copy_frame (frame); + tmp_frame = create_frame (this, this->ctx->pool); if (tmp_frame == NULL) { goto out; } @@ -456,20 +177,20 @@ do_fd_cleanup (xlator_t *this, server_connection_t *conn, call_frame_t *frame, ret = inode_path (fd->inode, NULL, &path); if (ret > 0) { - gf_log (this->name, GF_LOG_INFO, "fd cleanup on " - "%s", path); + gf_log (this->name, GF_LOG_INFO, + "fd cleanup on %s", path); GF_FREE (path); } else { - gf_log (this->name, GF_LOG_INFO, "fd cleanup on" - " inode with gfid %s", + gf_log (this->name, GF_LOG_INFO, + "fd cleanup on inode with gfid %s", uuid_utoa (fd->inode->gfid)); } tmp_frame->local = fd; tmp_frame->root->pid = 0; - tmp_frame->root->trans = server_conn_ref (conn); + gf_client_ref (client); memset (&tmp_frame->root->lk_owner, 0, sizeof (gf_lkowner_t)); @@ -486,268 +207,72 @@ out: return ret; } -int -do_connection_cleanup (xlator_t *this, server_connection_t *conn, - struct _lock_table *ltable, fdentry_t *fdentries, int fd_count) -{ - int ret = 0; - int saved_ret = 0; - call_frame_t *frame = NULL; - server_state_t *state = NULL; - - GF_VALIDATE_OR_GOTO ("server", this, out); - GF_VALIDATE_OR_GOTO ("server", conn, out); - - if (!ltable && !fdentries) - goto out; - - frame = create_frame (this, this->ctx->pool); - if (frame == NULL) { - goto out; - } - - if (ltable) - saved_ret = do_lock_table_cleanup (this, conn, frame, ltable); - - if (fdentries != NULL) { - ret = do_fd_cleanup (this, conn, frame, fdentries, fd_count); - } - - state = CALL_STATE (frame); - GF_FREE (state); - - STACK_DESTROY (frame->root); - - if (saved_ret || ret) { - ret = -1; - } - -out: - return ret; -} - int -server_connection_cleanup (xlator_t *this, server_connection_t *conn, +server_connection_cleanup (xlator_t *this, client_t *client, int32_t flags) { - struct _lock_table *ltable = NULL; - fdentry_t *fdentries = NULL; - uint32_t fd_count = 0; - int ret = 0; + 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, conn, out); + GF_VALIDATE_OR_GOTO (this->name, client, out); GF_VALIDATE_OR_GOTO (this->name, flags, out); - pthread_mutex_lock (&conn->lock); - { - if (conn->ltable && (flags & INTERNAL_LOCKS)) { - ltable = conn->ltable; - conn->ltable = gf_lock_table_new (); - } - - if (conn->fdtable && (flags & POSIX_LOCKS)) - fdentries = gf_fd_fdtable_get_all_fds (conn->fdtable, - &fd_count); - } - pthread_mutex_unlock (&conn->lock); - - if (conn->bound_xl) - ret = do_connection_cleanup (this, conn, ltable, - fdentries, fd_count); - -out: - return ret; -} - + serv_ctx = server_ctx_get (client, client->this); -int -server_connection_destroy (xlator_t *this, server_connection_t *conn) -{ - xlator_t *bound_xl = NULL; - int32_t ret = -1; - struct list_head inodelk_lockers; - struct list_head entrylk_lockers; - struct _lock_table *ltable = NULL; - fdtable_t *fdtable = NULL; - - GF_VALIDATE_OR_GOTO ("server", this, out); - GF_VALIDATE_OR_GOTO ("server", conn, out); - - bound_xl = (xlator_t *) (conn->bound_xl); - - if (bound_xl) { - pthread_mutex_lock (&(conn->lock)); - { - if (conn->ltable) { - ltable = conn->ltable; - conn->ltable = NULL; - } - if (conn->fdtable) { - fdtable = conn->fdtable; - conn->fdtable = NULL; - } - } - pthread_mutex_unlock (&conn->lock); - - INIT_LIST_HEAD (&inodelk_lockers); - INIT_LIST_HEAD (&entrylk_lockers); - - if (ltable) { - list_splice_init (<able->inodelk_lockers, - &inodelk_lockers); - - list_splice_init (<able->entrylk_lockers, - &entrylk_lockers); - GF_FREE (ltable); - } - - GF_ASSERT (list_empty (&inodelk_lockers)); - GF_ASSERT (list_empty (&entrylk_lockers)); - - if (fdtable) - gf_fd_fdtable_destroy (fdtable); + if (serv_ctx == NULL) { + gf_log (this->name, GF_LOG_INFO, "server_ctx_get() failed"); + goto out; } - gf_log (this->name, GF_LOG_INFO, "destroyed connection of %s", - conn->id); - - pthread_mutex_destroy (&conn->lock); - GF_FREE (conn->id); - GF_FREE (conn); - ret = 0; -out: - return ret; -} - -server_connection_t* -server_conn_unref (server_connection_t *conn) -{ - server_connection_t *todel = NULL; - xlator_t *this = NULL; - - pthread_mutex_lock (&conn->lock); + LOCK (&serv_ctx->fdtable_lock); { - conn->ref--; - - if (!conn->ref) { - todel = conn; - } + if (serv_ctx->fdtable && (flags & POSIX_LOCKS)) + fdentries = gf_fd_fdtable_get_all_fds (serv_ctx->fdtable, + &fd_count); } - pthread_mutex_unlock (&conn->lock); + UNLOCK (&serv_ctx->fdtable_lock); - if (todel) { - this = THIS; - server_connection_destroy (this, todel); - conn = NULL; - } - return conn; -} + if (client->bound_xl == NULL) + goto out; -server_connection_t* -server_conn_ref (server_connection_t *conn) -{ - pthread_mutex_lock (&conn->lock); - { - conn->ref++; + if (flags & INTERNAL_LOCKS) { + cd_ret = gf_client_disconnect (client); } - pthread_mutex_unlock (&conn->lock); - - return conn; -} -server_connection_t * -server_connection_get (xlator_t *this, const char *id) -{ - server_connection_t *conn = NULL; - server_connection_t *trav = NULL; - server_conf_t *conf = NULL; - - GF_VALIDATE_OR_GOTO ("server", this, out); - GF_VALIDATE_OR_GOTO ("server", id, out); + if (fdentries != NULL) + ret = do_fd_cleanup (this, client, fdentries, fd_count); + else + gf_log (this->name, GF_LOG_INFO, "no fdentries to clean"); - conf = this->private; - - pthread_mutex_lock (&conf->mutex); - { - list_for_each_entry (trav, &conf->conns, list) { - if (!strcmp (trav->id, id)) { - conn = trav; - conn->bind_ref++; - goto unlock; - } - } - - conn = (void *) GF_CALLOC (1, sizeof (*conn), - gf_server_mt_conn_t); - if (!conn) - goto unlock; - - conn->id = gf_strdup (id); - /*'0' denotes uninitialised lock state*/ - conn->lk_version = 0; - conn->fdtable = gf_fd_fdtable_alloc (); - conn->ltable = gf_lock_table_new (); - conn->this = this; - conn->bind_ref = 1; - conn->ref = 1;//when bind_ref becomes 0 it calls conn_unref - pthread_mutex_init (&conn->lock, NULL); - list_add (&conn->list, &conf->conns); + if (cd_ret || ret) + ret = -1; - } -unlock: - pthread_mutex_unlock (&conf->mutex); out: - return conn; + return ret; } -server_connection_t* -server_connection_put (xlator_t *this, server_connection_t *conn, - gf_boolean_t *detached) -{ - server_conf_t *conf = NULL; - gf_boolean_t unref = _gf_false; - - if (detached) - *detached = _gf_false; - conf = this->private; - pthread_mutex_lock (&conf->mutex); - { - conn->bind_ref--; - if (!conn->bind_ref) { - list_del_init (&conn->list); - unref = _gf_true; - } - } - pthread_mutex_unlock (&conf->mutex); - if (unref) { - gf_log (this->name, GF_LOG_INFO, "Shutting down connection %s", - conn->id); - if (detached) - *detached = _gf_true; - server_conn_unref (conn); - conn = NULL; - } - return conn; -} static call_frame_t * server_alloc_frame (rpcsvc_request_t *req) { - call_frame_t *frame = NULL; - server_state_t *state = NULL; - server_connection_t *conn = NULL; + call_frame_t *frame = NULL; + server_state_t *state = NULL; + client_t *client = NULL; GF_VALIDATE_OR_GOTO ("server", req, out); GF_VALIDATE_OR_GOTO ("server", req->trans, out); GF_VALIDATE_OR_GOTO ("server", req->svc, out); GF_VALIDATE_OR_GOTO ("server", req->svc->ctx, out); - conn = (server_connection_t *)req->trans->xl_private; - GF_VALIDATE_OR_GOTO ("server", conn, out); + client = req->trans->xl_private; + GF_VALIDATE_OR_GOTO ("server", client, out); - frame = create_frame (conn->this, req->svc->ctx->pool); + frame = create_frame (client->this, req->svc->ctx->pool); if (!frame) goto out; @@ -755,45 +280,46 @@ server_alloc_frame (rpcsvc_request_t *req) if (!state) goto out; - if (conn->bound_xl) - state->itable = conn->bound_xl->itable; + if (client->bound_xl) + state->itable = client->bound_xl->itable; state->xprt = rpc_transport_ref (req->trans); - state->conn = conn; - 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 */ - frame->this = conn->this; + frame->this = client->this; out: return frame; } - call_frame_t * get_frame_from_request (rpcsvc_request_t *req) { - call_frame_t *frame = NULL; + call_frame_t *frame = NULL; + client_t *client = NULL; GF_VALIDATE_OR_GOTO ("server", req, out); + client = req->trans->xl_private; + frame = server_alloc_frame (req); if (!frame) goto out; frame->root->op = req->procnum; - frame->root->type = req->type; frame->root->unique = req->xid; frame->root->uid = req->uid; frame->root->gid = req->gid; frame->root->pid = req->pid; - frame->root->trans = server_conn_ref (req->trans->xl_private); + gf_client_ref (client); + frame->root->client = client; frame->root->lk_owner = req->lk_owner; server_decode_groups (frame, req); @@ -878,84 +404,6 @@ out: return ret; } -void -put_server_conn_state (xlator_t *this, rpc_transport_t *xprt) -{ - GF_VALIDATE_OR_GOTO ("server", this, out); - GF_VALIDATE_OR_GOTO ("server", xprt, out); - - xprt->xl_private = NULL; -out: - return; -} - -server_connection_t * -get_server_conn_state (xlator_t *this, rpc_transport_t *xprt) -{ - GF_VALIDATE_OR_GOTO ("server", this, out); - GF_VALIDATE_OR_GOTO ("server", xprt, out); - - return (server_connection_t *)xprt->xl_private; -out: - return NULL; -} - -server_connection_t * -create_server_conn_state (xlator_t *this, rpc_transport_t *xprt) -{ - server_connection_t *conn = NULL; - int ret = -1; - - GF_VALIDATE_OR_GOTO ("server", this, out); - GF_VALIDATE_OR_GOTO ("server", xprt, out); - - conn = GF_CALLOC (1, sizeof (*conn), gf_server_mt_conn_t); - if (!conn) - goto out; - - pthread_mutex_init (&conn->lock, NULL); - - conn->fdtable = gf_fd_fdtable_alloc (); - if (!conn->fdtable) - goto out; - - conn->ltable = gf_lock_table_new (); - if (!conn->ltable) - goto out; - - conn->this = this; - - xprt->xl_private = conn; - - ret = 0; -out: - if (ret) - destroy_server_conn_state (conn); - - return conn; -} - -void -destroy_server_conn_state (server_connection_t *conn) -{ - GF_VALIDATE_OR_GOTO ("server", conn, out); - - if (conn->ltable) { - /* TODO */ - //FREE (conn->ltable); - ; - } - - if (conn->fdtable) - gf_fd_fdtable_destroy (conn->fdtable); - - pthread_mutex_destroy (&conn->lock); - - GF_FREE (conn); -out: - return; -} - void print_caller (char *str, int size, call_frame_t *frame) @@ -1082,12 +530,15 @@ 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->conn->bound_xl->name); + "bound_xl=%s}", state->client->bound_xl->name); +*/ out: return; } + int server_resolve_is_empty (server_resolve_t *resolve) { @@ -1103,6 +554,7 @@ server_resolve_is_empty (server_resolve_t *resolve) return 1; } + void server_print_reply (call_frame_t *frame, int op_ret, int op_errno) { @@ -1148,16 +600,16 @@ out: void server_print_request (call_frame_t *frame) { - server_conf_t *conf = NULL; - xlator_t *this = NULL; + server_conf_t *conf = NULL; + xlator_t *this = NULL; server_state_t *state = NULL; + char *op = "UNKNOWN"; char resolve_vars[256]; char resolve2_vars[256]; char loc_vars[256]; char loc2_vars[256]; char other_vars[512]; char caller[512]; - char *op = "UNKNOWN"; GF_VALIDATE_OR_GOTO ("server", frame, out); @@ -1208,13 +660,14 @@ out: return; } + int serialize_rsp_direntp (gf_dirent_t *entries, gfs3_readdirp_rsp *rsp) { gf_dirent_t *entry = NULL; - gfs3_dirplist *trav = NULL; - gfs3_dirplist *prev = NULL; - int ret = -1; + gfs3_dirplist *trav = NULL; + gfs3_dirplist *prev = NULL; + int ret = -1; GF_VALIDATE_OR_GOTO ("server", entries, out); GF_VALIDATE_OR_GOTO ("server", rsp, out); @@ -1282,10 +735,10 @@ out: int serialize_rsp_dirent (gf_dirent_t *entries, gfs3_readdir_rsp *rsp) { - gf_dirent_t *entry = NULL; - gfs3_dirlist *trav = NULL; - gfs3_dirlist *prev = NULL; - int ret = -1; + gf_dirent_t *entry = NULL; + gfs3_dirlist *trav = NULL; + gfs3_dirlist *prev = NULL; + int ret = -1; GF_VALIDATE_OR_GOTO ("server", entries, out); GF_VALIDATE_OR_GOTO ("server", rsp, out); @@ -1312,11 +765,12 @@ out: return ret; } + int readdir_rsp_cleanup (gfs3_readdir_rsp *rsp) { - gfs3_dirlist *prev = NULL; - gfs3_dirlist *trav = NULL; + gfs3_dirlist *prev = NULL; + gfs3_dirlist *trav = NULL; trav = rsp->reply; prev = trav; @@ -1329,6 +783,7 @@ readdir_rsp_cleanup (gfs3_readdir_rsp *rsp) return 0; } + int readdirp_rsp_cleanup (gfs3_readdirp_rsp *rsp) { @@ -1347,6 +802,7 @@ readdirp_rsp_cleanup (gfs3_readdirp_rsp *rsp) return 0; } + int gf_server_check_getxattr_cmd (call_frame_t *frame, const char *key) { @@ -1375,13 +831,14 @@ gf_server_check_getxattr_cmd (call_frame_t *frame, const char *key) return 0; } + int gf_server_check_setxattr_cmd (call_frame_t *frame, dict_t *dict) { - server_conf_t *conf = NULL; - rpc_transport_t *xprt = NULL; - uint64_t total_read = 0; + server_conf_t *conf = NULL; + rpc_transport_t *xprt = NULL; + uint64_t total_read = 0; uint64_t total_write = 0; conf = frame->this->private; @@ -1402,32 +859,403 @@ gf_server_check_setxattr_cmd (call_frame_t *frame, dict_t *dict) return 0; } + gf_boolean_t -server_cancel_conn_timer (xlator_t *this, server_connection_t *conn) +server_cancel_grace_timer (xlator_t *this, client_t *client) { - gf_timer_t *timer = NULL; - gf_boolean_t cancelled = _gf_false; + server_ctx_t *serv_ctx = NULL; + gf_timer_t *timer = NULL; + gf_boolean_t cancelled = _gf_false; - if (!this || !conn) { - gf_log (THIS->name, GF_LOG_ERROR, "Invalid arguments to " - "cancel connection timer"); + if (!this || !client) { + gf_log (THIS->name, GF_LOG_ERROR, + "Invalid arguments to cancel connection timer"); return cancelled; } - pthread_mutex_lock (&conn->lock); - { - if (!conn->timer) - goto unlock; + serv_ctx = server_ctx_get (client, client->this); - timer = conn->timer; - conn->timer = NULL; + if (serv_ctx == NULL) { + gf_log (this->name, GF_LOG_INFO, "server_ctx_get() failed"); + goto out; } -unlock: - pthread_mutex_unlock (&conn->lock); + + LOCK (&serv_ctx->fdtable_lock); + { + if (serv_ctx->grace_timer) { + timer = serv_ctx->grace_timer; + serv_ctx->grace_timer = NULL; + } + } + 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; +} + +int32_t +gf_barrier_transmit (server_conf_t *conf, gf_barrier_payload_t *payload) +{ + gf_barrier_t *barrier = NULL; + int32_t ret = -1; + client_t *client = NULL; + gf_boolean_t lk_heal = _gf_false; + call_frame_t *frame = NULL; + server_state_t *state = NULL; + + GF_VALIDATE_OR_GOTO ("barrier", conf, out); + GF_VALIDATE_OR_GOTO ("barrier", conf->barrier, out); + GF_VALIDATE_OR_GOTO ("barrier", payload, out); + + barrier = conf->barrier; + + frame = payload->frame; + if (frame) { + state = CALL_STATE (frame); + frame->local = NULL; + client = frame->root->client; + } + /* currently lk fops are not barrier'ed. This is reflecting code in + * server_submit_reply */ + if (client) + lk_heal = ((server_conf_t *) client->this->private)->lk_heal; + + ret = rpcsvc_submit_generic (payload->req, &payload->rsp, 1, + payload->payload, payload->payload_count, + payload->iobref); + iobuf_unref (payload->iob); + if (ret == -1) { + gf_log_callingfn ("", GF_LOG_ERROR, "Reply submission failed"); + if (frame && client && !lk_heal) { + server_connection_cleanup (frame->this, client, + INTERNAL_LOCKS | POSIX_LOCKS); + } else { + /* TODO: Failure of open(dir), create, inodelk, entrylk + or lk fops send failure must be handled specially. */ + } + goto ret; + } + + ret = 0; +ret: + if (state) { + free_state (state); + } + + if (frame) { + gf_client_unref (client); + STACK_DESTROY (frame->root); + } + + if (payload->free_iobref) { + iobref_unref (payload->iobref); + } +out: + return ret; +} + +gf_barrier_payload_t * +gf_barrier_dequeue (gf_barrier_t *barrier) +{ + gf_barrier_payload_t *payload = NULL; + + if (!barrier || list_empty (&barrier->queue)) + return NULL; + + payload = list_entry (barrier->queue.next, + gf_barrier_payload_t, list); + if (payload) { + list_del_init (&payload->list); + barrier->cur_size--; + } + + return payload; +} + + +void* +gf_barrier_dequeue_start (void *data) +{ + server_conf_t *conf = NULL; + gf_barrier_t *barrier = NULL; + gf_barrier_payload_t *payload = NULL; + + conf = (server_conf_t *)data; + if (!conf || !conf->barrier) + return NULL; + barrier = conf->barrier; + + LOCK (&barrier->lock); + { + while (barrier->cur_size) { + payload = gf_barrier_dequeue (barrier); + if (payload) { + if (gf_barrier_transmit (conf, payload)) { + gf_log ("server", GF_LOG_WARNING, + "Failed to transmit"); + } + GF_FREE (payload); + } + } + } + UNLOCK (&barrier->lock); + return NULL; +} + +void +gf_barrier_timeout (void *data) +{ + server_conf_t *conf = NULL; + gf_barrier_t *barrier = NULL; + gf_boolean_t need_dequeue = _gf_false; + + conf = (server_conf_t *)data; + if (!conf || !conf->barrier) + goto out; + barrier = conf->barrier; + + gf_log ("", GF_LOG_INFO, "barrier timed-out"); + LOCK (&barrier->lock); + { + need_dequeue = barrier->on; + barrier->on = _gf_false; + } + UNLOCK (&barrier->lock); + + if (need_dequeue == _gf_true) + gf_barrier_dequeue_start (data); +out: + return; +} + + +int32_t +gf_barrier_start (xlator_t *this) +{ + server_conf_t *conf = NULL; + gf_barrier_t *barrier = NULL; + int32_t ret = -1; + struct timespec time = {0,}; + + conf = this->private; + + GF_VALIDATE_OR_GOTO ("server", this, out); + GF_VALIDATE_OR_GOTO (this->name, conf, out); + GF_VALIDATE_OR_GOTO (this->name, conf->barrier, out); + + barrier = conf->barrier; + + gf_log (this->name, GF_LOG_INFO, "barrier start called"); + LOCK (&barrier->lock); + { + /* if barrier is on, reset timer */ + if (barrier->on == _gf_true) { + ret = gf_timer_call_cancel (this->ctx, barrier->timer); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, "Failed to " + "unset timer, failing barrier start"); + goto unlock; + } + } + + barrier->on = _gf_true; + time.tv_sec = barrier->time_out; + time.tv_nsec = 0; + + barrier->timer = gf_timer_call_after (this->ctx, time, + gf_barrier_timeout, + (void *)conf); + if (!barrier->timer) { + gf_log (this->name, GF_LOG_ERROR, "Failed to set " + "timer, failing barrier start"); + barrier->on = _gf_false; + } + } +unlock: + UNLOCK (&barrier->lock); + + ret = 0; +out: + return ret; +} + +int32_t +gf_barrier_stop (xlator_t *this) +{ + server_conf_t *conf = NULL; + gf_barrier_t *barrier = NULL; + int32_t ret = -1; + gf_boolean_t need_dequeue = _gf_false; + + conf = this->private; + + GF_VALIDATE_OR_GOTO ("server", this, out); + GF_VALIDATE_OR_GOTO (this->name, conf, out); + GF_VALIDATE_OR_GOTO (this->name, conf->barrier, out); + + barrier = conf->barrier; + + gf_log (this->name, GF_LOG_INFO, "barrier stop called"); + LOCK (&barrier->lock); + { + need_dequeue = barrier->on; + barrier->on = _gf_false; + } + UNLOCK (&barrier->lock); + + if (need_dequeue == _gf_true) { + gf_timer_call_cancel (this->ctx, barrier->timer); + ret = gf_thread_create (&conf->barrier_th, NULL, + gf_barrier_dequeue_start, + conf); + if (ret) { + gf_log (this->name, GF_LOG_CRITICAL, + "Failed to start un-barriering"); + goto out; + } + } + ret = 0; +out: + return ret; +} + +int32_t +gf_barrier_fops_configure (xlator_t *this, gf_barrier_t *barrier, char *str) +{ + int32_t ret = -1; + char *dup_str = NULL; + char *str_tok = NULL; + char *save_ptr = NULL; + uint64_t fops = 0; + + /* by defaul fsync & flush needs to be barriered */ + + fops |= 1 << GFS3_OP_FSYNC; + fops |= 1 << GFS3_OP_FLUSH; + + if (!str) + goto done; + + dup_str = gf_strdup (str); + if (!dup_str) + goto done; + + str_tok = strtok_r (dup_str, ",", &save_ptr); + if (!str_tok) + goto done; + + fops = 0; + while (str_tok) { + if (!strcmp(str_tok, "writev")) { + fops |= ((uint64_t)1 << GFS3_OP_WRITE); + } else if (!strcmp(str_tok, "fsync")) { + fops |= ((uint64_t)1 << GFS3_OP_FSYNC); + } else if (!strcmp(str_tok, "read")) { + fops |= ((uint64_t)1 << GFS3_OP_READ); + } else if (!strcmp(str_tok, "rename")) { + fops |= ((uint64_t)1 << GFS3_OP_RENAME); + } else if (!strcmp(str_tok, "flush")) { + fops |= ((uint64_t)1 << GFS3_OP_FLUSH); + } else if (!strcmp(str_tok, "ftruncate")) { + fops |= ((uint64_t)1 << GFS3_OP_FTRUNCATE); + } else if (!strcmp(str_tok, "fallocate")) { + fops |= ((uint64_t)1 << GFS3_OP_FALLOCATE); + } else if (!strcmp(str_tok, "rmdir")) { + fops |= ((uint64_t)1 << GFS3_OP_RMDIR); + } else { + gf_log ("barrier", GF_LOG_ERROR, + "Invalid barrier fop %s", str_tok); + } + + str_tok = strtok_r (NULL, ",", &save_ptr); + } +done: + LOCK (&barrier->lock); + { + barrier->fops = fops; + } + UNLOCK (&barrier->lock); + ret = 0; + + GF_FREE (dup_str); + return ret; +} + +void +gf_barrier_enqueue (gf_barrier_t *barrier, gf_barrier_payload_t *payload) +{ + list_add_tail (&payload->list, &barrier->queue); + barrier->cur_size++; +} + +gf_barrier_payload_t * +gf_barrier_payload (rpcsvc_request_t *req, struct iovec *rsp, + call_frame_t *frame, struct iovec *payload_orig, + int payloadcount, struct iobref *iobref, + struct iobuf *iob, gf_boolean_t free_iobref) +{ + gf_barrier_payload_t *payload = NULL; + + if (!rsp) + return NULL; + + payload = GF_CALLOC (1, sizeof (*payload),1); + if (!payload) + return NULL; + + INIT_LIST_HEAD (&payload->list); + + payload->req = req; + memcpy (&payload->rsp, rsp, sizeof (struct iovec)); + payload->frame = frame; + payload->payload = payload_orig; + payload->payload_count = payloadcount; + payload->iobref = iobref; + payload->iob = iob; + payload->free_iobref = free_iobref; + + return payload; +} diff --git a/xlators/protocol/server/src/server-helpers.h b/xlators/protocol/server/src/server-helpers.h index 0b7424bab..b455aa6df 100644 --- a/xlators/protocol/server/src/server-helpers.h +++ b/xlators/protocol/server/src/server-helpers.h @@ -15,13 +15,8 @@ #define CALL_STATE(frame) ((server_state_t *)frame->root->state) -#define BOUND_XL(frame) ((xlator_t *) CALL_STATE(frame)->conn->bound_xl) - #define XPRT_FROM_FRAME(frame) ((rpc_transport_t *) CALL_STATE(frame)->xprt) -#define SERVER_CONNECTION(frame) \ - ((server_connection_t *) CALL_STATE(frame)->conn) - #define SERVER_CONF(frame) \ ((server_conf_t *)XPRT_FROM_FRAME(frame)->this->private) @@ -34,45 +29,26 @@ #define IS_NOT_ROOT(pathlen) ((pathlen > 2)? 1 : 0) +#define is_fop_barriered(fops, procnum) (fops & ((uint64_t)1 << procnum)) + +#define barrier_add_to_queue(barrier) (barrier->on || barrier->cur_size) + void free_state (server_state_t *state); void server_loc_wipe (loc_t *loc); -int32_t -gf_add_locker (server_connection_t *conn, const char *volume, - loc_t *loc, - fd_t *fd, - pid_t pid, - gf_lkowner_t *owner, - glusterfs_fop_t type); - -int32_t -gf_del_locker (server_connection_t *conn, const char *volume, - loc_t *loc, - fd_t *fd, - gf_lkowner_t *owner, - glusterfs_fop_t type); - void server_print_request (call_frame_t *frame); call_frame_t * get_frame_from_request (rpcsvc_request_t *req); -gf_boolean_t -server_cancel_conn_timer (xlator_t *this, server_connection_t *conn); - -void -put_server_conn_state (xlator_t *this, rpc_transport_t *xprt); - -server_connection_t * -get_server_conn_state (xlator_t *this, rpc_transport_t *xptr); - -server_connection_t * -create_server_conn_state (xlator_t *this, rpc_transport_t *xptr); +int +server_connection_cleanup (xlator_t *this, struct _client_t *client, + int32_t flags); -void -destroy_server_conn_state (server_connection_t *conn); +gf_boolean_t +server_cancel_grace_timer (xlator_t *this, struct _client_t *client); int server_build_config (xlator_t *this, server_conf_t *conf); @@ -82,4 +58,17 @@ 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); + +int32_t gf_barrier_start (xlator_t *this); +int32_t gf_barrier_stop (xlator_t *this); +int32_t gf_barrier_fops_configure (xlator_t *this, gf_barrier_t *barrier, + char *str); +void gf_barrier_enqueue (gf_barrier_t *barrier, gf_barrier_payload_t *stub); +gf_barrier_payload_t * +gf_barrier_payload (rpcsvc_request_t *req, struct iovec *rsp, + call_frame_t *frame, struct iovec *payload, + int payloadcount, struct iobref *iobref, + struct iobuf *iob, gf_boolean_t free_iobref); + #endif /* !_SERVER_HELPERS_H */ diff --git a/xlators/protocol/server/src/server-resolve.c b/xlators/protocol/server/src/server-resolve.c index 4a91a4104..cc4686a03 100644 --- a/xlators/protocol/server/src/server-resolve.c +++ b/xlators/protocol/server/src/server-resolve.c @@ -147,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: @@ -179,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; } @@ -449,14 +451,14 @@ 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; - server_connection_t *conn = 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; - conn = SERVER_CONNECTION (frame); fd_no = resolve->fd_no; @@ -465,7 +467,18 @@ server_resolve_fd (call_frame_t *frame) return 0; } - state->fd = gf_fd_fdptr_get (conn->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"); @@ -520,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 a9d2ee5b6..138e601ce 100644 --- a/xlators/protocol/server/src/server-rpc-fops.c +++ b/xlators/protocol/server/src/server-rpc-fops.c @@ -24,6 +24,11 @@ #include "xdr-nfs3.h" +#define SERVER_REQ_SET_ERROR(req, ret) \ + do { \ + rpcsvc_request_seterr (req, GARBAGE_ARGS); \ + ret = RPCSVC_ACTOR_ERROR; \ + } while (0) /* Callback function section */ int @@ -31,17 +36,14 @@ server_statfs_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct statvfs *buf, dict_t *xdata) { - gfs3_statfs_rsp rsp = {0,}; - rpcsvc_request_t *req = NULL; - - req = frame->local; + gfs3_statfs_rsp rsp = {0,}; + 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); if (op_ret < 0) { - gf_log (this->name, GF_LOG_WARNING, - "%"PRId64": STATFS (%s)", + gf_log (this->name, GF_LOG_WARNING, "%"PRId64": STATFS (%s)", frame->root->unique, strerror (op_errno)); goto out; } @@ -52,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); @@ -67,16 +69,15 @@ server_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, inode_t *inode, struct iatt *stbuf, dict_t *xdata, struct iatt *postparent) { - rpcsvc_request_t *req = NULL; - server_state_t *state = NULL; - inode_t *root_inode = NULL; - inode_t *link_inode = NULL; - loc_t fresh_loc = {0,}; - gfs3_lookup_rsp rsp = {0,}; - uuid_t rootgfid = {0,}; + rpcsvc_request_t *req = NULL; + server_state_t *state = NULL; + inode_t *root_inode = NULL; + inode_t *link_inode = NULL; + loc_t fresh_loc = {0,}; + 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; @@ -84,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); @@ -94,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) { @@ -108,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; @@ -137,8 +139,9 @@ out: if (state->resolve.bname) { gf_log (this->name, ((op_errno == ENOENT) ? GF_LOG_TRACE : GF_LOG_INFO), - "%"PRId64": LOOKUP %s (%s/%s) ==> (%s)", - frame->root->unique, state->loc.path, + "%"PRId64": LOOKUP %s (%s/%s) ==> " + "(%s)", frame->root->unique, + state->loc.path, uuid_utoa (state->resolve.pargfid), state->resolve.bname, strerror (op_errno)); @@ -152,6 +155,7 @@ out: } } + req = frame->local; server_submit_reply (frame, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_lookup_rsp); @@ -166,21 +170,20 @@ server_lk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct gf_flock *lock, dict_t *xdata) { - gfs3_lk_rsp rsp = {0,}; - rpcsvc_request_t *req = NULL; - server_state_t *state = NULL; - - req = frame->local; - state = CALL_STATE(frame); + gfs3_lk_rsp rsp = {0,}; + rpcsvc_request_t *req = NULL; + server_state_t *state = 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); 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, state->resolve.fd_no, + "%"PRId64": LK %"PRId64" (%s) ==> " + "(%s)", frame->root->unique, + state->resolve.fd_no, uuid_utoa (state->resolve.gfid), strerror (op_errno)); } @@ -209,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); @@ -222,21 +226,19 @@ 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_connection_t *conn = NULL; - 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; - conn = SERVER_CONNECTION(frame); - 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, + gf_log (this->name, (op_errno == ENOENT)? + GF_LOG_DEBUG:GF_LOG_ERROR, "%"PRId64": INODELK %s (%s) ==> (%s)", frame->root->unique, state->loc.path, uuid_utoa (state->resolve.gfid), @@ -245,20 +247,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 (conn, state->volume, - &state->loc, NULL, &frame->root->lk_owner, - GF_FOP_INODELK); - else - gf_add_locker (conn, 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); @@ -272,43 +265,32 @@ 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; - server_connection_t *conn = NULL; - rpcsvc_request_t *req = NULL; + gf_common_rsp rsp = {0,}; + server_state_t *state = NULL; + rpcsvc_request_t *req = NULL; - req = frame->local; - conn = SERVER_CONNECTION(frame); - 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, - "%"PRId64": FINODELK %"PRId64" (%s) ==> (%s)", - frame->root->unique, state->resolve.fd_no, + "%"PRId64": FINODELK %"PRId64" (%s) " + "==> (%s)", frame->root->unique, + state->resolve.fd_no, uuid_utoa (state->resolve.gfid), strerror (op_errno)); } goto out; } - if (state->flock.l_type == F_UNLCK) - gf_del_locker (conn, state->volume, - NULL, state->fd, - &frame->root->lk_owner, GF_FOP_INODELK); - else - gf_add_locker (conn, 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); @@ -321,18 +303,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_connection_t *conn = NULL; - server_state_t *state = NULL; - rpcsvc_request_t *req = NULL; - gf_common_rsp rsp = {0,}; - - req = frame->local; - conn = SERVER_CONNECTION(frame); - 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, @@ -344,20 +323,11 @@ server_entrylk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, goto out; } - if (state->cmd == ENTRYLK_UNLOCK) - gf_del_locker (conn, state->volume, - &state->loc, NULL, &frame->root->lk_owner, - GF_FOP_ENTRYLK); - else - gf_add_locker (conn, 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); @@ -371,18 +341,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_connection_t *conn = NULL; - server_state_t *state = NULL; - rpcsvc_request_t *req = NULL; - - req = frame->local; - conn = SERVER_CONNECTION(frame); - 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, @@ -394,19 +361,11 @@ server_fentrylk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, goto out; } - if (state->cmd == ENTRYLK_UNLOCK) - gf_del_locker (conn, state->volume, - NULL, state->fd, &frame->root->lk_owner, - GF_FOP_ENTRYLK); - else - gf_add_locker (conn, 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); @@ -420,17 +379,15 @@ int server_access_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,}; - rpcsvc_request_t *req = NULL; - server_state_t *state = NULL; - - req = frame->local; - state = CALL_STATE(frame); + gf_common_rsp rsp = {0,}; + rpcsvc_request_t *req = NULL; + server_state_t *state = 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); 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, @@ -443,6 +400,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); @@ -456,17 +414,16 @@ server_rmdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct iatt *preparent, struct iatt *postparent, dict_t *xdata) { - gfs3_rmdir_rsp rsp = {0,}; - server_state_t *state = NULL; - inode_t *parent = NULL; - rpcsvc_request_t *req = NULL; - - req = frame->local; - state = CALL_STATE(frame); + gfs3_rmdir_rsp rsp = {0,}; + server_state_t *state = NULL; + inode_t *parent = 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) { gf_log (this->name, GF_LOG_INFO, "%"PRId64": RMDIR %s (%s/%s) ==> (%s)", @@ -495,6 +452,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); @@ -509,17 +467,16 @@ server_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, struct iatt *stbuf, struct iatt *preparent, struct iatt *postparent, dict_t *xdata) { - gfs3_mkdir_rsp rsp = {0,}; - server_state_t *state = NULL; - inode_t *link_inode = NULL; - rpcsvc_request_t *req = NULL; - - req = frame->local; - state = CALL_STATE(frame); + gfs3_mkdir_rsp rsp = {0,}; + server_state_t *state = NULL; + inode_t *link_inode = 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) { gf_log (this->name, GF_LOG_INFO, "%"PRId64": MKDIR %s (%s/%s) ==> (%s)", @@ -542,6 +499,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); @@ -556,17 +514,16 @@ server_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this, inode_t *inode, struct iatt *stbuf, struct iatt *preparent, struct iatt *postparent, dict_t *xdata) { - gfs3_mknod_rsp rsp = {0,}; - server_state_t *state = NULL; - inode_t *link_inode = NULL; - rpcsvc_request_t *req = NULL; - - req = frame->local; - state = CALL_STATE(frame); + gfs3_mknod_rsp rsp = {0,}; + server_state_t *state = NULL; + inode_t *link_inode = 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) { gf_log (this->name, GF_LOG_INFO, "%"PRId64": MKNOD %s (%s/%s) ==> (%s)", @@ -589,6 +546,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); @@ -601,17 +559,15 @@ int server_fsyncdir_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); 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, @@ -624,6 +580,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); @@ -637,18 +594,16 @@ server_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, gf_dirent_t *entries, dict_t *xdata) { - gfs3_readdir_rsp rsp = {0,}; - server_state_t *state = NULL; - rpcsvc_request_t *req = NULL; - int ret = 0; - - req = frame->local; - state = CALL_STATE(frame); + gfs3_readdir_rsp rsp = {0,}; + server_state_t *state = NULL; + rpcsvc_request_t *req = NULL; + int ret = 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": READDIR %"PRId64" (%s) ==> (%s)", frame->root->unique, state->resolve.fd_no, @@ -671,6 +626,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); @@ -685,29 +641,33 @@ 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_connection_t *conn = NULL; - server_state_t *state = NULL; - rpcsvc_request_t *req = NULL; - gfs3_opendir_rsp rsp = {0,}; - uint64_t fd_no = 0; - - req = frame->local; - conn = SERVER_CONNECTION (frame); - 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) { - gf_log (this->name, GF_LOG_INFO, + state = CALL_STATE (frame); + gf_log (this->name, (op_errno == ENOENT)? + GF_LOG_DEBUG:GF_LOG_ERROR, "%"PRId64": OPENDIR %s (%s) ==> (%s)", frame->root->unique, state->loc.path, uuid_utoa (state->resolve.gfid), strerror (op_errno)); 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 (conn->fdtable, fd); + fd_no = gf_fd_unused_get (serv_ctx->fdtable, fd); fd_ref (fd); // on behalf of the client out: @@ -715,6 +675,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); @@ -727,17 +688,15 @@ int server_removexattr_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,}; - rpcsvc_request_t *req = NULL; - server_state_t *state = NULL; - - req = frame->local; - state = CALL_STATE(frame); + gf_common_rsp rsp = {0,}; + rpcsvc_request_t *req = NULL; + server_state_t *state = 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); 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, @@ -750,6 +709,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); @@ -762,17 +722,15 @@ int server_fremovexattr_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,}; - rpcsvc_request_t *req = NULL; + gf_common_rsp rsp = {0,}; + 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, @@ -785,6 +743,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); @@ -798,17 +757,15 @@ server_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, dict_t *dict, dict_t *xdata) { - gfs3_getxattr_rsp rsp = {0,}; - rpcsvc_request_t *req = NULL; - server_state_t *state = NULL; - - req = frame->local; - state = CALL_STATE (frame); + gfs3_getxattr_rsp rsp = {0,}; + rpcsvc_request_t *req = NULL; + server_state_t *state = 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); if (op_ret == -1) { + state = CALL_STATE (frame); gf_log (this->name, (((op_errno == ENOTSUP) || (op_errno == ENODATA) || (op_errno == ENOENT)) ? @@ -820,13 +777,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); @@ -843,17 +801,15 @@ server_fgetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, dict_t *dict, dict_t *xdata) { - gfs3_fgetxattr_rsp rsp = {0,}; - server_state_t *state = NULL; - rpcsvc_request_t *req = NULL; - - req = frame->local; - state = CALL_STATE (frame); + gfs3_fgetxattr_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); 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)", @@ -863,7 +819,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: @@ -871,6 +827,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); @@ -886,11 +843,11 @@ static int _gf_server_log_setxattr_failure (dict_t *d, char *k, data_t *v, void *tmp) { - server_state_t *state = NULL; - call_frame_t *frame = NULL; + server_state_t *state = NULL; + 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", @@ -907,13 +864,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, @@ -929,6 +884,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); @@ -942,11 +898,11 @@ static int _gf_server_log_fsetxattr_failure (dict_t *d, char *k, data_t *v, void *tmp) { - call_frame_t *frame = NULL; - server_state_t *state = NULL; + call_frame_t *frame = NULL; + 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", @@ -964,13 +920,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, @@ -986,6 +940,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); @@ -1001,20 +956,19 @@ server_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this, struct iatt *prenewparent, struct iatt *postnewparent, dict_t *xdata) { - gfs3_rename_rsp rsp = {0,}; - server_state_t *state = NULL; - rpcsvc_request_t *req = NULL; - inode_t *tmp_inode = NULL; - inode_t *tmp_parent = NULL; - char oldpar_str[50] = {0,}; - char newpar_str[50] = {0,}; - - req = frame->local; - state = CALL_STATE(frame); + gfs3_rename_rsp rsp = {0,}; + server_state_t *state = NULL; + rpcsvc_request_t *req = NULL; + inode_t *tmp_inode = NULL; + inode_t *tmp_parent = NULL; + char oldpar_str[50] = {0,}; + char newpar_str[50] = {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); + state = CALL_STATE (frame); + if (op_ret == -1) { uuid_utoa_r (state->resolve.gfid, oldpar_str); uuid_utoa_r (state->resolve2.gfid, newpar_str); @@ -1029,7 +983,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->conn->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); @@ -1071,6 +1025,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); @@ -1084,17 +1039,16 @@ server_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct iatt *preparent, struct iatt *postparent, dict_t *xdata) { - gfs3_unlink_rsp rsp = {0,}; - server_state_t *state = NULL; - inode_t *parent = NULL; - rpcsvc_request_t *req = NULL; - - req = frame->local; - state = CALL_STATE(frame); + gfs3_unlink_rsp rsp = {0,}; + server_state_t *state = NULL; + inode_t *parent = 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) { gf_log (this->name, (op_errno == ENOENT)? GF_LOG_DEBUG:GF_LOG_ERROR, @@ -1106,7 +1060,7 @@ server_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, } /* TODO: log gfid of the inodes */ - gf_log (state->conn->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); @@ -1126,6 +1080,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); @@ -1140,17 +1095,16 @@ server_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, struct iatt *stbuf, struct iatt *preparent, struct iatt *postparent, dict_t *xdata) { - gfs3_symlink_rsp rsp = {0,}; - server_state_t *state = NULL; - inode_t *link_inode = NULL; - rpcsvc_request_t *req = NULL; - - req = frame->local; - state = CALL_STATE(frame); + gfs3_symlink_rsp rsp = {0,}; + server_state_t *state = NULL; + inode_t *link_inode = 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) { gf_log (this->name, GF_LOG_INFO, "%"PRId64": SYMLINK %s (%s/%s) ==> (%s)", @@ -1173,6 +1127,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); @@ -1188,27 +1143,27 @@ server_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this, struct iatt *stbuf, struct iatt *preparent, struct iatt *postparent, dict_t *xdata) { - gfs3_link_rsp rsp = {0,}; - server_state_t *state = NULL; - inode_t *link_inode = NULL; - rpcsvc_request_t *req = NULL; + gfs3_link_rsp rsp = {0,}; + server_state_t *state = NULL; + inode_t *link_inode = NULL; + rpcsvc_request_t *req = NULL; 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); gf_log (this->name, GF_LOG_INFO, "%"PRId64": LINK %s (%s) -> %s/%s ==> (%s)", - frame->root->unique, state->loc.path, gfid_str, - newpar_str, state->resolve2.bname, strerror (op_errno)); + frame->root->unique, state->loc.path, + gfid_str, newpar_str, state->resolve2.bname, + strerror (op_errno)); goto out; } @@ -1224,6 +1179,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); @@ -1237,17 +1193,15 @@ server_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct iatt *prebuf, struct iatt *postbuf, dict_t *xdata) { - gfs3_truncate_rsp rsp = {0,}; - server_state_t *state = NULL; - rpcsvc_request_t *req = NULL; - - req = frame->local; - state = CALL_STATE (frame); + gfs3_truncate_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); 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, @@ -1262,6 +1216,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); @@ -1275,17 +1230,15 @@ server_fstat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct iatt *stbuf, dict_t *xdata) { - gfs3_fstat_rsp rsp = {0,}; - server_state_t *state = NULL; - rpcsvc_request_t *req = NULL; - - req = frame->local; - state = CALL_STATE(frame); + gfs3_fstat_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); 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, @@ -1299,6 +1252,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); @@ -1312,17 +1266,15 @@ server_ftruncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct iatt *prebuf, struct iatt *postbuf, dict_t *xdata) { - gfs3_ftruncate_rsp rsp = {0}; - server_state_t *state = NULL; - rpcsvc_request_t *req = NULL; - - req = frame->local; - state = CALL_STATE (frame); + gfs3_ftruncate_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); 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, @@ -1337,6 +1289,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); @@ -1349,21 +1302,20 @@ int server_flush_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); if (op_ret < 0) { - gf_log (this->name, GF_LOG_INFO, - "%"PRId64": FLUSH %"PRId64" (%s) ==> (%s)", + state = CALL_STATE (frame); + gf_log (this->name, (op_errno == ENOENT)? + GF_LOG_DEBUG:GF_LOG_ERROR, + "%"PRId64": FLUSH %"PRId64" (%s) ==> (%s)", frame->root->unique, state->resolve.fd_no, - uuid_utoa (state->resolve.gfid), strerror (op_errno)); + uuid_utoa (state->resolve.gfid), strerror (op_errno)); goto out; } @@ -1371,6 +1323,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); @@ -1384,17 +1337,15 @@ server_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct iatt *prebuf, struct iatt *postbuf, dict_t *xdata) { - gfs3_fsync_rsp rsp = {0,}; - server_state_t *state = NULL; - rpcsvc_request_t *req = NULL; - - req = frame->local; - state = CALL_STATE(frame); + gfs3_fsync_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); 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, @@ -1409,6 +1360,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); @@ -1422,17 +1374,15 @@ server_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct iatt *prebuf, struct iatt *postbuf, dict_t *xdata) { - gfs3_write_rsp rsp = {0,}; - server_state_t *state = NULL; - rpcsvc_request_t *req = NULL; - - req = frame->local; - state = CALL_STATE(frame); + gfs3_write_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); 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, @@ -1447,6 +1397,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); @@ -1462,12 +1413,9 @@ server_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this, struct iovec *vector, int32_t count, struct iatt *stbuf, struct iobref *iobref, dict_t *xdata) { - gfs3_read_rsp rsp = {0,}; - server_state_t *state = NULL; - rpcsvc_request_t *req = NULL; - - req = frame->local; - state = CALL_STATE(frame); + gfs3_read_rsp rsp = {0,}; + server_state_t *state = NULL; + rpcsvc_request_t *req = NULL; #ifdef GF_TESTING_IO_XDATA { @@ -1479,10 +1427,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, @@ -1497,6 +1446,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); @@ -1511,17 +1461,15 @@ server_rchecksum_cbk (call_frame_t *frame, void *cookie, xlator_t *this, uint32_t weak_checksum, uint8_t *strong_checksum, dict_t *xdata) { - gfs3_rchecksum_rsp rsp = {0,}; - rpcsvc_request_t *req = NULL; + gfs3_rchecksum_rsp rsp = {0,}; + 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, @@ -1538,6 +1486,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); @@ -1551,21 +1500,19 @@ 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_connection_t *conn = NULL; - server_state_t *state = NULL; - rpcsvc_request_t *req = NULL; - uint64_t fd_no = 0; - gfs3_open_rsp rsp = {0,}; - - req = frame->local; - conn = SERVER_CONNECTION (frame); - 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) { - gf_log (this->name, GF_LOG_INFO, + state = CALL_STATE (frame); + gf_log (this->name, (op_errno == ENOENT)? + GF_LOG_DEBUG:GF_LOG_ERROR, "%"PRId64": OPEN %s (%s) ==> (%s)", frame->root->unique, state->loc.path, uuid_utoa (state->resolve.gfid), @@ -1573,8 +1520,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 (conn->fdtable, fd); + fd_no = gf_fd_unused_get (serv_ctx->fdtable, fd); fd_ref (fd); rsp.fd = fd_no; @@ -1582,6 +1535,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); @@ -1596,20 +1550,18 @@ server_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, struct iatt *stbuf, struct iatt *preparent, struct iatt *postparent, dict_t *xdata) { - server_connection_t *conn = NULL; 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; - conn = SERVER_CONNECTION (frame); - 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 +1572,7 @@ server_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, } /* TODO: log gfid too */ - gf_log (state->conn->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 +1599,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 (conn->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 +1623,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); @@ -1679,17 +1637,15 @@ server_readlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, const char *buf, struct iatt *stbuf, dict_t *xdata) { - gfs3_readlink_rsp rsp = {0,}; - server_state_t *state = NULL; - rpcsvc_request_t *req = NULL; - - req = frame->local; - state = CALL_STATE(frame); + gfs3_readlink_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); 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 +1664,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); @@ -1721,18 +1678,17 @@ server_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct iatt *stbuf, dict_t *xdata) { - gfs3_stat_rsp rsp = {0,}; - server_state_t *state = NULL; - rpcsvc_request_t *req = NULL; - - req = frame->local; - state = CALL_STATE (frame); + gfs3_stat_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); if (op_ret) { - gf_log (this->name, GF_LOG_INFO, + state = CALL_STATE (frame); + gf_log (this->name, (op_errno == ENOENT)? + GF_LOG_DEBUG:GF_LOG_ERROR, "%"PRId64": STAT %s (%s) ==> (%s)", frame->root->unique, state->loc.path, uuid_utoa (state->resolve.gfid), @@ -1746,6 +1702,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); @@ -1760,17 +1717,15 @@ server_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct iatt *statpre, struct iatt *statpost, dict_t *xdata) { - gfs3_setattr_rsp rsp = {0,}; - server_state_t *state = NULL; - rpcsvc_request_t *req = NULL; - - req = frame->local; - state = CALL_STATE (frame); + gfs3_setattr_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); 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 +1741,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); @@ -1799,17 +1755,15 @@ server_fsetattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct iatt *statpre, struct iatt *statpost, dict_t *xdata) { - gfs3_fsetattr_rsp rsp = {0,}; - server_state_t *state = NULL; - rpcsvc_request_t *req = NULL; - - req = frame->local; - state = CALL_STATE (frame); + gfs3_fsetattr_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); 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 +1779,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); @@ -1839,17 +1794,15 @@ server_xattrop_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, dict_t *dict, dict_t *xdata) { - gfs3_xattrop_rsp rsp = {0,}; - server_state_t *state = NULL; - rpcsvc_request_t *req = NULL; - - req = frame->local; - state = CALL_STATE (frame); + gfs3_xattrop_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); 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 +1811,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); @@ -1881,17 +1835,15 @@ server_fxattrop_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, dict_t *dict, dict_t *xdata) { - gfs3_xattrop_rsp rsp = {0,}; - server_state_t *state = NULL; - rpcsvc_request_t *req = NULL; - - req = frame->local; - state = CALL_STATE(frame); + gfs3_xattrop_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); 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 +1852,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); @@ -1920,20 +1873,19 @@ out: int server_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, gf_dirent_t *entries, dict_t *xdata) + int32_t op_ret, int32_t op_errno, gf_dirent_t *entries, + dict_t *xdata) { - gfs3_readdirp_rsp rsp = {0,}; - server_state_t *state = NULL; - rpcsvc_request_t *req = NULL; - int ret = 0; - - req = frame->local; - state = CALL_STATE(frame); + gfs3_readdirp_rsp rsp = {0,}; + server_state_t *state = NULL; + rpcsvc_request_t *req = NULL; + int ret = 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": READDIRP %"PRId64" (%s) ==> (%s)", frame->root->unique, state->resolve.fd_no, @@ -1959,6 +1911,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); @@ -1969,6 +1922,122 @@ out: return 0; } +int +server_fallocate_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, + struct iatt *statpre, struct iatt *statpost, dict_t *xdata) +{ + gfs3_fallocate_rsp rsp = {0,}; + server_state_t *state = NULL; + rpcsvc_request_t *req = NULL; + + 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, + uuid_utoa (state->resolve.gfid), + strerror (op_errno)); + goto out; + } + + gf_stat_from_iatt (&rsp.statpre, statpre); + gf_stat_from_iatt (&rsp.statpost, statpost); + +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); + + GF_FREE (rsp.xdata.xdata_val); + + return 0; +} + +int +server_discard_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, + struct iatt *statpre, struct iatt *statpost, dict_t *xdata) +{ + gfs3_discard_rsp rsp = {0,}; + server_state_t *state = NULL; + rpcsvc_request_t *req = NULL; + + 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, + uuid_utoa (state->resolve.gfid), + strerror (op_errno)); + goto out; + } + + gf_stat_from_iatt (&rsp.statpre, statpre); + gf_stat_from_iatt (&rsp.statpost, statpost); + +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); + + GF_FREE (rsp.xdata.xdata_val); + + return 0; +} + +int +server_zerofill_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, + struct iatt *statpre, struct iatt *statpost, dict_t *xdata) +{ + gfs3_zerofill_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), + rsp.xdata.xdata_len, op_errno, out); + + if (op_ret) { + gf_log (this->name, GF_LOG_INFO, + "%"PRId64": ZEROFILL%"PRId64" (%s) ==> (%s)", + frame->root->unique, state->resolve.fd_no, + uuid_utoa (state->resolve.gfid), + strerror (op_errno)); + goto out; + } + + gf_stat_from_iatt (&rsp.statpre, statpre); + gf_stat_from_iatt (&rsp.statpost, statpost); + +out: + rsp.op_ret = op_ret; + rsp.op_errno = gf_errno_to_error (op_errno); + + server_submit_reply(frame, req, &rsp, NULL, 0, NULL, + (xdrproc_t) xdr_gfs3_zerofill_rsp); + + GF_FREE (rsp.xdata.xdata_val); + + return 0; +} + + /* Resume function section */ int @@ -2132,6 +2201,7 @@ err: int server_fentrylk_resume (call_frame_t *frame, xlator_t *bound_xl) { + GF_UNUSED int ret = -1; server_state_t *state = NULL; state = CALL_STATE (frame); @@ -2139,6 +2209,13 @@ server_fentrylk_resume (call_frame_t *frame, xlator_t *bound_xl) if (state->resolve.op_ret != 0) goto err; + if (!state->xdata) + state->xdata = dict_new (); + + if (state->xdata) + ret = dict_set_str (state->xdata, "connection-id", + frame->root->client->client_uid); + STACK_WIND (frame, server_fentrylk_cbk, bound_xl, bound_xl->fops->fentrylk, state->volume, state->fd, state->name, @@ -2155,6 +2232,7 @@ err: int server_entrylk_resume (call_frame_t *frame, xlator_t *bound_xl) { + GF_UNUSED int ret = -1; server_state_t *state = NULL; state = CALL_STATE (frame); @@ -2162,6 +2240,13 @@ server_entrylk_resume (call_frame_t *frame, xlator_t *bound_xl) if (state->resolve.op_ret != 0) goto err; + if (!state->xdata) + state->xdata = dict_new (); + + if (state->xdata) + ret = dict_set_str (state->xdata, "connection-id", + frame->root->client->client_uid); + STACK_WIND (frame, server_entrylk_cbk, bound_xl, bound_xl->fops->entrylk, state->volume, &state->loc, state->name, @@ -2177,13 +2262,24 @@ err: int 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) goto err; + if (!state->xdata) + state->xdata = dict_new (); + + if (state->xdata) + ret = dict_set_str (state->xdata, "connection-id", + frame->root->client->client_uid); + STACK_WIND (frame, server_finodelk_cbk, bound_xl, bound_xl->fops->finodelk, state->volume, state->fd, state->cmd, &state->flock, state->xdata); @@ -2199,13 +2295,24 @@ err: int 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) goto err; + if (!state->xdata) + state->xdata = dict_new (); + + if (state->xdata) + ret = dict_set_str (state->xdata, "connection-id", + frame->root->client->client_uid); + STACK_WIND (frame, server_inodelk_cbk, bound_xl, bound_xl->fops->inodelk, state->volume, &state->loc, state->cmd, &state->flock, state->xdata); @@ -2914,6 +3021,69 @@ err: return 0; } +int +server_fallocate_resume (call_frame_t *frame, xlator_t *bound_xl) +{ + server_state_t *state = NULL; + + state = CALL_STATE (frame); + + if (state->resolve.op_ret != 0) + goto err; + + STACK_WIND (frame, server_fallocate_cbk, + bound_xl, bound_xl->fops->fallocate, + state->fd, state->flags, state->offset, state->size, + state->xdata); + return 0; +err: + server_fallocate_cbk(frame, NULL, frame->this, state->resolve.op_ret, + state->resolve.op_errno, NULL, NULL, NULL); + + return 0; +} + +int +server_discard_resume (call_frame_t *frame, xlator_t *bound_xl) +{ + server_state_t *state = NULL; + + state = CALL_STATE (frame); + + if (state->resolve.op_ret != 0) + goto err; + + STACK_WIND (frame, server_discard_cbk, + bound_xl, bound_xl->fops->discard, + state->fd, state->offset, state->size, state->xdata); + return 0; +err: + server_discard_cbk(frame, NULL, frame->this, state->resolve.op_ret, + state->resolve.op_errno, NULL, NULL, NULL); + + return 0; +} + +int +server_zerofill_resume (call_frame_t *frame, xlator_t *bound_xl) +{ + server_state_t *state = NULL; + + state = CALL_STATE (frame); + + if (state->resolve.op_ret != 0) + goto err; + + STACK_WIND (frame, server_zerofill_cbk, + bound_xl, bound_xl->fops->zerofill, + state->fd, state->offset, state->size, state->xdata); + return 0; +err: + server_zerofill_cbk(frame, NULL, frame->this, state->resolve.op_ret, + state->resolve.op_errno, NULL, NULL, NULL); + + return 0; +} @@ -2936,31 +3106,31 @@ server3_3_stat (rpcsvc_request_t *req) ret = xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_stat_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { - // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_STAT; state = CALL_STATE (frame); - if (!state->conn->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } state->resolve.type = RESOLVE_MUST; memcpy (state->resolve.gfid, args.gfid, 16); - GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->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); @@ -2971,7 +3141,7 @@ out: free (args.xdata.xdata_val); if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); return ret; } @@ -2993,22 +3163,22 @@ server3_3_setattr (rpcsvc_request_t *req) (xdrproc_t)xdr_gfs3_setattr_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_SETATTR; state = CALL_STATE (frame); - if (!state->conn->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } @@ -3018,9 +3188,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->conn->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; @@ -3028,7 +3199,7 @@ server3_3_setattr (rpcsvc_request_t *req) out: if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); free (args.xdata.xdata_val); @@ -3052,22 +3223,21 @@ server3_3_fsetattr (rpcsvc_request_t *req) (xdrproc_t)xdr_gfs3_fsetattr_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { - // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_FSETATTR; state = CALL_STATE (frame); - if (!state->conn->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } @@ -3077,13 +3247,196 @@ server3_3_fsetattr (rpcsvc_request_t *req) gf_stat_to_iatt (&args.stbuf, &state->stbuf); state->valid = args.valid; - GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->bound_xl, state->xdata, + 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; + resolve_and_resume (frame, server_fsetattr_resume); + +out: + free (args.xdata.xdata_val); + + if (op_errno) + SERVER_REQ_SET_ERROR (req, ret); + + return ret; +} + +int +server3_3_fallocate(rpcsvc_request_t *req) +{ + server_state_t *state = NULL; + call_frame_t *frame = NULL; + gfs3_fallocate_req args = {{0},}; + int ret = -1; + int op_errno = 0; + + if (!req) + return ret; + + ret = xdr_to_generic (req->msg[0], &args, + (xdrproc_t)xdr_gfs3_fallocate_req); + if (ret < 0) { + //failed to decode msg; + SERVER_REQ_SET_ERROR (req, ret); + goto out; + } + + frame = get_frame_from_request (req); + if (!frame) { + // something wrong, mostly insufficient memory + SERVER_REQ_SET_ERROR (req, ret); + goto out; + } + frame->root->op = GF_FOP_FALLOCATE; + + 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; + } + + state->resolve.type = RESOLVE_MUST; + state->resolve.fd_no = args.fd; + + state->flags = args.flags; + state->offset = args.offset; + state->size = args.size; + memcpy(state->resolve.gfid, args.gfid, 16); + + 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; + resolve_and_resume (frame, server_fallocate_resume); + +out: + free (args.xdata.xdata_val); + + if (op_errno) + SERVER_REQ_SET_ERROR (req, ret); + + return ret; +} + + +int +server3_3_discard(rpcsvc_request_t *req) +{ + server_state_t *state = NULL; + call_frame_t *frame = NULL; + gfs3_discard_req args = {{0},}; + int ret = -1; + int op_errno = 0; + + if (!req) + return ret; + + ret = xdr_to_generic (req->msg[0], &args, + (xdrproc_t)xdr_gfs3_discard_req); + if (ret < 0) { + //failed to decode msg; + SERVER_REQ_SET_ERROR (req, ret); + goto out; + } + + frame = get_frame_from_request (req); + if (!frame) { + // something wrong, mostly insufficient memory + SERVER_REQ_SET_ERROR (req, ret); + goto out; + } + frame->root->op = GF_FOP_DISCARD; + + 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; + } + + state->resolve.type = RESOLVE_MUST; + state->resolve.fd_no = args.fd; + + state->offset = args.offset; + state->size = args.size; + memcpy(state->resolve.gfid, args.gfid, 16); + + 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; + resolve_and_resume (frame, server_discard_resume); + +out: + free (args.xdata.xdata_val); + + if (op_errno) + SERVER_REQ_SET_ERROR (req, ret); + + return ret; +} + + +int +server3_3_zerofill(rpcsvc_request_t *req) +{ + server_state_t *state = NULL; + call_frame_t *frame = NULL; + gfs3_zerofill_req args = {{0},}; + int ret = -1; + int op_errno = 0; + + if (!req) + return ret; + + ret = xdr_to_generic (req->msg[0], &args, + (xdrproc_t)xdr_gfs3_zerofill_req); + if (ret < 0) { + /*failed to decode msg*/; + req->rpc_err = GARBAGE_ARGS; + goto out; + } + + frame = get_frame_from_request (req); + if (!frame) { + /* something wrong, mostly insufficient memory*/ + req->rpc_err = GARBAGE_ARGS; /* TODO */ + goto out; + } + frame->root->op = GF_FOP_ZEROFILL; + + state = CALL_STATE (frame); + if (!frame->root->client->bound_xl) { + /* auth failure, request on subvolume without setvolume */ + req->rpc_err = GARBAGE_ARGS; + goto out; + } + + state->resolve.type = RESOLVE_MUST; + state->resolve.fd_no = args.fd; + + state->offset = args.offset; + state->size = args.size; + memcpy(state->resolve.gfid, args.gfid, 16); + + 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; - resolve_and_resume (frame, server_fsetattr_resume); + resolve_and_resume (frame, server_zerofill_resume); out: free (args.xdata.xdata_val); @@ -3094,7 +3447,6 @@ out: return ret; } - int server3_3_readlink (rpcsvc_request_t *req) { @@ -3111,22 +3463,22 @@ server3_3_readlink (rpcsvc_request_t *req) (xdrproc_t)xdr_gfs3_readlink_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_READLINK; state = CALL_STATE (frame); - if (!state->conn->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } @@ -3135,9 +3487,10 @@ server3_3_readlink (rpcsvc_request_t *req) state->size = args.size; - GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->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; @@ -3147,7 +3500,7 @@ out: free (args.xdata.xdata_val); if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); return ret; } @@ -3171,22 +3524,22 @@ server3_3_create (rpcsvc_request_t *req) (xdrproc_t)xdr_gfs3_create_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_CREATE; state = CALL_STATE (frame); - if (!state->conn->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } @@ -3204,9 +3557,10 @@ server3_3_create (rpcsvc_request_t *req) } /* TODO: can do alloca for xdata field instead of stdalloc */ - GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->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; @@ -3217,7 +3571,7 @@ out: free (args.xdata.xdata_val); if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); return ret; } @@ -3238,22 +3592,22 @@ server3_3_open (rpcsvc_request_t *req) ret = xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_open_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_OPEN; state = CALL_STATE (frame); - if (!state->conn->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } @@ -3262,16 +3616,17 @@ server3_3_open (rpcsvc_request_t *req) state->flags = gf_flags_to_flags (args.flags); - GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->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; resolve_and_resume (frame, server_open_resume); out: if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); free (args.xdata.xdata_val); @@ -3294,22 +3649,22 @@ server3_3_readv (rpcsvc_request_t *req) ret = xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_read_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_READ; state = CALL_STATE (frame); - if (!state->conn->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } @@ -3321,9 +3676,10 @@ server3_3_readv (rpcsvc_request_t *req) memcpy (state->resolve.gfid, args.gfid, 16); - GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->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; @@ -3333,7 +3689,7 @@ out: free (args.xdata.xdata_val); if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); return ret; } @@ -3357,22 +3713,22 @@ server3_3_writev (rpcsvc_request_t *req) (xdrproc_t)xdr_gfs3_write_req); if (len < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_WRITE; state = CALL_STATE (frame); - if (!state->conn->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } @@ -3400,9 +3756,10 @@ server3_3_writev (rpcsvc_request_t *req) state->size += state->payload_vector[i].iov_len; } - GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->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); #ifdef GF_TESTING_IO_XDATA @@ -3415,7 +3772,7 @@ out: free (args.xdata.xdata_val); if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); return ret; } @@ -3481,26 +3838,36 @@ server3_3_writev_vecsizer (int state, ssize_t *readsize, char *base_addr, int server3_3_release (rpcsvc_request_t *req) { - server_connection_t *conn = NULL; - 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); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } - conn = req->trans->xl_private; - if (!conn) { + client = req->trans->xl_private; + if (!client) { /* Handshake is not complete yet. */ req->rpc_err = SYSTEM_ERR; goto out; } - gf_fd_put (conn->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); @@ -3513,26 +3880,35 @@ out: int server3_3_releasedir (rpcsvc_request_t *req) { - server_connection_t *conn = 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); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } - conn = req->trans->xl_private; - if (!conn) { - req->rpc_err = GARBAGE_ARGS; + client = req->trans->xl_private; + if (!client) { + SERVER_REQ_SET_ERROR (req, ret); + goto out; + } + + 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 (conn->fdtable, args.fd); + gf_fd_put (serv_ctx->fdtable, args.fd); server_submit_reply (NULL, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gf_common_rsp); @@ -3559,22 +3935,22 @@ server3_3_fsync (rpcsvc_request_t *req) (xdrproc_t)xdr_gfs3_fsync_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_FSYNC; state = CALL_STATE (frame); - if (!state->conn->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } @@ -3583,9 +3959,10 @@ server3_3_fsync (rpcsvc_request_t *req) state->flags = args.data; memcpy (state->resolve.gfid, args.gfid, 16); - GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->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; @@ -3594,7 +3971,7 @@ out: free (args.xdata.xdata_val); if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); return ret; } @@ -3617,22 +3994,22 @@ server3_3_flush (rpcsvc_request_t *req) (xdrproc_t)xdr_gfs3_flush_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_FLUSH; state = CALL_STATE (frame); - if (!state->conn->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } @@ -3640,9 +4017,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->conn->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; @@ -3651,7 +4029,7 @@ out: free (args.xdata.xdata_val); if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); return ret; } @@ -3674,22 +4052,22 @@ server3_3_ftruncate (rpcsvc_request_t *req) (xdrproc_t)xdr_gfs3_ftruncate_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_FTRUNCATE; state = CALL_STATE (frame); - if (!state->conn->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } @@ -3698,9 +4076,10 @@ server3_3_ftruncate (rpcsvc_request_t *req) state->offset = args.offset; memcpy (state->resolve.gfid, args.gfid, 16); - GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->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; @@ -3709,7 +4088,7 @@ out: free (args.xdata.xdata_val); if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); return ret; } @@ -3731,22 +4110,22 @@ server3_3_fstat (rpcsvc_request_t *req) (xdrproc_t)xdr_gfs3_fstat_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_FSTAT; state = CALL_STATE (frame); - if (!state->conn->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } @@ -3754,9 +4133,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->conn->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; @@ -3765,7 +4145,7 @@ out: free (args.xdata.xdata_val); if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); return ret; } @@ -3787,22 +4167,22 @@ server3_3_truncate (rpcsvc_request_t *req) (xdrproc_t)xdr_gfs3_truncate_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_TRUNCATE; state = CALL_STATE (frame); - if (!state->conn->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } @@ -3810,9 +4190,10 @@ server3_3_truncate (rpcsvc_request_t *req) memcpy (state->resolve.gfid, args.gfid, 16); state->offset = args.offset; - GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->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; @@ -3821,7 +4202,7 @@ out: free (args.xdata.xdata_val); if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); return ret; } @@ -3846,22 +4227,22 @@ server3_3_unlink (rpcsvc_request_t *req) (xdrproc_t)xdr_gfs3_unlink_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_UNLINK; state = CALL_STATE (frame); - if (!state->conn->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } @@ -3871,9 +4252,10 @@ server3_3_unlink (rpcsvc_request_t *req) state->flags = args.xflags; - GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->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; @@ -3882,7 +4264,7 @@ out: free (args.xdata.xdata_val); if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); return ret; } @@ -3907,22 +4289,22 @@ server3_3_setxattr (rpcsvc_request_t *req) (xdrproc_t)xdr_gfs3_setxattr_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_SETXATTR; state = CALL_STATE (frame); - if (!state->conn->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } @@ -3930,7 +4312,8 @@ server3_3_setxattr (rpcsvc_request_t *req) state->flags = args.flags; memcpy (state->resolve.gfid, args.gfid, 16); - GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->bound_xl, dict, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, + dict, (args.dict.dict_val), (args.dict.dict_len), ret, op_errno, out); @@ -3940,9 +4323,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->conn->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; @@ -3953,7 +4337,7 @@ out: free (args.xdata.xdata_val); if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); if (dict) dict_unref (dict); @@ -3981,22 +4365,22 @@ server3_3_fsetxattr (rpcsvc_request_t *req) (xdrproc_t)xdr_gfs3_fsetxattr_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_FSETXATTR; state = CALL_STATE (frame); - if (!state->conn->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } @@ -4005,16 +4389,18 @@ server3_3_fsetxattr (rpcsvc_request_t *req) state->flags = args.flags; memcpy (state->resolve.gfid, args.gfid, 16); - GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->bound_xl, dict, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, + dict, (args.dict.dict_val), (args.dict.dict_len), ret, op_errno, out); state->dict = dict; - GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->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; @@ -4025,7 +4411,7 @@ out: free (args.xdata.xdata_val); if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); if (dict) dict_unref (dict); @@ -4053,22 +4439,22 @@ server3_3_fxattrop (rpcsvc_request_t *req) (xdrproc_t)xdr_gfs3_fxattrop_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_FXATTROP; - state = CALL_STATE(frame); - if (!state->conn->bound_xl) { + state = CALL_STATE (frame); + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } @@ -4077,16 +4463,18 @@ server3_3_fxattrop (rpcsvc_request_t *req) state->flags = args.flags; memcpy (state->resolve.gfid, args.gfid, 16); - GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->bound_xl, dict, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, + dict, (args.dict.dict_val), (args.dict.dict_len), ret, op_errno, out); state->dict = dict; - GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->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; @@ -4098,7 +4486,7 @@ out: free (args.xdata.xdata_val); if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); if (dict) dict_unref (dict); @@ -4127,22 +4515,22 @@ server3_3_xattrop (rpcsvc_request_t *req) (xdrproc_t)xdr_gfs3_xattrop_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_XATTROP; - state = CALL_STATE(frame); - if (!state->conn->bound_xl) { + state = CALL_STATE (frame); + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } @@ -4150,16 +4538,18 @@ server3_3_xattrop (rpcsvc_request_t *req) state->flags = args.flags; memcpy (state->resolve.gfid, args.gfid, 16); - GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->bound_xl, dict, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, + dict, (args.dict.dict_val), (args.dict.dict_len), ret, op_errno, out); state->dict = dict; - GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->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; @@ -4170,7 +4560,7 @@ out: free (args.xdata.xdata_val); if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); if (dict) dict_unref (dict); @@ -4197,22 +4587,22 @@ server3_3_getxattr (rpcsvc_request_t *req) (xdrproc_t)xdr_gfs3_getxattr_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_GETXATTR; state = CALL_STATE (frame); - if (!state->conn->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } @@ -4225,9 +4615,10 @@ server3_3_getxattr (rpcsvc_request_t *req) gf_server_check_getxattr_cmd (frame, state->name); } - GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->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; @@ -4236,7 +4627,7 @@ out: free (args.xdata.xdata_val); if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); return ret; } @@ -4259,22 +4650,22 @@ server3_3_fgetxattr (rpcsvc_request_t *req) (xdrproc_t)xdr_gfs3_fgetxattr_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_FGETXATTR; state = CALL_STATE (frame); - if (!state->conn->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } @@ -4285,9 +4676,10 @@ server3_3_fgetxattr (rpcsvc_request_t *req) if (args.namelen) state->name = gf_strdup (args.name); - GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->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; @@ -4296,7 +4688,7 @@ out: free (args.xdata.xdata_val); if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); return ret; } @@ -4321,22 +4713,22 @@ server3_3_removexattr (rpcsvc_request_t *req) (xdrproc_t)xdr_gfs3_removexattr_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_REMOVEXATTR; state = CALL_STATE (frame); - if (!state->conn->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } @@ -4344,9 +4736,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->conn->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; @@ -4355,7 +4748,7 @@ out: free (args.xdata.xdata_val); if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); return ret; } @@ -4378,22 +4771,22 @@ server3_3_fremovexattr (rpcsvc_request_t *req) (xdrproc_t)xdr_gfs3_fremovexattr_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_FREMOVEXATTR; state = CALL_STATE (frame); - if (!state->conn->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } @@ -4402,9 +4795,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->conn->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; @@ -4413,7 +4807,7 @@ out: free (args.xdata.xdata_val); if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); return ret; } @@ -4437,31 +4831,32 @@ server3_3_opendir (rpcsvc_request_t *req) (xdrproc_t)xdr_gfs3_opendir_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_OPENDIR; state = CALL_STATE (frame); - if (!state->conn->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } state->resolve.type = RESOLVE_MUST; memcpy (state->resolve.gfid, args.gfid, 16); - GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->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; @@ -4470,7 +4865,7 @@ out: free (args.xdata.xdata_val); if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); return ret; } @@ -4493,22 +4888,22 @@ server3_3_readdirp (rpcsvc_request_t *req) (xdrproc_t)xdr_gfs3_readdirp_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_READDIRP; - state = CALL_STATE(frame); - if (!state->conn->bound_xl) { + state = CALL_STATE (frame); + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } @@ -4529,7 +4924,8 @@ 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->conn->bound_xl, state->dict, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->root->client->bound_xl, + state->dict, (args.dict.dict_val), (args.dict.dict_len), ret, op_errno, out); @@ -4539,7 +4935,7 @@ server3_3_readdirp (rpcsvc_request_t *req) resolve_and_resume (frame, server_readdirp_resume); out: if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); free (args.dict.dict_val); @@ -4563,22 +4959,22 @@ server3_3_readdir (rpcsvc_request_t *req) (xdrproc_t)xdr_gfs3_readdir_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_READDIR; - state = CALL_STATE(frame); - if (!state->conn->bound_xl) { + state = CALL_STATE (frame); + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } @@ -4598,9 +4994,10 @@ server3_3_readdir (rpcsvc_request_t *req) state->offset = args.offset; memcpy (state->resolve.gfid, args.gfid, 16); - GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->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; @@ -4609,7 +5006,7 @@ out: free (args.xdata.xdata_val); if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); return ret; } @@ -4630,22 +5027,22 @@ server3_3_fsyncdir (rpcsvc_request_t *req) (xdrproc_t)xdr_gfs3_fsyncdir_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_FSYNCDIR; - state = CALL_STATE(frame); - if (!state->conn->bound_xl) { + state = CALL_STATE (frame); + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } @@ -4654,9 +5051,10 @@ server3_3_fsyncdir (rpcsvc_request_t *req) state->flags = args.data; memcpy (state->resolve.gfid, args.gfid, 16); - GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->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; @@ -4665,7 +5063,7 @@ out: free (args.xdata.xdata_val); if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); return ret; } @@ -4690,22 +5088,22 @@ server3_3_mknod (rpcsvc_request_t *req) (xdrproc_t)xdr_gfs3_mknod_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_MKNOD; state = CALL_STATE (frame); - if (!state->conn->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } @@ -4717,9 +5115,10 @@ server3_3_mknod (rpcsvc_request_t *req) state->dev = args.dev; state->umask = args.umask; - GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->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; @@ -4727,7 +5126,7 @@ server3_3_mknod (rpcsvc_request_t *req) out: if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); /* memory allocated by libc, don't use GF_FREE */ free (args.xdata.xdata_val); @@ -4755,22 +5154,22 @@ server3_3_mkdir (rpcsvc_request_t *req) (xdrproc_t)xdr_gfs3_mkdir_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_MKDIR; state = CALL_STATE (frame); - if (!state->conn->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } @@ -4782,9 +5181,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->conn->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; @@ -4792,7 +5192,7 @@ server3_3_mkdir (rpcsvc_request_t *req) out: if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); free (args.xdata.xdata_val); @@ -4818,22 +5218,22 @@ server3_3_rmdir (rpcsvc_request_t *req) (xdrproc_t)xdr_gfs3_rmdir_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_RMDIR; state = CALL_STATE (frame); - if (!state->conn->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } @@ -4843,9 +5243,10 @@ server3_3_rmdir (rpcsvc_request_t *req) state->flags = args.xflags; - GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->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; @@ -4854,7 +5255,7 @@ out: free (args.xdata.xdata_val); if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); return ret; } @@ -4880,22 +5281,22 @@ server3_3_inodelk (rpcsvc_request_t *req) (xdrproc_t)xdr_gfs3_inodelk_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_INODELK; state = CALL_STATE (frame); - if (!state->conn->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } @@ -4932,9 +5333,10 @@ server3_3_inodelk (rpcsvc_request_t *req) break; } - GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->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; @@ -4945,7 +5347,7 @@ out: free (args.flock.lk_owner.lk_owner_val); if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); return ret; } @@ -4967,22 +5369,22 @@ server3_3_finodelk (rpcsvc_request_t *req) (xdrproc_t)xdr_gfs3_finodelk_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_FINODELK; - state = CALL_STATE(frame); - if (!state->conn->bound_xl) { + state = CALL_STATE (frame); + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } @@ -5020,9 +5422,10 @@ server3_3_finodelk (rpcsvc_request_t *req) break; } - GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->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; @@ -5033,7 +5436,7 @@ out: free (args.flock.lk_owner.lk_owner_val); if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); return ret; } @@ -5058,22 +5461,22 @@ server3_3_entrylk (rpcsvc_request_t *req) (xdrproc_t)xdr_gfs3_entrylk_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_ENTRYLK; state = CALL_STATE (frame); - if (!state->conn->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } @@ -5087,9 +5490,10 @@ server3_3_entrylk (rpcsvc_request_t *req) state->cmd = args.cmd; state->type = args.type; - GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->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; @@ -5098,7 +5502,7 @@ out: free (args.xdata.xdata_val); if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); return ret; } @@ -5122,22 +5526,22 @@ server3_3_fentrylk (rpcsvc_request_t *req) (xdrproc_t)xdr_gfs3_fentrylk_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_FENTRYLK; - state = CALL_STATE(frame); - if (!state->conn->bound_xl) { + state = CALL_STATE (frame); + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } @@ -5151,9 +5555,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->conn->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; @@ -5162,7 +5567,7 @@ out: free (args.xdata.xdata_val); if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); return ret; } @@ -5183,22 +5588,22 @@ server3_3_access (rpcsvc_request_t *req) (xdrproc_t)xdr_gfs3_access_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_ACCESS; state = CALL_STATE (frame); - if (!state->conn->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } @@ -5206,9 +5611,10 @@ server3_3_access (rpcsvc_request_t *req) memcpy (state->resolve.gfid, args.gfid, 16); state->mask = args.mask; - GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->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; @@ -5217,7 +5623,7 @@ out: free (args.xdata.xdata_val); if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); return ret; } @@ -5243,22 +5649,22 @@ server3_3_symlink (rpcsvc_request_t *req) (xdrproc_t)xdr_gfs3_symlink_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_SYMLINK; state = CALL_STATE (frame); - if (!state->conn->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } @@ -5268,9 +5674,10 @@ server3_3_symlink (rpcsvc_request_t *req) state->name = gf_strdup (args.linkname); state->umask = args.umask; - GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->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; @@ -5278,7 +5685,7 @@ server3_3_symlink (rpcsvc_request_t *req) out: if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); /* memory allocated by libc, don't use GF_FREE */ free (args.xdata.xdata_val); @@ -5305,22 +5712,22 @@ server3_3_link (rpcsvc_request_t *req) ret = xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_link_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_LINK; state = CALL_STATE (frame); - if (!state->conn->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } @@ -5331,9 +5738,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->conn->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; @@ -5342,7 +5750,7 @@ out: free (args.xdata.xdata_val); if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); return ret; } @@ -5367,22 +5775,22 @@ server3_3_rename (rpcsvc_request_t *req) (xdrproc_t)xdr_gfs3_rename_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_RENAME; state = CALL_STATE (frame); - if (!state->conn->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } @@ -5394,9 +5802,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->conn->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; @@ -5405,7 +5814,7 @@ out: free (args.xdata.xdata_val); if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); return ret; } @@ -5425,22 +5834,22 @@ server3_3_lk (rpcsvc_request_t *req) ret = xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_lk_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_LK; state = CALL_STATE (frame); - if (!state->conn->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } @@ -5488,7 +5897,7 @@ server3_3_lk (rpcsvc_request_t *req) state->flock.l_type = F_UNLCK; break; default: - gf_log (state->conn->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); @@ -5496,9 +5905,10 @@ server3_3_lk (rpcsvc_request_t *req) } - GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->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; @@ -5509,7 +5919,7 @@ out: free (args.flock.lk_owner.lk_owner_val); if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); return ret; } @@ -5531,22 +5941,22 @@ server3_3_rchecksum (rpcsvc_request_t *req) (xdrproc_t)xdr_gfs3_rchecksum_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_RCHECKSUM; - state = CALL_STATE(frame); - if (!state->conn->bound_xl) { + state = CALL_STATE (frame); + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } @@ -5555,9 +5965,10 @@ server3_3_rchecksum (rpcsvc_request_t *req) state->offset = args.offset; state->size = args.len; - GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->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; @@ -5566,7 +5977,7 @@ out: free (args.xdata.xdata_val); if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); return ret; } @@ -5603,14 +6014,14 @@ server3_3_lookup (rpcsvc_request_t *req) (xdrproc_t)xdr_gfs3_lookup_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto err; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto err; } frame->root->op = GF_FOP_LOOKUP; @@ -5620,9 +6031,9 @@ server3_3_lookup (rpcsvc_request_t *req) */ state = CALL_STATE (frame); - if (!state->conn->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } @@ -5635,9 +6046,10 @@ server3_3_lookup (rpcsvc_request_t *req) memcpy (state->resolve.gfid, args.gfid, 16); } - GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->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; @@ -5669,88 +6081,92 @@ server3_3_statfs (rpcsvc_request_t *req) (xdrproc_t)xdr_gfs3_statfs_req); if (ret < 0) { //failed to decode msg; - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame = get_frame_from_request (req); if (!frame) { // something wrong, mostly insufficient memory - req->rpc_err = GARBAGE_ARGS; /* TODO */ + SERVER_REQ_SET_ERROR (req, ret); goto out; } frame->root->op = GF_FOP_STATFS; state = CALL_STATE (frame); - if (!state->conn->bound_xl) { + if (!frame->root->client->bound_xl) { /* auth failure, request on subvolume without setvolume */ - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); goto out; } state->resolve.type = RESOLVE_MUST; memcpy (state->resolve.gfid, args.gfid, 16); - GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->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; resolve_and_resume (frame, server_statfs_resume); out: if (op_errno) - req->rpc_err = GARBAGE_ARGS; + SERVER_REQ_SET_ERROR (req, ret); return ret; } rpcsvc_actor_t glusterfs3_3_fop_actors[] = { - [GFS3_OP_NULL] = { "NULL", GFS3_OP_NULL, server_null, NULL, 0}, - [GFS3_OP_STAT] = { "STAT", GFS3_OP_STAT, server3_3_stat, NULL, 0}, - [GFS3_OP_READLINK] = { "READLINK", GFS3_OP_READLINK, server3_3_readlink, NULL, 0}, - [GFS3_OP_MKNOD] = { "MKNOD", GFS3_OP_MKNOD, server3_3_mknod, NULL, 0}, - [GFS3_OP_MKDIR] = { "MKDIR", GFS3_OP_MKDIR, server3_3_mkdir, NULL, 0}, - [GFS3_OP_UNLINK] = { "UNLINK", GFS3_OP_UNLINK, server3_3_unlink, NULL, 0}, - [GFS3_OP_RMDIR] = { "RMDIR", GFS3_OP_RMDIR, server3_3_rmdir, NULL, 0}, - [GFS3_OP_SYMLINK] = { "SYMLINK", GFS3_OP_SYMLINK, server3_3_symlink, NULL, 0}, - [GFS3_OP_RENAME] = { "RENAME", GFS3_OP_RENAME, server3_3_rename, NULL, 0}, - [GFS3_OP_LINK] = { "LINK", GFS3_OP_LINK, server3_3_link, NULL, 0}, - [GFS3_OP_TRUNCATE] = { "TRUNCATE", GFS3_OP_TRUNCATE, server3_3_truncate, NULL, 0}, - [GFS3_OP_OPEN] = { "OPEN", GFS3_OP_OPEN, server3_3_open, NULL, 0}, - [GFS3_OP_READ] = { "READ", GFS3_OP_READ, server3_3_readv, NULL, 0}, - [GFS3_OP_WRITE] = { "WRITE", GFS3_OP_WRITE, server3_3_writev, server3_3_writev_vecsizer, 0}, - [GFS3_OP_STATFS] = { "STATFS", GFS3_OP_STATFS, server3_3_statfs, NULL, 0}, - [GFS3_OP_FLUSH] = { "FLUSH", GFS3_OP_FLUSH, server3_3_flush, NULL, 0}, - [GFS3_OP_FSYNC] = { "FSYNC", GFS3_OP_FSYNC, server3_3_fsync, NULL, 0}, - [GFS3_OP_SETXATTR] = { "SETXATTR", GFS3_OP_SETXATTR, server3_3_setxattr, NULL, 0}, - [GFS3_OP_GETXATTR] = { "GETXATTR", GFS3_OP_GETXATTR, server3_3_getxattr, NULL, 0}, - [GFS3_OP_REMOVEXATTR] = { "REMOVEXATTR", GFS3_OP_REMOVEXATTR, server3_3_removexattr, NULL, 0}, - [GFS3_OP_OPENDIR] = { "OPENDIR", GFS3_OP_OPENDIR, server3_3_opendir, NULL, 0}, - [GFS3_OP_FSYNCDIR] = { "FSYNCDIR", GFS3_OP_FSYNCDIR, server3_3_fsyncdir, NULL, 0}, - [GFS3_OP_ACCESS] = { "ACCESS", GFS3_OP_ACCESS, server3_3_access, NULL, 0}, - [GFS3_OP_CREATE] = { "CREATE", GFS3_OP_CREATE, server3_3_create, NULL, 0}, - [GFS3_OP_FTRUNCATE] = { "FTRUNCATE", GFS3_OP_FTRUNCATE, server3_3_ftruncate, NULL, 0}, - [GFS3_OP_FSTAT] = { "FSTAT", GFS3_OP_FSTAT, server3_3_fstat, NULL, 0}, - [GFS3_OP_LK] = { "LK", GFS3_OP_LK, server3_3_lk, NULL, 0}, - [GFS3_OP_LOOKUP] = { "LOOKUP", GFS3_OP_LOOKUP, server3_3_lookup, NULL, 0}, - [GFS3_OP_READDIR] = { "READDIR", GFS3_OP_READDIR, server3_3_readdir, NULL, 0}, - [GFS3_OP_INODELK] = { "INODELK", GFS3_OP_INODELK, server3_3_inodelk, NULL, 0}, - [GFS3_OP_FINODELK] = { "FINODELK", GFS3_OP_FINODELK, server3_3_finodelk, NULL, 0}, - [GFS3_OP_ENTRYLK] = { "ENTRYLK", GFS3_OP_ENTRYLK, server3_3_entrylk, NULL, 0}, - [GFS3_OP_FENTRYLK] = { "FENTRYLK", GFS3_OP_FENTRYLK, server3_3_fentrylk, NULL, 0}, - [GFS3_OP_XATTROP] = { "XATTROP", GFS3_OP_XATTROP, server3_3_xattrop, NULL, 0}, - [GFS3_OP_FXATTROP] = { "FXATTROP", GFS3_OP_FXATTROP, server3_3_fxattrop, NULL, 0}, - [GFS3_OP_FGETXATTR] = { "FGETXATTR", GFS3_OP_FGETXATTR, server3_3_fgetxattr, NULL, 0}, - [GFS3_OP_FSETXATTR] = { "FSETXATTR", GFS3_OP_FSETXATTR, server3_3_fsetxattr, NULL, 0}, - [GFS3_OP_RCHECKSUM] = { "RCHECKSUM", GFS3_OP_RCHECKSUM, server3_3_rchecksum, NULL, 0}, - [GFS3_OP_SETATTR] = { "SETATTR", GFS3_OP_SETATTR, server3_3_setattr, NULL, 0}, - [GFS3_OP_FSETATTR] = { "FSETATTR", GFS3_OP_FSETATTR, server3_3_fsetattr, NULL, 0}, - [GFS3_OP_READDIRP] = { "READDIRP", GFS3_OP_READDIRP, server3_3_readdirp, NULL, 0}, - [GFS3_OP_RELEASE] = { "RELEASE", GFS3_OP_RELEASE, server3_3_release, NULL, 0}, - [GFS3_OP_RELEASEDIR] = { "RELEASEDIR", GFS3_OP_RELEASEDIR, server3_3_releasedir, NULL, 0}, - [GFS3_OP_FREMOVEXATTR] = { "FREMOVEXATTR", GFS3_OP_FREMOVEXATTR, server3_3_fremovexattr, NULL, 0}, + [GFS3_OP_NULL] = {"NULL", GFS3_OP_NULL, server_null, NULL, 0, DRC_NA}, + [GFS3_OP_STAT] = {"STAT", GFS3_OP_STAT, server3_3_stat, NULL, 0, DRC_NA}, + [GFS3_OP_READLINK] = {"READLINK", GFS3_OP_READLINK, server3_3_readlink, NULL, 0, DRC_NA}, + [GFS3_OP_MKNOD] = {"MKNOD", GFS3_OP_MKNOD, server3_3_mknod, NULL, 0, DRC_NA}, + [GFS3_OP_MKDIR] = {"MKDIR", GFS3_OP_MKDIR, server3_3_mkdir, NULL, 0, DRC_NA}, + [GFS3_OP_UNLINK] = {"UNLINK", GFS3_OP_UNLINK, server3_3_unlink, NULL, 0, DRC_NA}, + [GFS3_OP_RMDIR] = {"RMDIR", GFS3_OP_RMDIR, server3_3_rmdir, NULL, 0, DRC_NA}, + [GFS3_OP_SYMLINK] = {"SYMLINK", GFS3_OP_SYMLINK, server3_3_symlink, NULL, 0, DRC_NA}, + [GFS3_OP_RENAME] = {"RENAME", GFS3_OP_RENAME, server3_3_rename, NULL, 0, DRC_NA}, + [GFS3_OP_LINK] = {"LINK", GFS3_OP_LINK, server3_3_link, NULL, 0, DRC_NA}, + [GFS3_OP_TRUNCATE] = {"TRUNCATE", GFS3_OP_TRUNCATE, server3_3_truncate, NULL, 0, DRC_NA}, + [GFS3_OP_OPEN] = {"OPEN", GFS3_OP_OPEN, server3_3_open, NULL, 0, DRC_NA}, + [GFS3_OP_READ] = {"READ", GFS3_OP_READ, server3_3_readv, NULL, 0, DRC_NA}, + [GFS3_OP_WRITE] = {"WRITE", GFS3_OP_WRITE, server3_3_writev, server3_3_writev_vecsizer, 0, DRC_NA}, + [GFS3_OP_STATFS] = {"STATFS", GFS3_OP_STATFS, server3_3_statfs, NULL, 0, DRC_NA}, + [GFS3_OP_FLUSH] = {"FLUSH", GFS3_OP_FLUSH, server3_3_flush, NULL, 0, DRC_NA}, + [GFS3_OP_FSYNC] = {"FSYNC", GFS3_OP_FSYNC, server3_3_fsync, NULL, 0, DRC_NA}, + [GFS3_OP_SETXATTR] = {"SETXATTR", GFS3_OP_SETXATTR, server3_3_setxattr, NULL, 0, DRC_NA}, + [GFS3_OP_GETXATTR] = {"GETXATTR", GFS3_OP_GETXATTR, server3_3_getxattr, NULL, 0, DRC_NA}, + [GFS3_OP_REMOVEXATTR] = {"REMOVEXATTR", GFS3_OP_REMOVEXATTR, server3_3_removexattr, NULL, 0, DRC_NA}, + [GFS3_OP_OPENDIR] = {"OPENDIR", GFS3_OP_OPENDIR, server3_3_opendir, NULL, 0, DRC_NA}, + [GFS3_OP_FSYNCDIR] = {"FSYNCDIR", GFS3_OP_FSYNCDIR, server3_3_fsyncdir, NULL, 0, DRC_NA}, + [GFS3_OP_ACCESS] = {"ACCESS", GFS3_OP_ACCESS, server3_3_access, NULL, 0, DRC_NA}, + [GFS3_OP_CREATE] = {"CREATE", GFS3_OP_CREATE, server3_3_create, NULL, 0, DRC_NA}, + [GFS3_OP_FTRUNCATE] = {"FTRUNCATE", GFS3_OP_FTRUNCATE, server3_3_ftruncate, NULL, 0, DRC_NA}, + [GFS3_OP_FSTAT] = {"FSTAT", GFS3_OP_FSTAT, server3_3_fstat, NULL, 0, DRC_NA}, + [GFS3_OP_LK] = {"LK", GFS3_OP_LK, server3_3_lk, NULL, 0, DRC_NA}, + [GFS3_OP_LOOKUP] = {"LOOKUP", GFS3_OP_LOOKUP, server3_3_lookup, NULL, 0, DRC_NA}, + [GFS3_OP_READDIR] = {"READDIR", GFS3_OP_READDIR, server3_3_readdir, NULL, 0, DRC_NA}, + [GFS3_OP_INODELK] = {"INODELK", GFS3_OP_INODELK, server3_3_inodelk, NULL, 0, DRC_NA}, + [GFS3_OP_FINODELK] = {"FINODELK", GFS3_OP_FINODELK, server3_3_finodelk, NULL, 0, DRC_NA}, + [GFS3_OP_ENTRYLK] = {"ENTRYLK", GFS3_OP_ENTRYLK, server3_3_entrylk, NULL, 0, DRC_NA}, + [GFS3_OP_FENTRYLK] = {"FENTRYLK", GFS3_OP_FENTRYLK, server3_3_fentrylk, NULL, 0, DRC_NA}, + [GFS3_OP_XATTROP] = {"XATTROP", GFS3_OP_XATTROP, server3_3_xattrop, NULL, 0, DRC_NA}, + [GFS3_OP_FXATTROP] = {"FXATTROP", GFS3_OP_FXATTROP, server3_3_fxattrop, NULL, 0, DRC_NA}, + [GFS3_OP_FGETXATTR] = {"FGETXATTR", GFS3_OP_FGETXATTR, server3_3_fgetxattr, NULL, 0, DRC_NA}, + [GFS3_OP_FSETXATTR] = {"FSETXATTR", GFS3_OP_FSETXATTR, server3_3_fsetxattr, NULL, 0, DRC_NA}, + [GFS3_OP_RCHECKSUM] = {"RCHECKSUM", GFS3_OP_RCHECKSUM, server3_3_rchecksum, NULL, 0, DRC_NA}, + [GFS3_OP_SETATTR] = {"SETATTR", GFS3_OP_SETATTR, server3_3_setattr, NULL, 0, DRC_NA}, + [GFS3_OP_FSETATTR] = {"FSETATTR", GFS3_OP_FSETATTR, server3_3_fsetattr, NULL, 0, DRC_NA}, + [GFS3_OP_READDIRP] = {"READDIRP", GFS3_OP_READDIRP, server3_3_readdirp, NULL, 0, DRC_NA}, + [GFS3_OP_RELEASE] = {"RELEASE", GFS3_OP_RELEASE, server3_3_release, NULL, 0, DRC_NA}, + [GFS3_OP_RELEASEDIR] = {"RELEASEDIR", GFS3_OP_RELEASEDIR, server3_3_releasedir, NULL, 0, DRC_NA}, + [GFS3_OP_FREMOVEXATTR] = {"FREMOVEXATTR", GFS3_OP_FREMOVEXATTR, server3_3_fremovexattr, NULL, 0, DRC_NA}, + [GFS3_OP_FALLOCATE] = {"FALLOCATE", GFS3_OP_FALLOCATE, server3_3_fallocate, NULL, 0, DRC_NA}, + [GFS3_OP_DISCARD] = {"DISCARD", GFS3_OP_DISCARD, server3_3_discard, NULL, 0, DRC_NA}, + [GFS3_OP_ZEROFILL] = {"ZEROFILL", GFS3_OP_ZEROFILL, server3_3_zerofill, NULL, 0, DRC_NA}, }; diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c index 7aafbdf0a..589bd7b36 100644 --- a/xlators/protocol/server/src/server.c +++ b/xlators/protocol/server/src/server.c @@ -25,33 +25,56 @@ #include "statedump.h" #include "defaults.h" #include "authenticate.h" -#include "rpcsvc.h" void grace_time_handler (void *data) { - server_connection_t *conn = NULL; - xlator_t *this = NULL; - gf_boolean_t cancelled = _gf_false; - gf_boolean_t detached = _gf_false; + 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; - conn = data; - this = conn->this; + client = data; + this = client->this; - GF_VALIDATE_OR_GOTO (THIS->name, conn, out); GF_VALIDATE_OR_GOTO (THIS->name, this, out); - gf_log (this->name, GF_LOG_INFO, "grace timer expired for %s", conn->id); + gf_log (this->name, GF_LOG_INFO, "grace timer expired for %s", + client->client_uid); - cancelled = server_cancel_conn_timer (this, conn); + 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 (serv_ctx->grace_timer) { + timer = serv_ctx->grace_timer; + serv_ctx->grace_timer = NULL; + } + } + UNLOCK (&serv_ctx->fdtable_lock); + if (timer) { + gf_timer_call_cancel (this->ctx, timer); + cancelled = _gf_true; + } if (cancelled) { - //conn should not be destroyed in conn_put, so take a ref. - server_conn_ref (conn); - server_connection_put (this, conn, &detached); + + /* + * client must not be destroyed in gf_client_put(), + * so take a ref. + */ + gf_client_ref (client); + gf_client_put (client, &detached); if (detached)//reconnection did not happen :-( - server_connection_cleanup (this, conn, - INTERNAL_LOCKS | POSIX_LOCKS); - server_conn_unref (conn); + server_connection_cleanup (this, client, + INTERNAL_LOCKS | POSIX_LOCKS); + gf_client_unref (client); } out: return; @@ -107,8 +130,6 @@ ret: return iob; } - - int server_submit_reply (call_frame_t *frame, rpcsvc_request_t *req, void *arg, struct iovec *payload, int payloadcount, @@ -119,19 +140,24 @@ server_submit_reply (call_frame_t *frame, rpcsvc_request_t *req, void *arg, struct iovec rsp = {0,}; server_state_t *state = NULL; char new_iobref = 0; - server_connection_t *conn = NULL; + client_t *client = NULL; gf_boolean_t lk_heal = _gf_false; + server_conf_t *conf = NULL; + gf_barrier_t *barrier = NULL; + gf_barrier_payload_t *stub = NULL; + gf_boolean_t barriered = _gf_false; GF_VALIDATE_OR_GOTO ("server", req, ret); if (frame) { state = CALL_STATE (frame); frame->local = NULL; - conn = SERVER_CONNECTION(frame); + client = frame->root->client; + conf = (server_conf_t *) client->this->private; } - if (conn) - lk_heal = ((server_conf_t *) conn->this->private)->lk_heal; + if (client) + lk_heal = ((server_conf_t *) client->this->private)->lk_heal; if (!iobref) { iobref = iobref_new (); @@ -150,6 +176,32 @@ server_submit_reply (call_frame_t *frame, rpcsvc_request_t *req, void *arg, iobref_add (iobref, iob); + if (conf) + barrier = conf->barrier; + if (barrier) { + /* todo: write's with fd flags set to O_SYNC and O_DIRECT */ + LOCK (&barrier->lock); + { + if (is_fop_barriered (barrier->fops, req->procnum) && + (barrier_add_to_queue (barrier))) { + stub = gf_barrier_payload (req, &rsp, frame, + payload, + payloadcount, iobref, + iob, new_iobref); + if (stub) { + gf_barrier_enqueue (barrier, stub); + barriered = _gf_true; + } else { + gf_log ("", GF_LOG_ERROR, "Failed to " + " barrier fop %"PRIu64, + ((uint64_t)1 << req->procnum)); + } + } + } + UNLOCK (&barrier->lock); + if (barriered == _gf_true) + goto out; + } /* Then, submit the message for transmission. */ ret = rpcsvc_submit_generic (req, &rsp, 1, payload, payloadcount, iobref); @@ -165,13 +217,14 @@ server_submit_reply (call_frame_t *frame, rpcsvc_request_t *req, void *arg, iobuf_unref (iob); if (ret == -1) { gf_log_callingfn ("", GF_LOG_ERROR, "Reply submission failed"); - if (frame && conn && !lk_heal) { - server_connection_cleanup (frame->this, conn, + if (frame && client && !lk_heal) { + server_connection_cleanup (frame->this, client, INTERNAL_LOCKS | POSIX_LOCKS); } else { + gf_log_callingfn ("", GF_LOG_ERROR, + "Reply submission failed"); /* TODO: Failure of open(dir), create, inodelk, entrylk or lk fops send failure must be handled specially. */ - ; } goto ret; } @@ -183,185 +236,17 @@ ret: } if (frame) { - if (frame->root->trans) - server_conn_unref (frame->root->trans); + gf_client_unref (client); STACK_DESTROY (frame->root); } if (new_iobref) { iobref_unref (iobref); } - - return ret; -} - -/* */ -int -server_fd_to_dict (xlator_t *this, dict_t *dict) -{ - server_conf_t *conf = NULL; - server_connection_t *trav = NULL; - char key[GF_DUMP_MAX_BUF_LEN] = {0,}; - int count = 0; - int ret = -1; - - GF_VALIDATE_OR_GOTO (THIS->name, this, out); - GF_VALIDATE_OR_GOTO (this->name, dict, out); - - conf = this->private; - if (!conf) - return -1; - - ret = pthread_mutex_trylock (&conf->mutex); - if (ret) - return -1; - - list_for_each_entry (trav, &conf->conns, list) { - memset (key, 0, sizeof (key)); - snprintf (key, sizeof (key), "conn%d", count++); - fdtable_dump_to_dict (trav->fdtable, key, dict); - } - pthread_mutex_unlock (&conf->mutex); - - ret = dict_set_int32 (dict, "conncount", count); out: return ret; } -int -server_fd (xlator_t *this) -{ - server_conf_t *conf = NULL; - server_connection_t *trav = NULL; - char key[GF_DUMP_MAX_BUF_LEN]; - int i = 1; - int ret = -1; - gf_boolean_t section_added = _gf_false; - - GF_VALIDATE_OR_GOTO ("server", this, out); - - conf = this->private; - if (!conf) { - gf_log (this->name, GF_LOG_WARNING, - "conf null in xlator"); - return -1; - } - - gf_proc_dump_add_section("xlator.protocol.server.conn"); - section_added = _gf_true; - - ret = pthread_mutex_trylock (&conf->mutex); - if (ret) - goto out; - - list_for_each_entry (trav, &conf->conns, list) { - if (trav->id) { - gf_proc_dump_build_key(key, - "conn","%d.id", i); - gf_proc_dump_write(key, "%s", trav->id); - } - - gf_proc_dump_build_key(key,"conn","%d.ref",i) - gf_proc_dump_write(key, "%d", trav->ref); - if (trav->bound_xl) { - gf_proc_dump_build_key(key, - "conn","%d.bound_xl", i); - gf_proc_dump_write(key, "%s", trav->bound_xl->name); - } - - gf_proc_dump_build_key(key, - "conn","%d.id", i); - fdtable_dump(trav->fdtable,key); - i++; - } - pthread_mutex_unlock (&conf->mutex); - - ret = 0; -out: - if (ret) { - if (section_added == _gf_false) - gf_proc_dump_add_section("xlator.protocol.server.conn"); - gf_proc_dump_write ("Unable to dump the list of connections", - "(Lock acquisition failed) %s", - this?this->name:"server"); - } - return ret; -} - -void -ltable_dump (server_connection_t *trav) -{ - char key[GF_DUMP_MAX_BUF_LEN] = {0,}; - struct _locker *locker = NULL; - char locker_data[GF_MAX_LOCK_OWNER_LEN] = {0,}; - int count = 0; - - gf_proc_dump_build_key(key, - "conn","bound_xl.ltable.inodelk.%s", - trav->bound_xl?trav->bound_xl->name:""); - gf_proc_dump_add_section(key); - - list_for_each_entry (locker, &trav->ltable->inodelk_lockers, lockers) { - count++; - gf_proc_dump_write("volume", "%s", locker->volume); - if (locker->fd) { - gf_proc_dump_write("fd", "%p", locker->fd); - gf_proc_dump_write("gfid", "%s", - uuid_utoa (locker->fd->inode->gfid)); - } else { - gf_proc_dump_write("fd", "%s", locker->loc.path); - gf_proc_dump_write("gfid", "%s", - uuid_utoa (locker->loc.inode->gfid)); - } - gf_proc_dump_write("pid", "%d", locker->pid); - gf_proc_dump_write("lock length", "%d", locker->owner.len); - lkowner_unparse (&locker->owner, locker_data, - locker->owner.len); - gf_proc_dump_write("lock owner", "%s", locker_data); - memset (locker_data, 0, sizeof (locker_data)); - - gf_proc_dump_build_key (key, "inode", "%d", count); - gf_proc_dump_add_section (key); - if (locker->fd) - inode_dump (locker->fd->inode, key); - else - inode_dump (locker->loc.inode, key); - } - - count = 0; - locker = NULL; - gf_proc_dump_build_key(key, - "conn","bound_xl.ltable.entrylk.%s", - trav->bound_xl?trav->bound_xl->name:""); - gf_proc_dump_add_section(key); - - list_for_each_entry (locker, &trav->ltable->entrylk_lockers, - lockers) { - count++; - gf_proc_dump_write("volume", "%s", locker->volume); - if (locker->fd) { - gf_proc_dump_write("fd", "%p", locker->fd); - gf_proc_dump_write("gfid", "%s", - uuid_utoa (locker->fd->inode->gfid)); - } else { - gf_proc_dump_write("fd", "%s", locker->loc.path); - gf_proc_dump_write("gfid", "%s", - uuid_utoa (locker->loc.inode->gfid)); - } - gf_proc_dump_write("pid", "%d", locker->pid); - gf_proc_dump_write("lock length", "%d", locker->owner.len); - lkowner_unparse (&locker->owner, locker_data, locker->owner.len); - gf_proc_dump_write("lock data", "%s", locker_data); - memset (locker_data, 0, sizeof (locker_data)); - - gf_proc_dump_build_key (key, "inode", "%d", count); - gf_proc_dump_add_section (key); - if (locker->fd) - inode_dump (locker->fd->inode, key); - else - inode_dump (locker->loc.inode, key); - } -} int server_priv_to_dict (xlator_t *this, dict_t *dict) @@ -468,104 +353,6 @@ out: return ret; } -int -server_inode_to_dict (xlator_t *this, dict_t *dict) -{ - server_conf_t *conf = NULL; - server_connection_t *trav = NULL; - char key[32] = {0,}; - int count = 0; - int ret = -1; - xlator_t *prev_bound_xl = NULL; - - GF_VALIDATE_OR_GOTO (THIS->name, this, out); - GF_VALIDATE_OR_GOTO (this->name, dict, out); - - conf = this->private; - if (!conf) - return -1; - - ret = pthread_mutex_trylock (&conf->mutex); - if (ret) - return -1; - - list_for_each_entry (trav, &conf->conns, list) { - if (trav->bound_xl && trav->bound_xl->itable) { - /* Presently every brick contains only one - * bound_xl for all connections. This will lead - * to duplicating of the inode lists, if listing - * is done for every connection. This simple check - * prevents duplication in the present case. If - * need arises the check can be improved. - */ - if (trav->bound_xl == prev_bound_xl) - continue; - prev_bound_xl = trav->bound_xl; - - memset (key, 0, sizeof (key)); - snprintf (key, sizeof (key), "conn%d", count); - inode_table_dump_to_dict (trav->bound_xl->itable, - key, dict); - count++; - } - } - pthread_mutex_unlock (&conf->mutex); - - ret = dict_set_int32 (dict, "conncount", count); - -out: - if (prev_bound_xl) - prev_bound_xl = NULL; - return ret; -} - -int -server_inode (xlator_t *this) -{ - server_conf_t *conf = NULL; - server_connection_t *trav = NULL; - char key[GF_DUMP_MAX_BUF_LEN]; - int i = 1; - int ret = -1; - - GF_VALIDATE_OR_GOTO ("server", this, out); - - conf = this->private; - if (!conf) { - gf_log (this->name, GF_LOG_WARNING, - "conf null in xlator"); - return -1; - } - - ret = pthread_mutex_trylock (&conf->mutex); - if (ret) - goto out; - - list_for_each_entry (trav, &conf->conns, list) { - ret = pthread_mutex_trylock (&trav->lock); - if (!ret) - { - gf_proc_dump_build_key(key, - "conn","%d.ltable", i); - gf_proc_dump_add_section(key); - ltable_dump (trav); - i++; - pthread_mutex_unlock (&trav->lock); - }else - continue; - } - pthread_mutex_unlock (&conf->mutex); - - ret = 0; -out: - if (ret) - gf_proc_dump_write ("Unable to dump the lock table", - "(Lock acquisition failed) %s", - this?this->name:"server"); - - return ret; -} - static int get_auth_types (dict_t *this, char *key, data_t *value, void *data) @@ -708,9 +495,10 @@ server_rpc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event, { gf_boolean_t detached = _gf_false; xlator_t *this = NULL; - rpc_transport_t *xprt = NULL; - server_connection_t *conn = NULL; + 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, @@ -719,7 +507,7 @@ server_rpc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event, } this = xl; - xprt = data; + trans = data; conf = this->private; switch (event) { @@ -727,17 +515,17 @@ server_rpc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event, { /* Have a structure per new connection */ /* TODO: Should we create anything here at all ? * / - conn = create_server_conn_state (this, xprt); - if (!conn) + client->conn = create_server_conn_state (this, trans); + if (!client->conn) goto out; - xprt->protocol_private = conn; + trans->protocol_private = client->conn; */ - INIT_LIST_HEAD (&xprt->list); + INIT_LIST_HEAD (&trans->list); pthread_mutex_lock (&conf->mutex); { - list_add_tail (&xprt->list, &conf->xprt_list); + list_add_tail (&trans->list, &conf->xprt_list); } pthread_mutex_unlock (&conf->mutex); @@ -750,50 +538,58 @@ server_rpc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event, */ pthread_mutex_lock (&conf->mutex); { - list_del_init (&xprt->list); + list_del_init (&trans->list); } pthread_mutex_unlock (&conf->mutex); - conn = get_server_conn_state (this, xprt); - if (!conn) + client = trans->xl_private; + if (!client) break; gf_log (this->name, GF_LOG_INFO, "disconnecting connection" - "from %s", conn->id); + "from %s", client->client_uid); /* If lock self heal is off, then destroy the conn object, else register a grace timer event */ if (!conf->lk_heal) { - server_conn_ref (conn); - server_connection_put (this, conn, &detached); + gf_client_ref (client); + gf_client_put (client, &detached); if (detached) - server_connection_cleanup (this, conn, - INTERNAL_LOCKS | - POSIX_LOCKS); - server_conn_unref (conn); - } else { - put_server_conn_state (this, xprt); - server_connection_cleanup (this, conn, INTERNAL_LOCKS); + server_connection_cleanup (this, client, + INTERNAL_LOCKS | POSIX_LOCKS); + gf_client_unref (client); + break; + } + trans->xl_private = NULL; + server_connection_cleanup (this, client, INTERNAL_LOCKS); - pthread_mutex_lock (&conn->lock); - { - if (conn->timer) - goto unlock; + serv_ctx = server_ctx_get (client, this); - gf_log (this->name, GF_LOG_INFO, "starting a grace " - "timer for %s", conn->id); + if (serv_ctx == NULL) { + gf_log (this->name, GF_LOG_INFO, + "server_ctx_get() failed"); + goto out; + } + + LOCK (&serv_ctx->fdtable_lock); + { + if (!serv_ctx->grace_timer) { - conn->timer = gf_timer_call_after (this->ctx, - conf->grace_tv, - grace_time_handler, - conn); + gf_log (this->name, GF_LOG_INFO, + "starting a grace timer for %s", + client->client_uid); + + serv_ctx->grace_timer = + gf_timer_call_after (this->ctx, + conf->grace_ts, + grace_time_handler, + client); } - unlock: - pthread_mutex_unlock (&conn->lock); } + UNLOCK (&serv_ctx->fdtable_lock); break; case RPCSVC_EVENT_TRANSPORT_DESTROY: - /*- conn obj has been disassociated from xprt on first + /*- conn obj has been disassociated from trans on first * disconnect. * conn cleanup and destruction is handed over to * grace_time_handler or the subsequent handler that 'owns' @@ -887,14 +683,14 @@ server_init_grace_timer (xlator_t *this, dict_t *options, ret = dict_get_int32 (options, "grace-timeout", &grace_timeout); if (!ret) - conf->grace_tv.tv_sec = grace_timeout; + conf->grace_ts.tv_sec = grace_timeout; else - conf->grace_tv.tv_sec = 10; + conf->grace_ts.tv_sec = 10; gf_log (this->name, GF_LOG_DEBUG, "Server grace timeout " - "value = %"PRIu64, conf->grace_tv.tv_sec); + "value = %"PRIu64, conf->grace_ts.tv_sec); - conf->grace_tv.tv_usec = 0; + conf->grace_ts.tv_nsec = 0; ret = 0; out: @@ -941,12 +737,6 @@ reconfigure (xlator_t *this, dict_t *options) } - /*ret = dict_get_str (options, "statedump-path", &statedump_path); - if (!ret) { - gf_path_strip_trailing_slashes (statedump_path); - GF_FREE (this->ctx->statedump_path); - this->ctx->statedump_path = gf_strdup (statedump_path); - }*/ GF_OPTION_RECONF ("statedump-path", statedump_path, options, path, out); if (!statedump_path) { @@ -985,6 +775,7 @@ reconfigure (xlator_t *this, dict_t *options) (void) rpcsvc_set_allow_insecure (rpc_conf, options); (void) rpcsvc_set_root_squash (rpc_conf, options); + (void) rpcsvc_set_outstanding_rpc_limit (rpc_conf, options); list_for_each_entry (listeners, &(rpc_conf->listeners), list) { if (listeners->trans != NULL) { if (listeners->trans->reconfigure ) @@ -1001,6 +792,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) { @@ -1008,6 +819,8 @@ init (xlator_t *this) server_conf_t *conf = NULL; rpcsvc_listener_t *listener = NULL; char *statedump_path = NULL; + gf_barrier_t *barrier = NULL; + char *str = NULL; GF_VALIDATE_OR_GOTO ("init", this, out); if (this->children == NULL) { @@ -1027,7 +840,6 @@ init (xlator_t *this) GF_VALIDATE_OR_GOTO(this->name, conf, out); - INIT_LIST_HEAD (&conf->conns); INIT_LIST_HEAD (&conf->xprt_list); pthread_mutex_init (&conf->mutex, NULL); @@ -1149,6 +961,37 @@ init (xlator_t *this) } } #endif + /* barrier related */ + barrier = GF_CALLOC (1, sizeof (*barrier),1); + if (!barrier) { + gf_log (this->name, GF_LOG_WARNING, + "WARNING: Failed to allocate barrier"); + ret = -1; + goto out; + } + + LOCK_INIT (&barrier->lock); + INIT_LIST_HEAD (&barrier->queue); + barrier->on = _gf_false; + + GF_OPTION_INIT ("barrier-queue-length", barrier->max_size, + int64, out); + GF_OPTION_INIT ("barrier-timeout", barrier->time_out, + uint64, out); + + ret = dict_get_str (this->options, "barrier-fops", &str); + if (ret) { + gf_log (this->name, GF_LOG_DEBUG, + "setting barrier fops to default value"); + } + ret = gf_barrier_fops_configure (this, barrier, str); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, + "invalid barrier fops specified"); + goto out; + } + + conf->barrier = barrier; this->private = conf; ret = 0; @@ -1202,27 +1045,65 @@ int notify (xlator_t *this, int32_t event, void *data, ...) { int ret = 0; + int32_t val = 0; + dict_t *dict = NULL; + dict_t *output = NULL; + va_list ap; + + dict = data; + va_start (ap, data); + output = va_arg (ap, dict_t*); + va_end (ap); + switch (event) { + case GF_EVENT_VOLUME_BARRIER_OP: + ret = dict_get_int32 (dict, "barrier", &val); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, + "Wrong BARRIER event"); + goto out; + } + /* !val un-barrier, if val, barrier */ + if (val) { + ret = gf_barrier_start (this); + if (ret) + gf_log (this->name, GF_LOG_ERROR, + "Barrier start failed"); + } else { + ret = gf_barrier_stop (this); + if (ret) + gf_log (this->name, GF_LOG_ERROR, + "Barrier stop failed"); + } + ret = dict_set_int32 (output, "barrier-status", ret); + if (ret) + gf_log (this->name, GF_LOG_ERROR, + "Failed to set barrier-status in dict"); + break; + + /* todo: call default_notify to make other xlators handle it.*/ default: default_notify (this, event, data); break; } - +out: return ret; } struct xlator_fops fops; -struct xlator_cbks cbks; +struct xlator_cbks cbks = { + .client_destroy = client_destroy_cbk, +}; struct xlator_dumpops dumpops = { .priv = server_priv, - .fd = server_fd, - .inode = server_inode, + .fd = gf_client_dump_fdtables, + .inode = gf_client_dump_inodes, .priv_to_dict = server_priv_to_dict, - .fd_to_dict = server_fd_to_dict, - .inode_to_dict = server_inode_to_dict, + .fd_to_dict = gf_client_dump_fdtables_to_dict, + .inode_to_dict = gf_client_dump_inodes_to_dict, }; @@ -1311,6 +1192,23 @@ struct volume_options options[] = { "hostnames to connect to the server. By default, all" " connections are allowed." }, - + {.key = {"barrier-timeout"}, + .type = GF_OPTION_TYPE_INT, + .default_value = "60", + .min = 0, + .max = 360, + .description = "Barrier timeout in seconds", + }, + {.key = {"barrier-queue-length"}, + .type = GF_OPTION_TYPE_INT, + .default_value = "4096", + .min = 0, + .max = 16384, + .description = "Barrier queue length", + }, + {.key = {"barrier-fops"}, + .type = GF_OPTION_TYPE_STR, + .description = "Allow a comma seperated fop lists", + }, { .key = {NULL} }, }; diff --git a/xlators/protocol/server/src/server.h b/xlators/protocol/server/src/server.h index e7eccfd11..782327d77 100644 --- a/xlators/protocol/server/src/server.h +++ b/xlators/protocol/server/src/server.h @@ -13,6 +13,7 @@ #include <pthread.h> +#include "fd.h" #include "rpcsvc.h" #include "fd.h" @@ -20,69 +21,47 @@ #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" #define GF_MAX_SOCKET_WINDOW_SIZE (1 * GF_UNIT_MB) #define GF_MIN_SOCKET_WINDOW_SIZE (0) -typedef enum { - INTERNAL_LOCKS = 1, - POSIX_LOCKS = 2, -} server_lock_flags_t; - -typedef struct _server_state server_state_t; - -struct _locker { - struct list_head lockers; - char *volume; - loc_t loc; - fd_t *fd; - gf_lkowner_t owner; - pid_t pid; +struct _gf_barrier_payload { + rpcsvc_request_t *req; + struct iovec rsp; + call_frame_t *frame; + struct iovec *payload; + struct iobref *iobref; + struct iobuf *iob; + int payload_count; + gf_boolean_t free_iobref; + struct list_head list; }; -struct _lock_table { - struct list_head inodelk_lockers; - struct list_head entrylk_lockers; +typedef struct _gf_barrier_payload gf_barrier_payload_t; + +struct _gf_barrier { + gf_lock_t lock; + gf_boolean_t on; + gf_boolean_t force; + size_t cur_size; + int64_t max_size; + uint64_t fops; + gf_timer_t *timer; + uint64_t time_out; + struct list_head queue; }; -/* private structure per connection (transport object) - * used as transport_t->xl_private - */ -struct _server_connection { - struct list_head list; - char *id; - int ref; - int bind_ref; - pthread_mutex_t lock; - fdtable_t *fdtable; - struct _lock_table *ltable; - gf_timer_t *timer; - xlator_t *bound_xl; - xlator_t *this; - uint32_t lk_version; -}; - -typedef struct _server_connection server_connection_t; - - -server_connection_t * -server_connection_get (xlator_t *this, const char *id); +typedef struct _gf_barrier gf_barrier_t; -server_connection_t * -server_connection_put (xlator_t *this, server_connection_t *conn, - gf_boolean_t *detached); - -server_connection_t* -server_conn_unref (server_connection_t *conn); - -server_connection_t* -server_conn_ref (server_connection_t *conn); +typedef enum { + INTERNAL_LOCKS = 1, + POSIX_LOCKS = 2, +} server_lock_flags_t; -int -server_connection_cleanup (xlator_t *this, server_connection_t *conn, - int32_t flags); +typedef struct _server_state server_state_t; int server_null (rpcsvc_request_t *req); @@ -102,11 +81,12 @@ struct server_conf { heal is on else off. */ char *conf_dir; struct _volfile_ctx *volfile; - struct timeval grace_tv; + struct timespec grace_ts; dict_t *auth_modules; pthread_mutex_t mutex; - struct list_head conns; + gf_barrier_t *barrier; struct list_head xprt_list; + pthread_t barrier_th; }; typedef struct server_conf server_conf_t; @@ -144,11 +124,10 @@ int resolve_and_resume (call_frame_t *frame, server_resume_fn_t fn); struct _server_state { - server_connection_t *conn; - 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; @@ -184,7 +163,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; @@ -192,10 +171,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, @@ -204,6 +193,4 @@ server_submit_reply (call_frame_t *frame, rpcsvc_request_t *req, void *arg, int gf_server_check_setxattr_cmd (call_frame_t *frame, dict_t *dict); int gf_server_check_getxattr_cmd (call_frame_t *frame, const char *name); -void ltable_dump (server_connection_t *conn); - #endif /* !_SERVER_H */ |
