📄 server-protocol.c
字号:
* @frame: call frame * @cookie: * @this: * @op_ret: return value * @op_errno: errno * @value: * * not for external reference */int32_tserver_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, dict_t *dict){ dict_t *reply = get_new_dict (); dict_set (reply, "RET", data_from_int32 (op_ret)); dict_set (reply, "ERRNO", data_from_int32 (op_errno)); if (op_ret >= 0) { /* Serialize the dictionary and set it as a parameter in 'reply' dict */ int32_t len = 0; char *dict_buf = NULL; dict_set (dict, "__@@protocol_client@@__key", str_to_data ("value")); len = dict_serialized_length (dict); dict_buf = calloc (len, 1); dict_serialize (dict, dict_buf); dict_set (reply, "DICT", data_from_dynptr (dict_buf, len)); } server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_GETXATTR, reply, frame->root->rsp_refs); return 0;}/* * server_setxattr_cbk - setxattr callback for server protocol * @frame: call frame * @cookie: * @this: * @op_ret: return value * @op_errno: errno * * not for external reference */int32_tserver_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno){ dict_t *reply = get_new_dict (); dict_set (reply, "RET", data_from_int32 (op_ret)); dict_set (reply, "ERRNO", data_from_int32 (op_errno)); server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_SETXATTR, reply, frame->root->rsp_refs); return 0;}/* * server_rename_cbk - rename callback for server protocol * @frame: call frame * @cookie: * @this: * @op_ret: return value * @op_errno: errno * * not for external reference */int32_tserver_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct stat *stbuf){ dict_t *reply = get_new_dict (); char *stat_str = NULL; dict_set (reply, "RET", data_from_int32 (op_ret)); dict_set (reply, "ERRNO", data_from_int32 (op_errno)); if (op_ret >= 0) { stat_str = stat_to_str (stbuf); dict_set (reply, "STAT", data_from_dynstr (stat_str)); } server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_RENAME, reply, frame->root->rsp_refs); return 0;}/* * server_unlink_cbk - unlink callback for server protocol * @frame: call frame * @cookie: * @this: * @op_ret: return value * @op_errno: errno * * not for external reference */int32_tserver_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno){ dict_t *reply = get_new_dict (); dict_set (reply, "RET", data_from_int32 (op_ret)); dict_set (reply, "ERRNO", data_from_int32 (op_errno)); server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_UNLINK, reply, frame->root->rsp_refs); return 0;}/* * server_symlink_cbk - symlink callback for server protocol * @frame: call frame * @cookie: * @this: * @op_ret: return value * @op_errno: errno * * not for external reference */int32_tserver_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, inode_t *inode, struct stat *stbuf){ dict_t *reply = get_new_dict (); char *stat_buf = NULL; inode_t *server_inode = NULL; dict_set (reply, "RET", data_from_int32 (op_ret)); dict_set (reply, "ERRNO", data_from_int32 (op_errno)); if (op_ret >= 0) { { server_inode = inode_update (BOUND_XL(frame)->itable, NULL, NULL, stbuf); inode_lookup (server_inode); server_inode->ctx = inode->ctx; inode->ctx = NULL; inode_unref (inode); inode_unref (server_inode); } stat_buf = stat_to_str (stbuf); dict_set (reply, "STAT", data_from_dynstr (stat_buf)); } server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_SYMLINK, reply, frame->root->rsp_refs); return 0;}/* * server_link_cbk - link callback for server protocol * @frame: call frame * @this: * @op_ret: * @op_errno: * @stbuf: * * not for external reference */int32_tserver_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, inode_t *inode, struct stat *stbuf){ dict_t *reply = get_new_dict (); char *stat_buf = NULL; dict_set (reply, "RET", data_from_int32 (op_ret)); dict_set (reply, "ERRNO", data_from_int32 (op_errno)); if (op_ret >= 0) { inode_lookup (inode); stat_buf = stat_to_str (stbuf); dict_set (reply, "STAT", data_from_dynstr (stat_buf)); dict_set (reply, "INODE", data_from_uint64 (inode->ino)); } server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_LINK, reply, frame->root->rsp_refs); return 0;}/* * server_truncate_cbk - truncate callback for server protocol * @frame: call frame * @cookie: * @this: * @op_ret: * @op_errno: * @stbuf: * * not for external reference */int32_tserver_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct stat *stbuf){ dict_t *reply = get_new_dict (); char *stat_buf = NULL; dict_set (reply, "RET", data_from_int32 (op_ret)); dict_set (reply, "ERRNO", data_from_int32 (op_errno)); if (op_ret >= 0) { stat_buf = stat_to_str (stbuf); dict_set (reply, "STAT", data_from_dynstr (stat_buf)); } server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_TRUNCATE, reply, frame->root->rsp_refs); return 0;}/* * server_fstat_cbk - fstat callback for server protocol * @frame: call frame * @cookie: * @this: * @op_ret: * @op_errno: * @stbuf: * * not for external reference */int32_tserver_fstat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct stat *stbuf){ dict_t *reply = get_new_dict (); char *stat_buf = NULL; dict_set (reply, "RET", data_from_int32 (op_ret)); dict_set (reply, "ERRNO", data_from_int32 (op_errno)); if (op_ret >= 0) { stat_buf = stat_to_str (stbuf); dict_set (reply, "STAT", data_from_dynstr (stat_buf)); } server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_FSTAT, reply, frame->root->rsp_refs); return 0;}/* * server_ftruncate_cbk - ftruncate callback for server protocol * @frame: call frame * @cookie: * @this: * @op_ret: * @op_errno: * @stbuf: * * not for external reference */int32_tserver_ftruncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct stat *stbuf){ dict_t *reply = get_new_dict (); char *stat_buf = NULL; dict_set (reply, "RET", data_from_int32 (op_ret)); dict_set (reply, "ERRNO", data_from_int32 (op_errno)); if (op_ret >= 0) { stat_buf = stat_to_str (stbuf); dict_set (reply, "STAT", data_from_dynstr (stat_buf)); } server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_FTRUNCATE, reply, frame->root->rsp_refs); return 0;}/* * server_flush_cbk - flush callback for server protocol * @frame: call frame * @cookie: * @this: * @op_ret: * @op_errno: * * not for external reference */int32_tserver_flush_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno){ dict_t *reply = get_new_dict (); dict_set (reply, "RET", data_from_int32 (op_ret)); dict_set (reply, "ERRNO", data_from_int32 (op_errno)); server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_FLUSH, reply, frame->root->rsp_refs); return 0;}/* * server_fsync_cbk - fsync callback for server protocol * @frame: call frame * @cookie: * @this: * @op_ret: * @op_errno: * * not for external reference */int32_tserver_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno){ dict_t *reply = get_new_dict (); dict_set (reply, "RET", data_from_int32 (op_ret)); dict_set (reply, "ERRNO", data_from_int32 (op_errno)); server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_FSYNC, reply, frame->root->rsp_refs); return 0;}/* * server_close_cbk - close callback for server protocol * @frame: call frame * @cookie: * @this: * @op_ret: * @op_errno: * * not for external reference */int32_tserver_close_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno){ dict_t *reply = get_new_dict (); fd_t *fd = frame->local; frame->local = NULL; dict_set (reply, "RET", data_from_int32 (op_ret)); dict_set (reply, "ERRNO", data_from_int32 (op_errno)); server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_CLOSE, reply, frame->root->rsp_refs); if (fd) fd_destroy (fd); return 0;}/* * server_writev_cbk - writev callback for server protocol * @frame: call frame * @cookie: * @this: * @op_ret: * @op_errno: * * not for external reference */int32_tserver_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct stat *stbuf){ dict_t *reply = get_new_dict (); char *stat_str = NULL; dict_set (reply, "RET", data_from_int32 (op_ret)); dict_set (reply, "ERRNO", data_from_int32 (op_errno)); if (op_ret >= 0) { stat_str = stat_to_str (stbuf); dict_set (reply, "STAT", data_from_dynstr (stat_str)); } server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_WRITE, reply, frame->root->rsp_refs); return 0;}/* * server_readv_cbk - readv callback for server protocol * @frame: call frame * @cookie: * @this: * @op_ret: * @op_errno: * @vector: * @count: * * not for external reference */int32_tserver_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct iovec *vector, int32_t count, struct stat *stbuf){ dict_t *reply = get_new_dict (); char *stat_str = NULL; dict_set (reply, "RET", data_from_int32 (op_ret)); dict_set (reply, "ERRNO", data_from_int32 (op_errno)); if (op_ret >= 0) { dict_set (reply, "BUF", data_from_iovec (vector, count)); stat_str = stat_to_str (stbuf); dict_set (reply, "STAT", data_from_dynstr (stat_str)); } else dict_set (reply, "BUF", str_to_data ("")); server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_READ, reply, frame->root->rsp_refs); return 0;}/* * server_open_cbk - open callback for server protocol * @frame: call frame * @cookie: * @this: * @op_ret: * @op_errno: * @fd: * * not for external reference */ int32_tserver_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, fd_t *fd){ dict_t *reply = get_new_dict (); dict_set (reply, "RET", data_from_int32 (op_ret)); dict_set (reply, "ERRNO", data_from_int32 (op_errno)); if (op_ret >= 0) { server_proto_priv_t *priv = NULL; int32_t fd_no = -1; priv = SERVER_PRIV (frame); fd_no = gf_fd_unused_get (priv->fdtable, fd); dict_set (reply, "FD", data_from_int32 (fd_no)); } server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_OPEN, reply, frame->root->rsp_refs); return 0;}/* * server_create_cbk - create callback for server * @frame: call frame * @cookie: * @this: translator structure * @op_ret: * @op_errno: * @fd: file descriptor * @inode: inode structure * @stbuf: struct stat of created file * * not for external reference */int32_tserver_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, fd_t *fd, inode_t *inode, struct stat *stbuf){ dict_t *reply = get_new_dict (); char *stat_buf = NULL; inode_t *server_inode = NULL; int32_t fd_no = -1; dict_set (reply, "RET", data_from_int32 (op_ret)); dict_set (reply, "ERRNO", data_from_int32 (op_errno)); if (op_ret >= 0) { server_proto_priv_t *priv = NULL; priv = SERVER_PRIV (frame); server_inode = inode_update (BOUND_XL(frame)->itable, NULL, NULL, stbuf); { server_inode->ctx = inode->ctx; inode_lookup (server_inode); inode->ctx = NULL; list_del (&fd->inode_list); LOCK (&server_inode->lock); { list_add (&fd->inode_list, &server_inode->fds); inode_unref (fd->inode); inode_unref (inode); fd->inode = inode_ref (server_inode); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -