diff options
Diffstat (limited to 'xlators/protocol')
-rw-r--r-- | xlators/protocol/client/src/client-callback.c | 40 | ||||
-rw-r--r-- | xlators/protocol/client/src/client-messages.h | 15 | ||||
-rw-r--r-- | xlators/protocol/client/src/client-rpc-fops.c | 117 | ||||
-rw-r--r-- | xlators/protocol/client/src/client.c | 29 | ||||
-rw-r--r-- | xlators/protocol/client/src/client.h | 1 | ||||
-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 |
8 files changed, 329 insertions, 14 deletions
diff --git a/xlators/protocol/client/src/client-callback.c b/xlators/protocol/client/src/client-callback.c index 7ee2113762a..4935ef5de7c 100644 --- a/xlators/protocol/client/src/client-callback.c +++ b/xlators/protocol/client/src/client-callback.c @@ -38,6 +38,45 @@ client_cbk_ino_flush (struct rpc_clnt *rpc, void *mydata, void *data) } int +client_cbk_recall_lease (struct rpc_clnt *rpc, void *mydata, void *data) +{ + int ret = -1; + struct iovec *iov = NULL; + struct gf_upcall upcall_data = {0,}; + uuid_t gfid; + struct gf_upcall_recall_lease rl_data = {0,}; + gfs3_recall_lease_req recall_lease = {{0,},}; + + GF_VALIDATE_OR_GOTO ("client-callback", rpc, out); + GF_VALIDATE_OR_GOTO ("client-callback", mydata, out); + GF_VALIDATE_OR_GOTO ("client-callback", data, out); + + iov = (struct iovec *)data; + ret = xdr_to_generic (*iov, &recall_lease, + (xdrproc_t)xdr_gfs3_recall_lease_req); + + if (ret < 0) { + gf_msg (THIS->name, GF_LOG_WARNING, -ret, + PC_MSG_RECALL_LEASE_FAIL, + "XDR decode of recall lease failed."); + goto out; + } + + upcall_data.data = &rl_data; + gf_proto_recall_lease_to_upcall (&recall_lease, &upcall_data); + upcall_data.event_type = GF_UPCALL_RECALL_LEASE; + + gf_msg_trace (THIS->name, 0, "Upcall gfid = %s, ret = %d", + recall_lease.gfid, ret); + + default_notify (THIS, GF_EVENT_UPCALL, &upcall_data); + +out: + return ret; +} + + +int client_cbk_cache_invalidation (struct rpc_clnt *rpc, void *mydata, void *data) { int ret = -1; @@ -128,6 +167,7 @@ rpcclnt_cb_actor_t gluster_cbk_actors[GF_CBK_MAXVALUE] = { [GF_CBK_CACHE_INVALIDATION] = {"CACHE_INVALIDATION", GF_CBK_CACHE_INVALIDATION, client_cbk_cache_invalidation }, [GF_CBK_CHILD_UP] = {"CHILD_UP", GF_CBK_CHILD_UP, client_cbk_child_up }, [GF_CBK_CHILD_DOWN] = {"CHILD_DOWN", GF_CBK_CHILD_DOWN, client_cbk_child_down }, + [GF_CBK_RECALL_LEASE] = {"RECALL_LEASE", GF_CBK_RECALL_LEASE, client_cbk_recall_lease }, }; diff --git a/xlators/protocol/client/src/client-messages.h b/xlators/protocol/client/src/client-messages.h index db27661715b..082a7103674 100644 --- a/xlators/protocol/client/src/client-messages.h +++ b/xlators/protocol/client/src/client-messages.h @@ -45,7 +45,7 @@ */ #define GLFS_PC_BASE GLFS_MSGID_COMP_PC -#define GLFS_PC_NUM_MESSAGES 65 +#define GLFS_PC_NUM_MESSAGES 66 #define GLFS_PC_MSGID_END (GLFS_PC_BASE + GLFS_NUM_MESSAGES + 1) /* Messages with message IDs */ #define glfs_msg_start_x GLFS_PC_BASE, "Invalid: Start of messages" @@ -617,6 +617,7 @@ * @recommendedaction * */ + #define PC_MSG_CHILD_STATUS (GLFS_PC_BASE + 64) /*! @@ -625,7 +626,17 @@ * @recommendedaction * */ -#define PC_MSG_GFID_NULL (GLFS_PC_BASE + 65) + +#define PC_MSG_RECALL_LEASE_FAIL (GLFS_PC_BASE + 65) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ + +#define PC_MSG_GFID_NULL (GLFS_PC_BASE + 66) /*------------*/ #define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" diff --git a/xlators/protocol/client/src/client-rpc-fops.c b/xlators/protocol/client/src/client-rpc-fops.c index c95a973ec72..9e39ebd7242 100644 --- a/xlators/protocol/client/src/client-rpc-fops.c +++ b/xlators/protocol/client/src/client-rpc-fops.c @@ -2524,6 +2524,65 @@ out: } int +client3_3_lease_cbk (struct rpc_req *req, struct iovec *iov, int count, + void *myframe) +{ + call_frame_t *frame = NULL; + struct gf_lease lease = {0,}; + gfs3_lease_rsp rsp = {0,}; + int ret = 0; + xlator_t *this = NULL; + dict_t *xdata = NULL; + + this = THIS; + + frame = myframe; + + if (-1 == req->rpc_status) { + gf_msg (this->name, GF_LOG_ERROR, ENOTCONN, + PC_MSG_REMOTE_OP_FAILED, "Lease fop failed"); + rsp.op_ret = -1; + rsp.op_errno = ENOTCONN; + goto out; + } + + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_lease_rsp); + if (ret < 0) { + gf_msg (this->name, GF_LOG_ERROR, EINVAL, + PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; + } + + if (rsp.op_ret >= 0) { + gf_proto_lease_to_lease (&rsp.lease, &lease); + } + + 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_msg (this->name, GF_LOG_WARNING, + gf_error_to_errno (rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, + "remote operation failed"); + } + + CLIENT_STACK_UNWIND (lease, frame, rsp.op_ret, + gf_error_to_errno (rsp.op_errno), &lease, xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); + + return 0; +} + +int client3_3_lk_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { @@ -5497,6 +5556,62 @@ unwind: } int32_t +client3_3_lease (call_frame_t *frame, xlator_t *this, + void *data) +{ + clnt_args_t *args = NULL; + gfs3_lease_req req = {{0,},}; + int32_t gf_cmd = 0; + int32_t gf_type = 0; + int64_t remote_fd = -1; + clnt_conf_t *conf = NULL; + int op_errno = ESTALE; + int ret = 0; + + GF_VALIDATE_OR_GOTO ("client", this, unwind); + GF_VALIDATE_OR_GOTO (this->name, frame, unwind); + GF_VALIDATE_OR_GOTO (this->name, data, unwind); + + args = data; + conf = this->private; + + if (!(args->loc && args->loc->inode)) + goto unwind; + + if (!gf_uuid_is_null (args->loc->inode->gfid)) + memcpy (req.gfid, args->loc->inode->gfid, 16); + else + memcpy (req.gfid, args->loc->gfid, 16); + + GF_ASSERT_AND_GOTO_WITH_ERROR (this->name, + !gf_uuid_is_null (*((uuid_t *)req.gfid)), + unwind, op_errno, EINVAL); + + gf_proto_lease_from_lease (&req.lease, args->lease); + + 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_LEASE, + client3_3_lease_cbk, NULL, + NULL, 0, NULL, 0, NULL, + (xdrproc_t)xdr_gfs3_lease_req); + if (ret) { + gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, + "failed to send the fop"); + } + + GF_FREE (req.xdata.xdata_val); + + return 0; +unwind: + CLIENT_STACK_UNWIND (lease, frame, -1, op_errno, NULL, NULL); + GF_FREE (req.xdata.xdata_val); + + return 0; +} + +int32_t client3_3_lk (call_frame_t *frame, xlator_t *this, void *data) { @@ -6501,6 +6616,7 @@ rpc_clnt_procedure_t clnt3_3_fop_actors[GF_FOP_MAXVALUE] = { [GF_FOP_FREMOVEXATTR] = { "FREMOVEXATTR", client3_3_fremovexattr }, [GF_FOP_IPC] = { "IPC", client3_3_ipc }, [GF_FOP_SEEK] = { "SEEK", client3_3_seek }, + [GF_FOP_LEASE] = { "LEASE", client3_3_lease }, }; /* Used From RPC-CLNT library to log proper name of procedure based on number */ @@ -6554,6 +6670,7 @@ char *clnt3_3_fop_names[GFS3_OP_MAXVALUE] = { [GFS3_OP_ZEROFILL] = "ZEROFILL", [GFS3_OP_IPC] = "IPC", [GFS3_OP_SEEK] = "SEEK", + [GFS3_OP_LEASE] = "LEASE", }; diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c index f1f58eb822e..aae712acd4b 100644 --- a/xlators/protocol/client/src/client.c +++ b/xlators/protocol/client/src/client.c @@ -1478,6 +1478,34 @@ out: } int32_t +client_lease (call_frame_t *frame, xlator_t *this, loc_t *loc, + struct gf_lease *lease, 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.loc = loc; + args.lease = lease; + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_LEASE]; + if (proc->fn) + ret = proc->fn (frame, this, &args); +out: + if (ret) + STACK_UNWIND_STRICT (lk, frame, -1, ENOTCONN, NULL, NULL); + + return 0; +} + + +int32_t client_lk (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t cmd, struct gf_flock *lock, dict_t *xdata) { @@ -2720,6 +2748,7 @@ struct xlator_fops fops = { .getspec = client_getspec, .ipc = client_ipc, .seek = client_seek, + .lease = client_lease, }; diff --git a/xlators/protocol/client/src/client.h b/xlators/protocol/client/src/client.h index a4d4d9f75a5..20a57a1f855 100644 --- a/xlators/protocol/client/src/client.h +++ b/xlators/protocol/client/src/client.h @@ -213,6 +213,7 @@ typedef struct client_args { int32_t valid; int32_t len; gf_seek_what_t what; + struct gf_lease *lease; mode_t umask; dict_t *xdata; 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; }; |