diff options
author | Poornima G <pgurusid@redhat.com> | 2015-07-09 15:22:43 +0530 |
---|---|---|
committer | Pranith Kumar Karampuri <pkarampu@redhat.com> | 2016-04-29 22:37:39 -0700 |
commit | 3c8922d123471de0c5da499420fcac6b10179786 (patch) | |
tree | 0f8df8166f53ae77fa9117beb57db55a19ea08e3 /xlators/protocol/server/src | |
parent | 80e3832ec16f69d4184172cfc9afa9e42533e0ef (diff) |
Protocol: Add lease fop
Change-Id: I64c361d3e4ae86d57dc18bb887758d044c861237
BUG: 1319992
Signed-off-by: Poornima G <pgurusid@redhat.com>
Reviewed-on: http://review.gluster.org/11597
Smoke: Gluster Build System <jenkins@build.gluster.com>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Diffstat (limited to 'xlators/protocol/server/src')
-rw-r--r-- | xlators/protocol/server/src/server-rpc-fops.c | 111 | ||||
-rw-r--r-- | xlators/protocol/server/src/server.c | 29 | ||||
-rw-r--r-- | xlators/protocol/server/src/server.h | 1 |
3 files changed, 129 insertions, 12 deletions
diff --git a/xlators/protocol/server/src/server-rpc-fops.c b/xlators/protocol/server/src/server-rpc-fops.c index b9236705532..adfeb6464c8 100644 --- a/xlators/protocol/server/src/server-rpc-fops.c +++ b/xlators/protocol/server/src/server-rpc-fops.c @@ -192,6 +192,43 @@ out: return 0; } +int +server_lease_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, struct gf_lease *lease, + dict_t *xdata) +{ + gfs3_lease_rsp rsp = {0,}; + rpcsvc_request_t *req = NULL; + server_state_t *state = 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_msg (this->name, fop_log_level (GF_FOP_LEASE, op_errno), + op_errno, PS_MSG_LK_INFO, + "%"PRId64": LEASE %s (%s) ==> " + "(%s)", frame->root->unique, + state->loc.path, + uuid_utoa (state->resolve.gfid), + strerror (op_errno)); + goto out; + } + gf_proto_lease_from_lease (&rsp.lease, lease); + +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_lease_rsp); + + GF_FREE (rsp.xdata.xdata_val); + + return 0; +} int server_lk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, @@ -2204,6 +2241,27 @@ err: } int +server_lease_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_lease_cbk, bound_xl, bound_xl->fops->lease, + &state->loc, &state->lease, state->xdata); + + return 0; + +err: + server_lease_cbk (frame, NULL, frame->this, state->resolve.op_ret, + state->resolve.op_errno, NULL, NULL); + return 0; +} + +int server_lk_resume (call_frame_t *frame, xlator_t *bound_xl) { server_state_t *state = NULL; @@ -6107,6 +6165,58 @@ out: } int +server3_3_lease (rpcsvc_request_t *req) +{ + server_state_t *state = NULL; + call_frame_t *frame = NULL; + gfs3_lease_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_lease_req); + if (ret < 0) { + SERVER_REQ_SET_ERROR (req, ret); + goto out; + } + + frame = get_frame_from_request (req); + if (!frame) { + SERVER_REQ_SET_ERROR (req, ret); + goto out; + } + frame->root->op = GF_FOP_LEASE; + + state = CALL_STATE (frame); + if (!frame->root->client->bound_xl) { + SERVER_REQ_SET_ERROR (req, ret); + goto out; + } + + state->resolve.type = RESOLVE_MUST; + memcpy (state->resolve.gfid, args.gfid, 16); + gf_proto_lease_to_lease (&args.lease, &state->lease); + + 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_lease_resume); +out: + free (args.xdata.xdata_val); + + if (op_errno) + SERVER_REQ_SET_ERROR (req, ret); + + return ret; +} + +int server3_3_lk (rpcsvc_request_t *req) { server_state_t *state = NULL; @@ -6458,6 +6568,7 @@ rpcsvc_actor_t glusterfs3_3_fop_actors[GLUSTER_FOP_PROCCNT] = { [GFS3_OP_ZEROFILL] = {"ZEROFILL", GFS3_OP_ZEROFILL, server3_3_zerofill, NULL, 0, DRC_NA}, [GFS3_OP_IPC] = {"IPC", GFS3_OP_IPC, server3_3_ipc, NULL, 0, DRC_NA}, [GFS3_OP_SEEK] = {"SEEK", GFS3_OP_SEEK, server3_3_seek, NULL, 0, DRC_NA}, + [GFS3_OP_LEASE] = {"LEASE", GFS3_OP_LEASE, server3_3_lease, NULL, 0, DRC_NA}, }; diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c index cb2a0f6c1d9..75b208c98c0 100644 --- a/xlators/protocol/server/src/server.c +++ b/xlators/protocol/server/src/server.c @@ -1176,16 +1176,17 @@ fini (xlator_t *this) int server_process_event_upcall (xlator_t *this, void *data) { - int ret = -1; - server_conf_t *conf = NULL; - client_t *client = NULL; - char *client_uid = NULL; - struct gf_upcall *upcall_data = NULL; - void *up_req = NULL; - rpc_transport_t *xprt = NULL; - enum gf_cbk_procnum cbk_procnum = GF_CBK_NULL; - gfs3_cbk_cache_invalidation_req gf_c_req = {0,}; - xdrproc_t xdrproc; + int ret = -1; + server_conf_t *conf = NULL; + client_t *client = NULL; + char *client_uid = NULL; + struct gf_upcall *upcall_data = NULL; + void *up_req = NULL; + rpc_transport_t *xprt = NULL; + enum gf_cbk_procnum cbk_procnum = GF_CBK_NULL; + gfs3_cbk_cache_invalidation_req gf_c_req = {0,}; + gfs3_recall_lease_req gf_recall_lease = {{0,},}; + xdrproc_t xdrproc; GF_VALIDATE_OR_GOTO(this->name, data, out); @@ -1193,9 +1194,7 @@ server_process_event_upcall (xlator_t *this, void *data) GF_VALIDATE_OR_GOTO(this->name, conf, out); upcall_data = (struct gf_upcall *)data; - client_uid = upcall_data->client_uid; - GF_VALIDATE_OR_GOTO(this->name, client_uid, out); switch (upcall_data->event_type) { @@ -1207,6 +1206,12 @@ server_process_event_upcall (xlator_t *this, void *data) cbk_procnum = GF_CBK_CACHE_INVALIDATION; xdrproc = (xdrproc_t)xdr_gfs3_cbk_cache_invalidation_req; break; + case GF_UPCALL_RECALL_LEASE: + gf_proto_recall_lease_from_upcall (&gf_recall_lease, upcall_data); + up_req = &gf_recall_lease; + cbk_procnum = GF_CBK_RECALL_LEASE; + xdrproc = (xdrproc_t)xdr_gfs3_recall_lease_req; + break; default: gf_msg (this->name, GF_LOG_WARNING, EINVAL, PS_MSG_INVALID_ENTRY, diff --git a/xlators/protocol/server/src/server.h b/xlators/protocol/server/src/server.h index 3172eab5711..f2140dbb087 100644 --- a/xlators/protocol/server/src/server.h +++ b/xlators/protocol/server/src/server.h @@ -159,6 +159,7 @@ struct _server_state { dict_t *xdata; mode_t umask; + struct gf_lease lease; }; |