summaryrefslogtreecommitdiffstats
path: root/xlators/protocol/server
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/protocol/server')
-rw-r--r--xlators/protocol/server/src/server-helpers.c36
-rw-r--r--xlators/protocol/server/src/server-rpc-fops.c126
-rw-r--r--xlators/protocol/server/src/server.h4
3 files changed, 165 insertions, 1 deletions
diff --git a/xlators/protocol/server/src/server-helpers.c b/xlators/protocol/server/src/server-helpers.c
index 146c13c3c2f..dc127a6cdcd 100644
--- a/xlators/protocol/server/src/server-helpers.c
+++ b/xlators/protocol/server/src/server-helpers.c
@@ -1309,3 +1309,39 @@ server_inode_new (inode_table_t *itable, uuid_t gfid) {
return inode_new (itable);
}
+int
+unserialize_req_locklist (gfs3_setactivelk_req *req,
+ lock_migration_info_t *lmi)
+{
+ struct gfs3_locklist *trav = NULL;
+ lock_migration_info_t *temp = NULL;
+ char *buf = NULL;
+ int entry_len = 0;
+ int ret = -1;
+
+ trav = req->request;
+
+ INIT_LIST_HEAD (&lmi->list);
+
+ while (trav) {
+ temp = GF_CALLOC (1, sizeof (*lmi), gf_common_mt_lock_mig);
+ if (temp == NULL) {
+ gf_msg (THIS->name, GF_LOG_ERROR, 0, 0, "No memory");
+ goto out;
+ }
+
+ INIT_LIST_HEAD (&temp->list);
+
+ gf_proto_flock_to_flock (&trav->flock, &temp->flock);
+
+ temp->client_uid = gf_strdup (trav->client_uid);
+
+ list_add_tail (&temp->list, &lmi->list);
+
+ trav = trav->nextentry;
+ }
+
+ ret = 0;
+out:
+ return ret;
+}
diff --git a/xlators/protocol/server/src/server-rpc-fops.c b/xlators/protocol/server/src/server-rpc-fops.c
index 8a1b14bf7f6..72824781406 100644
--- a/xlators/protocol/server/src/server-rpc-fops.c
+++ b/xlators/protocol/server/src/server-rpc-fops.c
@@ -2209,6 +2209,44 @@ out:
return 0;
}
+static int
+server_setactivelk_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, dict_t *xdata)
+{
+ gfs3_setactivelk_rsp rsp = {0,};
+ server_state_t *state = NULL;
+ rpcsvc_request_t *req = NULL;
+ int ret = 0;
+
+ state = CALL_STATE (frame);
+
+ 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_msg (this->name, GF_LOG_INFO,
+ op_errno, 0,
+ "%"PRId64": SETACTIVELK %s (%s) ==> (%s)",
+ frame->root->unique, state->loc.path,
+ uuid_utoa (state->resolve.gfid),
+ strerror (op_errno));
+ goto 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_setactivelk_rsp);
+
+ GF_FREE (rsp.xdata.xdata_val);
+
+ return 0;
+}
/* Resume function section */
@@ -3375,6 +3413,28 @@ err:
}
+int
+server_setactivelk_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_setactivelk_cbk,
+ bound_xl, bound_xl->fops->setactivelk, &state->loc,
+ &state->locklist, state->xdata);
+ return 0;
+err:
+ server_setactivelk_cbk (frame, NULL, frame->this,
+ state->resolve.op_ret,
+ state->resolve.op_errno, NULL);
+ return 0;
+
+}
+
/* Fop section */
int
@@ -6646,6 +6706,69 @@ out:
return ret;
}
+
+static int
+server3_3_setactivelk (rpcsvc_request_t *req)
+{
+ server_state_t *state = NULL;
+ call_frame_t *frame = NULL;
+ gfs3_setactivelk_req args = {{0,},};
+ size_t headers_size = 0;
+ int ret = -1;
+ int op_errno = 0;
+
+ if (!req)
+ return ret;
+
+ ret = xdr_to_generic (req->msg[0], &args,
+ (xdrproc_t)xdr_gfs3_setactivelk_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_SETACTIVELK;
+
+ 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);
+
+ /* here, dict itself works as 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 = unserialize_req_locklist (&args, &state->locklist);
+ if (ret)
+ goto out;
+
+ ret = 0;
+
+ resolve_and_resume (frame, server_setactivelk_resume);
+out:
+ free (args.xdata.xdata_val);
+
+ if (op_errno)
+ SERVER_REQ_SET_ERROR (req, ret);
+
+ free (args.xdata.xdata_val);
+
+ return ret;
+}
+
rpcsvc_actor_t glusterfs3_3_fop_actors[GLUSTER_FOP_PROCCNT] = {
[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},
@@ -6697,7 +6820,8 @@ rpcsvc_actor_t glusterfs3_3_fop_actors[GLUSTER_FOP_PROCCNT] = {
[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},
- [GFS3_OP_GETACTIVELK] = {"GETACTIVELK", GFS3_OP_GETACTIVELK, server3_3_getactivelk, NULL, 0, DRC_NA},
+ [GFS3_OP_GETACTIVELK] = {"GETACTIVELK", GFS3_OP_GETACTIVELK, server3_3_getactivelk, NULL, 0, DRC_NA},
+ [GFS3_OP_SETACTIVELK] = {"SETACTIVELK", GFS3_OP_SETACTIVELK, server3_3_setactivelk, NULL, 0, DRC_NA},
};
diff --git a/xlators/protocol/server/src/server.h b/xlators/protocol/server/src/server.h
index f2140dbb087..163cf2b9918 100644
--- a/xlators/protocol/server/src/server.h
+++ b/xlators/protocol/server/src/server.h
@@ -160,6 +160,7 @@ struct _server_state {
dict_t *xdata;
mode_t umask;
struct gf_lease lease;
+ lock_migration_info_t locklist;
};
@@ -185,4 +186,7 @@ int gf_server_check_getxattr_cmd (call_frame_t *frame, const char *name);
void
forget_inode_if_no_dentry (inode_t *inode);
+int
+unserialize_req_locklist (gfs3_setactivelk_req *req,
+ lock_migration_info_t *lmi);
#endif /* !_SERVER_H */