diff options
author | Amar Tumballi <amar@gluster.com> | 2010-05-04 00:37:01 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2010-05-03 23:40:10 -0700 |
commit | 7840d9de272ef2f24c4c755a857ad8ae06703b55 (patch) | |
tree | 6d212b7d72f00605b80503508c146b205280208c /xlators/protocol | |
parent | f75b76350747f5f58a4bbe704915c74979cc5ac3 (diff) |
frame's 'op', 'type' restructured
Signed-off-by: Amar Tumballi <amar@gluster.com>
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
BUG: 875 (Implement a new protocol to provide proper backward/forward compatibility)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=875
Diffstat (limited to 'xlators/protocol')
-rw-r--r-- | xlators/protocol/client/src/client-protocol.c | 245 | ||||
-rw-r--r-- | xlators/protocol/lib/src/Makefile.am | 4 | ||||
-rw-r--r-- | xlators/protocol/lib/src/protocol.c | 108 | ||||
-rw-r--r-- | xlators/protocol/lib/src/protocol.h | 171 | ||||
-rw-r--r-- | xlators/protocol/server/src/server-protocol.c | 185 |
5 files changed, 384 insertions, 329 deletions
diff --git a/xlators/protocol/client/src/client-protocol.c b/xlators/protocol/client/src/client-protocol.c index df890cc3c..c5554ac98 100644 --- a/xlators/protocol/client/src/client-protocol.c +++ b/xlators/protocol/client/src/client-protocol.c @@ -61,7 +61,7 @@ protocol_client_xfer (call_frame_t *frame, xlator_t *this, transport_t *trans, int protocol_client_post_handshake (call_frame_t *frame, xlator_t *this); -static gf_op_t gf_fops[GF_FOP_MAXVALUE]; +static gf_op_t gf_fops[GF_PROTO_FOP_MAXVALUE]; static gf_op_t gf_mops[GF_MOP_MAXVALUE]; static gf_op_t gf_cbks[GF_CBK_MAXVALUE]; @@ -731,7 +731,7 @@ client_create (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_LOWLAT), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_CREATE, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_CREATE, hdr, hdrlen, NULL, 0, NULL); return ret; unwind: @@ -800,7 +800,7 @@ client_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_LOWLAT), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_OPEN, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_OPEN, hdr, hdrlen, NULL, 0, NULL); return ret; @@ -855,7 +855,7 @@ client_stat (call_frame_t *frame, xlator_t *this, loc_t *loc) ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_LOWLAT), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_STAT, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_STAT, hdr, hdrlen, NULL, 0, NULL); return ret; @@ -911,7 +911,7 @@ client_readlink (call_frame_t *frame, xlator_t *this, loc_t *loc, size_t size) ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_LOWLAT), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_READLINK, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_READLINK, hdr, hdrlen, NULL, 0, NULL); return ret; @@ -980,7 +980,7 @@ client_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_LOWLAT), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_MKNOD, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_MKNOD, hdr, hdrlen, NULL, 0, NULL); return ret; @@ -1046,7 +1046,7 @@ client_mkdir (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode) ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_LOWLAT), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_MKDIR, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_MKDIR, hdr, hdrlen, NULL, 0, NULL); return ret; @@ -1102,7 +1102,7 @@ client_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc) ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_BULK), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_UNLINK, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_UNLINK, hdr, hdrlen, NULL, 0, NULL); return ret; @@ -1158,7 +1158,7 @@ client_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc) ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_BULK), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_RMDIR, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_RMDIR, hdr, hdrlen, NULL, 0, NULL); return ret; @@ -1228,7 +1228,7 @@ client_symlink (call_frame_t *frame, xlator_t *this, const char *linkname, ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_LOWLAT), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_SYMLINK, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_SYMLINK, hdr, hdrlen, NULL, 0, NULL); return ret; unwind: @@ -1308,7 +1308,7 @@ client_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc, ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_LOWLAT), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_RENAME, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_RENAME, hdr, hdrlen, NULL, 0, NULL); return ret; unwind: @@ -1391,7 +1391,7 @@ client_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc) ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_LOWLAT), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_LINK, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_LINK, hdr, hdrlen, NULL, 0, NULL); return ret; unwind: @@ -1445,7 +1445,7 @@ client_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset) ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_BULK), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_TRUNCATE, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_TRUNCATE, hdr, hdrlen, NULL, 0, NULL); return ret; @@ -1518,7 +1518,7 @@ client_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_BULK), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_READ, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_READ, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -1592,7 +1592,7 @@ client_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_BULK), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_WRITE, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_WRITE, hdr, hdrlen, vector, count, iobref); return ret; unwind: @@ -1648,7 +1648,7 @@ client_statfs (call_frame_t *frame, xlator_t *this, loc_t *loc) ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_LOWLAT), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_STATFS, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_STATFS, hdr, hdrlen, NULL, 0, NULL); return ret; @@ -1716,7 +1716,7 @@ client_flush (call_frame_t *frame, xlator_t *this, fd_t *fd) ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_BULK), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_FLUSH, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_FLUSH, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -1785,7 +1785,7 @@ client_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags) ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_BULK), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_FSYNC, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_FSYNC, hdr, hdrlen, NULL, 0, NULL); return ret; @@ -1854,7 +1854,7 @@ client_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc, ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_BULK), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_XATTROP, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_XATTROP, hdr, hdrlen, NULL, 0, NULL); return ret; unwind: @@ -1938,7 +1938,7 @@ client_fxattrop (call_frame_t *frame, xlator_t *this, fd_t *fd, ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_BULK), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_FXATTROP, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_FXATTROP, hdr, hdrlen, NULL, 0, NULL); return ret; unwind: @@ -2015,7 +2015,7 @@ client_setxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_BULK), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_SETXATTR, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_SETXATTR, hdr, hdrlen, NULL, 0, NULL); return ret; unwind: @@ -2106,7 +2106,7 @@ client_fsetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_BULK), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_FSETXATTR, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_FSETXATTR, hdr, hdrlen, NULL, 0, NULL); return ret; unwind: @@ -2166,7 +2166,7 @@ client_getxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_LOWLAT), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_GETXATTR, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_GETXATTR, hdr, hdrlen, NULL, 0, NULL); return ret; unwind: @@ -2245,7 +2245,7 @@ client_fgetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_LOWLAT), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_FGETXATTR, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_FGETXATTR, hdr, hdrlen, NULL, 0, NULL); return ret; unwind: @@ -2304,7 +2304,7 @@ client_removexattr (call_frame_t *frame, xlator_t *this, loc_t *loc, ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_LOWLAT), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_REMOVEXATTR, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_REMOVEXATTR, hdr, hdrlen, NULL, 0, NULL); return ret; unwind: @@ -2366,7 +2366,7 @@ client_opendir (call_frame_t *frame, xlator_t *this, loc_t *loc, ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_LOWLAT), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_OPENDIR, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_OPENDIR, hdr, hdrlen, NULL, 0, NULL); return ret; @@ -2432,7 +2432,7 @@ client_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_LOWLAT), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_READDIRP, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_READDIRP, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -2500,7 +2500,7 @@ client_readdir (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_LOWLAT), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_READDIR, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_READDIR, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -2566,7 +2566,7 @@ client_fsyncdir (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags) ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_BULK), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_FSYNCDIR, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_FSYNCDIR, hdr, hdrlen, NULL, 0, NULL); return ret; @@ -2619,7 +2619,7 @@ client_access (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t mask) ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_LOWLAT), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_ACCESS, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_ACCESS, hdr, hdrlen, NULL, 0, NULL); return ret; @@ -2688,7 +2688,7 @@ client_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_BULK), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_FTRUNCATE, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_FTRUNCATE, hdr, hdrlen, NULL, 0, NULL); return ret; @@ -2754,7 +2754,7 @@ client_fstat (call_frame_t *frame, xlator_t *this, fd_t *fd) ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_BULK), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_FSTAT, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_FSTAT, hdr, hdrlen, NULL, 0, NULL); return ret; @@ -2853,7 +2853,7 @@ client_lk (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t cmd, ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_BULK), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_LK, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_LK, hdr, hdrlen, NULL, 0, NULL); return ret; unwind: @@ -2945,7 +2945,7 @@ client_inodelk (call_frame_t *frame, xlator_t *this, const char *volume, ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_BULK), GF_OP_TYPE_FOP_REQUEST, - GF_FOP_INODELK, + GF_PROTO_FOP_INODELK, hdr, hdrlen, NULL, 0, NULL); return ret; unwind: @@ -3052,7 +3052,7 @@ client_finodelk (call_frame_t *frame, xlator_t *this, const char *volume, ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_BULK), GF_OP_TYPE_FOP_REQUEST, - GF_FOP_FINODELK, + GF_PROTO_FOP_FINODELK, hdr, hdrlen, NULL, 0, NULL); return ret; unwind: @@ -3113,7 +3113,7 @@ client_entrylk (call_frame_t *frame, xlator_t *this, const char *volume, ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_LOWLAT), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_ENTRYLK, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_ENTRYLK, hdr, hdrlen, NULL, 0, NULL); return ret; @@ -3191,7 +3191,7 @@ client_fentrylk (call_frame_t *frame, xlator_t *this, const char *volume, ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_LOWLAT), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_FENTRYLK, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_FENTRYLK, hdr, hdrlen, NULL, 0, NULL); return ret; @@ -3289,7 +3289,7 @@ client_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_LOWLAT), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_LOOKUP, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_LOOKUP, hdr, hdrlen, NULL, 0, NULL); return ret; @@ -3339,7 +3339,7 @@ client_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc, ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_BULK), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_SETATTR, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_SETATTR, hdr, hdrlen, NULL, 0, NULL); return ret; @@ -3402,7 +3402,7 @@ client_fsetattr (call_frame_t *frame, xlator_t *this, fd_t *fd, ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_BULK), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_FSETATTR, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_FSETATTR, hdr, hdrlen, NULL, 0, NULL); return ret; @@ -5174,68 +5174,6 @@ client_getspec_cbk (call_frame_t *frame, gf_hdr_common_t *hdr, size_t hdrlen, return 0; } - -int -client_log (call_frame_t *frame, xlator_t *this, const char *msg) -{ - gf_hdr_common_t * hdr = NULL; - gf_mop_log_req_t * req = NULL; - size_t hdrlen = -1; - int msglen = 0; - int ret = -1; - - if (msg) - msglen = STRLEN_0 (msg); - - hdrlen = gf_hdr_len (req, msglen); - hdr = gf_hdr_new (req, msglen); - - GF_VALIDATE_OR_GOTO (this->name, hdr, unwind); - - req = gf_param (hdr); - req->msglen = hton32 (msglen); - - if (msglen) - strcpy (req->msg, msg); - - ret = protocol_client_xfer (frame, this, - CLIENT_CHANNEL (this, CHANNEL_BULK), - GF_OP_TYPE_MOP_REQUEST, GF_MOP_LOG, - hdr, hdrlen, NULL, 0, NULL); - - return ret; - -unwind: - if (hdr) - GF_FREE (hdr); - - STACK_UNWIND (frame, -1, EINVAL, NULL); - return 0; -} - - -int -client_log_cbk (call_frame_t *frame, gf_hdr_common_t *hdr, size_t hdrlen, - struct iobuf *iobuf) -{ - gf_mop_log_rsp_t * rsp = NULL; - - int32_t op_ret = 0; - int32_t op_errno = 0; - int32_t gf_errno = 0; - - op_ret = ntoh32 (hdr->rsp.op_ret); - gf_errno = ntoh32 (hdr->rsp.op_errno); - op_errno = gf_error_to_errno (gf_errno); - - rsp = gf_param (hdr); - - STACK_UNWIND (frame, op_ret, op_errno); - - return 0; -} - - int client_checksum (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flag) { @@ -5265,7 +5203,7 @@ client_checksum (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flag) ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_BULK), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_CHECKSUM, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_CHECKSUM, hdr, hdrlen, NULL, 0, NULL); return ret; @@ -5348,7 +5286,7 @@ client_rchecksum (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_BULK), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_RCHECKSUM, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_RCHECKSUM, hdr, hdrlen, NULL, 0, NULL); return ret; @@ -5514,7 +5452,7 @@ protocol_client_reopendir (xlator_t *this, client_fd_ctx_t *fdctx) ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_LOWLAT), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_OPENDIR, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_OPENDIR, hdr, hdrlen, NULL, 0, NULL); return ret; @@ -5638,7 +5576,7 @@ protocol_client_reopen (xlator_t *this, client_fd_ctx_t *fdctx) ret = protocol_client_xfer (frame, this, CLIENT_CHANNEL (this, CHANNEL_LOWLAT), - GF_OP_TYPE_FOP_REQUEST, GF_FOP_OPEN, + GF_OP_TYPE_FOP_REQUEST, GF_PROTO_FOP_OPEN, hdr, hdrlen, NULL, 0, NULL); return ret; @@ -5996,46 +5934,55 @@ client_forget_cbk (call_frame_t *frame, gf_hdr_common_t *hdr, size_t hdrlen, } +int +client_log_cbk (call_frame_t *frame, gf_hdr_common_t *hdr, size_t hdrlen, + struct iobuf *iobuf) +{ + gf_log ("", GF_LOG_CRITICAL, "fop not implemented"); + return 0; +} + + static gf_op_t gf_fops[] = { - [GF_FOP_STAT] = client_stat_cbk, - [GF_FOP_READLINK] = client_readlink_cbk, - [GF_FOP_MKNOD] = client_mknod_cbk, - [GF_FOP_MKDIR] = client_mkdir_cbk, - [GF_FOP_UNLINK] = client_unlink_cbk, - [GF_FOP_RMDIR] = client_rmdir_cbk, - [GF_FOP_SYMLINK] = client_symlink_cbk, - [GF_FOP_RENAME] = client_rename_cbk, - [GF_FOP_LINK] = client_link_cbk, - [GF_FOP_TRUNCATE] = client_truncate_cbk, - [GF_FOP_OPEN] = client_open_cbk, - [GF_FOP_READ] = client_readv_cbk, - [GF_FOP_WRITE] = client_write_cbk, - [GF_FOP_STATFS] = client_statfs_cbk, - [GF_FOP_FLUSH] = client_flush_cbk, - [GF_FOP_FSYNC] = client_fsync_cbk, - [GF_FOP_SETXATTR] = client_setxattr_cbk, - [GF_FOP_GETXATTR] = client_getxattr_cbk, - [GF_FOP_REMOVEXATTR] = client_removexattr_cbk, - [GF_FOP_OPENDIR] = client_opendir_cbk, - [GF_FOP_FSYNCDIR] = client_fsyncdir_cbk, - [GF_FOP_ACCESS] = client_access_cbk, - [GF_FOP_CREATE] = client_create_cbk, - [GF_FOP_FTRUNCATE] = client_ftruncate_cbk, - [GF_FOP_FSTAT] = client_fstat_cbk, - [GF_FOP_LK] = client_lk_common_cbk, - [GF_FOP_LOOKUP] = client_lookup_cbk, - [GF_FOP_READDIR] = client_readdir_cbk, - [GF_FOP_READDIRP] = client_readdirp_cbk, - [GF_FOP_INODELK] = client_inodelk_cbk, - [GF_FOP_FINODELK] = client_finodelk_cbk, - [GF_FOP_ENTRYLK] = client_entrylk_cbk, - [GF_FOP_FENTRYLK] = client_fentrylk_cbk, - [GF_FOP_CHECKSUM] = client_checksum_cbk, - [GF_FOP_RCHECKSUM] = client_rchecksum_cbk, - [GF_FOP_XATTROP] = client_xattrop_cbk, - [GF_FOP_FXATTROP] = client_fxattrop_cbk, - [GF_FOP_SETATTR] = client_setattr_cbk, - [GF_FOP_FSETATTR] = client_fsetattr_cbk + [GF_PROTO_FOP_STAT] = client_stat_cbk, + [GF_PROTO_FOP_READLINK] = client_readlink_cbk, + [GF_PROTO_FOP_MKNOD] = client_mknod_cbk, + [GF_PROTO_FOP_MKDIR] = client_mkdir_cbk, + [GF_PROTO_FOP_UNLINK] = client_unlink_cbk, + [GF_PROTO_FOP_RMDIR] = client_rmdir_cbk, + [GF_PROTO_FOP_SYMLINK] = client_symlink_cbk, + [GF_PROTO_FOP_RENAME] = client_rename_cbk, + [GF_PROTO_FOP_LINK] = client_link_cbk, + [GF_PROTO_FOP_TRUNCATE] = client_truncate_cbk, + [GF_PROTO_FOP_OPEN] = client_open_cbk, + [GF_PROTO_FOP_READ] = client_readv_cbk, + [GF_PROTO_FOP_WRITE] = client_write_cbk, + [GF_PROTO_FOP_STATFS] = client_statfs_cbk, + [GF_PROTO_FOP_FLUSH] = client_flush_cbk, + [GF_PROTO_FOP_FSYNC] = client_fsync_cbk, + [GF_PROTO_FOP_SETXATTR] = client_setxattr_cbk, + [GF_PROTO_FOP_GETXATTR] = client_getxattr_cbk, + [GF_PROTO_FOP_REMOVEXATTR] = client_removexattr_cbk, + [GF_PROTO_FOP_OPENDIR] = client_opendir_cbk, + [GF_PROTO_FOP_FSYNCDIR] = client_fsyncdir_cbk, + [GF_PROTO_FOP_ACCESS] = client_access_cbk, + [GF_PROTO_FOP_CREATE] = client_create_cbk, + [GF_PROTO_FOP_FTRUNCATE] = client_ftruncate_cbk, + [GF_PROTO_FOP_FSTAT] = client_fstat_cbk, + [GF_PROTO_FOP_LK] = client_lk_common_cbk, + [GF_PROTO_FOP_LOOKUP] = client_lookup_cbk, + [GF_PROTO_FOP_READDIR] = client_readdir_cbk, + [GF_PROTO_FOP_READDIRP] = client_readdirp_cbk, + [GF_PROTO_FOP_INODELK] = client_inodelk_cbk, + [GF_PROTO_FOP_FINODELK] = client_finodelk_cbk, + [GF_PROTO_FOP_ENTRYLK] = client_entrylk_cbk, + [GF_PROTO_FOP_FENTRYLK] = client_fentrylk_cbk, + [GF_PROTO_FOP_CHECKSUM] = client_checksum_cbk, + [GF_PROTO_FOP_RCHECKSUM] = client_rchecksum_cbk, + [GF_PROTO_FOP_XATTROP] = client_xattrop_cbk, + [GF_PROTO_FOP_FXATTROP] = client_fxattrop_cbk, + [GF_PROTO_FOP_SETATTR] = client_setattr_cbk, + [GF_PROTO_FOP_FSETATTR] = client_fsetattr_cbk }; static gf_op_t gf_mops[] = { @@ -6089,7 +6036,7 @@ protocol_client_interpret (xlator_t *this, transport_t *trans, switch (type) { case GF_OP_TYPE_FOP_REPLY: - if ((op > GF_FOP_MAXVALUE) || + if ((op > GF_PROTO_FOP_MAXVALUE) || (op < 0)) { gf_log (trans->xl->name, GF_LOG_WARNING, "invalid fop '%d'", op); @@ -6206,6 +6153,8 @@ init (xlator_t *this) conf = GF_CALLOC (1, sizeof (client_conf_t), gf_client_mt_client_conf_t); + protocol_common_init (); + pthread_mutex_init (&conf->mutex, NULL); INIT_LIST_HEAD (&conf->saved_fds); @@ -6698,11 +6647,7 @@ struct xlator_fops fops = { .fxattrop = client_fxattrop, .setattr = client_setattr, .fsetattr = client_fsetattr, -}; - -struct xlator_mops mops = { .getspec = client_getspec, - .log = client_log, }; struct xlator_cbks cbks = { diff --git a/xlators/protocol/lib/src/Makefile.am b/xlators/protocol/lib/src/Makefile.am index d3d1aafe1..53131f6d0 100644 --- a/xlators/protocol/lib/src/Makefile.am +++ b/xlators/protocol/lib/src/Makefile.am @@ -7,9 +7,9 @@ libgfproto_la_CPPFLAGS = -D_FILE_OFFSET_BITS=64 -D__USE_FILE_OFFSET64 -D_GNU_SOU libgfproto_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la -lib_LTLIBRARIES = libgfproto.la +lib_LTLIBRARIES = libgfproto.la -libgfproto_la_SOURCES = transport.c authenticate.c +libgfproto_la_SOURCES = transport.c authenticate.c protocol.c noinst_HEADERS = transport.h protocol.h authenticate.h diff --git a/xlators/protocol/lib/src/protocol.c b/xlators/protocol/lib/src/protocol.c new file mode 100644 index 000000000..63950f43d --- /dev/null +++ b/xlators/protocol/lib/src/protocol.c @@ -0,0 +1,108 @@ + +#include "globals.h" +#include "compat.h" +#include "protocol.h" + +char *gf_mop_list[GF_MOP_MAXVALUE]; +char *gf_cbk_list[GF_CBK_MAXVALUE]; + +static int +gf_dirent_nb_size (gf_dirent_t *entries) +{ + return (sizeof (struct gf_dirent_nb) + strlen (entries->d_name) + 1); +} + +int +gf_dirent_serialize (gf_dirent_t *entries, char *buf, size_t buf_size) +{ + struct gf_dirent_nb *entry_nb = NULL; + gf_dirent_t *entry = NULL; + int size = 0; + int entry_size = 0; + + + list_for_each_entry (entry, &entries->list, list) { + entry_size = gf_dirent_nb_size (entry); + + if (buf && (size + entry_size <= buf_size)) { + entry_nb = (void *) (buf + size); + + entry_nb->d_ino = hton64 (entry->d_ino); + entry_nb->d_off = hton64 (entry->d_off); + entry_nb->d_len = hton32 (entry->d_len); + entry_nb->d_type = hton32 (entry->d_type); + + gf_stat_from_iatt (&entry_nb->d_stat, &entry->d_stat); + + strcpy (entry_nb->d_name, entry->d_name); + } + size += entry_size; + } + + return size; +} + + +int +gf_dirent_unserialize (gf_dirent_t *entries, const char *buf, size_t buf_size) +{ + struct gf_dirent_nb *entry_nb = NULL; + int remaining_size = 0; + int least_dirent_size = 0; + int count = 0; + gf_dirent_t *entry = NULL; + int entry_strlen = 0; + int entry_len = 0; + + + remaining_size = buf_size; + least_dirent_size = (sizeof (struct gf_dirent_nb) + 2); + + while (remaining_size >= least_dirent_size) { + entry_nb = (void *)(buf + (buf_size - remaining_size)); + + entry_strlen = strnlen (entry_nb->d_name, remaining_size); + if (entry_strlen == remaining_size) { + break; + } + + entry_len = sizeof (gf_dirent_t) + entry_strlen + 1; + entry = GF_CALLOC (1, entry_len, gf_common_mt_gf_dirent_t); + if (!entry) { + break; + } + + entry->d_ino = ntoh64 (entry_nb->d_ino); + entry->d_off = ntoh64 (entry_nb->d_off); + entry->d_len = ntoh32 (entry_nb->d_len); + entry->d_type = ntoh32 (entry_nb->d_type); + + gf_stat_to_iatt (&entry_nb->d_stat, &entry->d_stat); + + strcpy (entry->d_name, entry_nb->d_name); + + list_add_tail (&entry->list, &entries->list); + + remaining_size -= (sizeof (*entry_nb) + entry_strlen + 1); + count++; + } + + return count; +} + +int +protocol_common_init (void) +{ + gf_mop_list[GF_MOP_SETVOLUME] = "SETVOLUME"; + gf_mop_list[GF_MOP_GETVOLUME] = "GETVOLUME"; + gf_mop_list[GF_MOP_SETSPEC] = "SETSPEC"; + gf_mop_list[GF_MOP_GETSPEC] = "GETSPEC"; + gf_mop_list[GF_MOP_LOG] = "LOG"; + gf_mop_list[GF_MOP_PING] = "PING"; + + gf_cbk_list[GF_CBK_FORGET] = "FORGET"; + gf_cbk_list[GF_CBK_RELEASE] = "RELEASE"; + gf_cbk_list[GF_CBK_RELEASEDIR] = "RELEASEDIR"; + + return 0; +} diff --git a/xlators/protocol/lib/src/protocol.h b/xlators/protocol/lib/src/protocol.h index 6fd291bbe..254e36e66 100644 --- a/xlators/protocol/lib/src/protocol.h +++ b/xlators/protocol/lib/src/protocol.h @@ -42,6 +42,89 @@ #define GF_PROTOCOL_VERSION "3.0" +extern char *gf_mop_list[]; +extern char *gf_cbk_list[]; + +/* NOTE: add members ONLY at the end (just before _MAXVALUE) */ +typedef enum { + GF_PROTO_FOP_STAT, /* 0 */ + GF_PROTO_FOP_READLINK, /* 1 */ + GF_PROTO_FOP_MKNOD, /* 2 */ + GF_PROTO_FOP_MKDIR, + GF_PROTO_FOP_UNLINK, + GF_PROTO_FOP_RMDIR, /* 5 */ + GF_PROTO_FOP_SYMLINK, + GF_PROTO_FOP_RENAME, + GF_PROTO_FOP_LINK, + GF_PROTO_FOP_TRUNCATE, + GF_PROTO_FOP_OPEN, /* 10 */ + GF_PROTO_FOP_READ, + GF_PROTO_FOP_WRITE, + GF_PROTO_FOP_STATFS, /* 15 */ + GF_PROTO_FOP_FLUSH, + GF_PROTO_FOP_FSYNC, + GF_PROTO_FOP_SETXATTR, + GF_PROTO_FOP_GETXATTR, + GF_PROTO_FOP_REMOVEXATTR,/* 20 */ + GF_PROTO_FOP_OPENDIR, + GF_PROTO_FOP_GETDENTS, + GF_PROTO_FOP_FSYNCDIR, + GF_PROTO_FOP_ACCESS, + GF_PROTO_FOP_CREATE, /* 25 */ + GF_PROTO_FOP_FTRUNCATE, + GF_PROTO_FOP_FSTAT, + GF_PROTO_FOP_LK, + GF_PROTO_FOP_LOOKUP, + GF_PROTO_FOP_SETDENTS, + GF_PROTO_FOP_READDIR, + GF_PROTO_FOP_INODELK, /* 35 */ + GF_PROTO_FOP_FINODELK, + GF_PROTO_FOP_ENTRYLK, + GF_PROTO_FOP_FENTRYLK, + GF_PROTO_FOP_CHECKSUM, + GF_PROTO_FOP_XATTROP, /* 40 */ + GF_PROTO_FOP_FXATTROP, + GF_PROTO_FOP_LOCK_NOTIFY, + GF_PROTO_FOP_LOCK_FNOTIFY, + GF_PROTO_FOP_FGETXATTR, + GF_PROTO_FOP_FSETXATTR, /* 45 */ + GF_PROTO_FOP_RCHECKSUM, + GF_PROTO_FOP_SETATTR, + GF_PROTO_FOP_FSETATTR, + GF_PROTO_FOP_READDIRP, + GF_PROTO_FOP_MAXVALUE, +} glusterfs_proto_fop_t; + +/* NOTE: add members ONLY at the end (just before _MAXVALUE) */ +typedef enum { + GF_MOP_SETVOLUME, /* 0 */ + GF_MOP_GETVOLUME, /* 1 */ + GF_MOP_STATS, + GF_MOP_SETSPEC, + GF_MOP_GETSPEC, + GF_MOP_PING, /* 5 */ + GF_MOP_LOG, + GF_MOP_NOTIFY, + GF_MOP_MAXVALUE, /* 8 */ +} glusterfs_mop_t; + +typedef enum { + GF_CBK_FORGET, /* 0 */ + GF_CBK_RELEASE, /* 1 */ + GF_CBK_RELEASEDIR, /* 2 */ + GF_CBK_MAXVALUE /* 3 */ +} glusterfs_cbk_t; + +typedef enum { + GF_OP_TYPE_FOP_REQUEST = 1, + GF_OP_TYPE_MOP_REQUEST, + GF_OP_TYPE_CBK_REQUEST, + GF_OP_TYPE_FOP_REPLY, + GF_OP_TYPE_MOP_REPLY, + GF_OP_TYPE_CBK_REPLY +} glusterfs_op_type_t; + + struct gf_stat { uint64_t ino; uint64_t size; @@ -1026,89 +1109,11 @@ struct gf_dirent_nb { char d_name[0]; } __attribute__((packed)); +int +gf_dirent_unserialize (gf_dirent_t *entries, const char *buf, size_t buf_size); +int +gf_dirent_serialize (gf_dirent_t *entries, char *buf, size_t buf_size); -static inline int -gf_dirent_nb_size (gf_dirent_t *entries) -{ - return (sizeof (struct gf_dirent_nb) + strlen (entries->d_name) + 1); -} - -static inline int -gf_dirent_serialize (gf_dirent_t *entries, char *buf, size_t buf_size) -{ - struct gf_dirent_nb *entry_nb = NULL; - gf_dirent_t *entry = NULL; - int size = 0; - int entry_size = 0; - - - list_for_each_entry (entry, &entries->list, list) { - entry_size = gf_dirent_nb_size (entry); - - if (buf && (size + entry_size <= buf_size)) { - entry_nb = (void *) (buf + size); - - entry_nb->d_ino = hton64 (entry->d_ino); - entry_nb->d_off = hton64 (entry->d_off); - entry_nb->d_len = hton32 (entry->d_len); - entry_nb->d_type = hton32 (entry->d_type); - - gf_stat_from_iatt (&entry_nb->d_stat, &entry->d_stat); - - strcpy (entry_nb->d_name, entry->d_name); - } - size += entry_size; - } - - return size; -} - - -static inline int -gf_dirent_unserialize (gf_dirent_t *entries, const char *buf, size_t buf_size) -{ - struct gf_dirent_nb *entry_nb = NULL; - int remaining_size = 0; - int least_dirent_size = 0; - int count = 0; - gf_dirent_t *entry = NULL; - int entry_strlen = 0; - int entry_len = 0; - - - remaining_size = buf_size; - least_dirent_size = (sizeof (struct gf_dirent_nb) + 2); - - while (remaining_size >= least_dirent_size) { - entry_nb = (void *)(buf + (buf_size - remaining_size)); - - entry_strlen = strnlen (entry_nb->d_name, remaining_size); - if (entry_strlen == remaining_size) { - break; - } - - entry_len = sizeof (gf_dirent_t) + entry_strlen + 1; - entry = GF_CALLOC (1, entry_len, gf_common_mt_gf_dirent_t); - if (!entry) { - break; - } - - entry->d_ino = ntoh64 (entry_nb->d_ino); - entry->d_off = ntoh64 (entry_nb->d_off); - entry->d_len = ntoh32 (entry_nb->d_len); - entry->d_type = ntoh32 (entry_nb->d_type); - - gf_stat_to_iatt (&entry_nb->d_stat, &entry->d_stat); - - strcpy (entry->d_name, entry_nb->d_name); - - list_add_tail (&entry->list, &entries->list); - - remaining_size -= (sizeof (*entry_nb) + entry_strlen + 1); - count++; - } - - return count; -} +int protocol_common_init (void); #endif diff --git a/xlators/protocol/server/src/server-protocol.c b/xlators/protocol/server/src/server-protocol.c index 079b3f2e4..b5f90c3a5 100644 --- a/xlators/protocol/server/src/server-protocol.c +++ b/xlators/protocol/server/src/server-protocol.c @@ -388,7 +388,7 @@ server_lk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, strerror (op_errno)); } - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_LK, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_LK, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -433,7 +433,7 @@ server_inodelk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, strerror (op_errno)); } - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_INODELK, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_INODELK, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -480,7 +480,7 @@ server_finodelk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, strerror (op_errno)); } - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_FINODELK, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_FINODELK, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -536,7 +536,7 @@ server_entrylk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, strerror (op_errno)); } - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_ENTRYLK, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_ENTRYLK, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -580,7 +580,7 @@ server_fentrylk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, strerror (op_errno)); } - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_FENTRYLK, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_FENTRYLK, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -617,7 +617,7 @@ server_access_cbk (call_frame_t *frame, void *cookie, xlator_t *this, gf_errno = gf_errno_to_error (op_errno); hdr->rsp.op_errno = hton32 (gf_errno); - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_ACCESS, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_ACCESS, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -676,7 +676,7 @@ server_rmdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, gf_stat_from_iatt (&rsp->postparent, postparent); } - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_RMDIR, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_RMDIR, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -732,7 +732,7 @@ server_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, op_ret, strerror (op_errno)); } - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_MKDIR, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_MKDIR, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -788,7 +788,7 @@ server_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this, op_ret, strerror (op_errno)); } - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_MKNOD, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_MKNOD, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -832,7 +832,7 @@ server_fsyncdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, gf_errno = gf_errno_to_error (op_errno); hdr->rsp.op_errno = hton32 (gf_errno); - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_FSYNCDIR, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_FSYNCDIR, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -885,7 +885,7 @@ server_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, strerror (op_errno)); } - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_READDIR, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_READDIR, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -975,7 +975,7 @@ server_opendir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, hdr->rsp.op_errno = hton32 (gf_errno); rsp->fd = hton64 (fd_no); - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_OPENDIR, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_OPENDIR, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -1016,7 +1016,7 @@ server_statfs_cbk (call_frame_t *frame, void *cookie, xlator_t *this, gf_statfs_from_statfs (&rsp->statfs, buf); } - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_STATFS, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_STATFS, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -1052,7 +1052,7 @@ server_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, gf_errno = gf_errno_to_error (op_errno); hdr->rsp.op_errno = hton32 (gf_errno); - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_REMOVEXATTR, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_REMOVEXATTR, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -1116,7 +1116,7 @@ server_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, gf_errno = gf_errno_to_error (op_errno); hdr->rsp.op_errno = hton32 (gf_errno); - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_GETXATTR, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_GETXATTR, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -1170,7 +1170,7 @@ server_fgetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, gf_errno = gf_errno_to_error (op_errno); hdr->rsp.op_errno = hton32 (gf_errno); - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_FGETXATTR, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_FGETXATTR, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -1207,7 +1207,7 @@ server_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, gf_errno = gf_errno_to_error (op_errno); hdr->rsp.op_errno = hton32 (gf_errno); - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_SETXATTR, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_SETXATTR, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -1234,7 +1234,7 @@ server_fsetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, gf_errno = gf_errno_to_error (op_errno); hdr->rsp.op_errno = hton32 (gf_errno); - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_FSETXATTR, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_FSETXATTR, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -1297,7 +1297,7 @@ server_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this, gf_stat_from_iatt (&rsp->postnewparent, postnewparent); } - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_RENAME, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_RENAME, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -1363,7 +1363,7 @@ server_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, gf_stat_from_iatt (&rsp->postparent, postparent); } - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_UNLINK, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_UNLINK, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -1419,7 +1419,7 @@ server_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, op_ret, strerror (op_errno)); } - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_SYMLINK, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_SYMLINK, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -1487,7 +1487,7 @@ server_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this, op_ret, strerror (op_errno)); } - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_LINK, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_LINK, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -1537,7 +1537,7 @@ server_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, op_ret, strerror (op_errno)); } - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_TRUNCATE, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_TRUNCATE, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -1584,7 +1584,7 @@ server_fstat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, strerror (op_errno)); } - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_FSTAT, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_FSTAT, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -1633,7 +1633,7 @@ server_ftruncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, strerror (op_errno)); } - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_FTRUNCATE, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_FTRUNCATE, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -1677,7 +1677,7 @@ server_flush_cbk (call_frame_t *frame, void *cookie, xlator_t *this, gf_errno = gf_errno_to_error (op_errno); hdr->rsp.op_errno = hton32 (gf_errno); - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_FLUSH, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_FLUSH, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -1727,7 +1727,7 @@ server_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this, gf_stat_from_iatt (&(rsp->poststat), postbuf); } - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_FSYNC, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_FSYNC, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -1809,7 +1809,7 @@ server_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, strerror (op_errno)); } - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_WRITE, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_WRITE, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -1860,7 +1860,7 @@ server_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this, strerror (op_errno)); } - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_READ, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_READ, hdr, hdrlen, vector, count, iobref); return 0; @@ -1916,7 +1916,7 @@ server_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, hdr->rsp.op_errno = hton32 (gf_errno); rsp->fd = hton64 (fd_no); - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_OPEN, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_OPEN, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -2017,7 +2017,7 @@ server_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, gf_stat_from_iatt (&rsp->postparent, postparent); } - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_CREATE, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_CREATE, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -2071,7 +2071,7 @@ server_readlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, strcpy (rsp->path, buf); } - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_READLINK, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_READLINK, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -2118,7 +2118,7 @@ server_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, op_ret, strerror (op_errno)); } - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_STAT, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_STAT, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -2168,7 +2168,7 @@ server_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, op_ret, strerror (op_errno)); } - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_SETATTR, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_SETATTR, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -2218,7 +2218,7 @@ server_fsetattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, op_ret, strerror (op_errno)); } - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_FSETATTR, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_FSETATTR, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -2341,7 +2341,7 @@ server_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, op_ret, strerror (op_errno)); } - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_LOOKUP, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_LOOKUP, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -2404,7 +2404,7 @@ server_xattrop_cbk (call_frame_t *frame, void *cookie, xlator_t *this, gf_errno = gf_errno_to_error (op_errno); hdr->rsp.op_errno = hton32 (gf_errno); - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_XATTROP, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_XATTROP, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -2469,7 +2469,7 @@ server_fxattrop_cbk (call_frame_t *frame, void *cookie, xlator_t *this, hdr->rsp.op_errno = hton32 (gf_errno); - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_FXATTROP, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_FXATTROP, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -3879,7 +3879,7 @@ server_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this, strerror (op_errno)); } - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_READDIRP, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_READDIRP, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -5116,7 +5116,7 @@ server_checksum_cbk (call_frame_t *frame, void *cookie, xlator_t *this, rsp->dchecksum[NAME_MAX + NAME_MAX] = '\0'; } - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_CHECKSUM, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_CHECKSUM, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -5200,7 +5200,7 @@ server_rchecksum_cbk (call_frame_t *frame, void *cookie, xlator_t *this, rsp->strong_checksum[MD5_DIGEST_LEN] = '\0'; } - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_RCHECKSUM, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_RCHECKSUM, hdr, hdrlen, NULL, 0, NULL); return 0; @@ -5650,7 +5650,7 @@ server_setdents (call_frame_t *frame, xlator_t *bound_xl, hdr->rsp.op_errno = hton32 (gf_errno); hdr->rsp.op_ret = -1; - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_SETDENTS, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_SETDENTS, rsp_hdr, rsp_hdrlen, NULL, 0, NULL); return 0; @@ -5674,7 +5674,7 @@ server_getdents (call_frame_t *frame, xlator_t *bound_xl, hdr->rsp.op_errno = hton32 (gf_errno); hdr->rsp.op_ret = -1; - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_GETDENTS, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_GETDENTS, rsp_hdr, rsp_hdrlen, NULL, 0, NULL); return 0; @@ -5698,7 +5698,7 @@ server_lock_notify (call_frame_t *frame, xlator_t *bound_xl, hdr->rsp.op_errno = hton32 (gf_errno); hdr->rsp.op_ret = -1; - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_LOCK_NOTIFY, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_LOCK_NOTIFY, rsp_hdr, rsp_hdrlen, NULL, 0, NULL); return 0; @@ -5722,7 +5722,7 @@ server_lock_fnotify (call_frame_t *frame, xlator_t *bound_xl, hdr->rsp.op_errno = hton32 (gf_errno); hdr->rsp.op_ret = -1; - protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_FOP_LOCK_FNOTIFY, + protocol_server_reply (frame, GF_OP_TYPE_FOP_REPLY, GF_PROTO_FOP_LOCK_FNOTIFY, rsp_hdr, rsp_hdrlen, NULL, 0, NULL); return 0; @@ -5901,51 +5901,51 @@ typedef int32_t (*gf_op_t) (call_frame_t *frame, xlator_t *bould_xl, static gf_op_t gf_fops[] = { - [GF_FOP_STAT] = server_stat, - [GF_FOP_READLINK] = server_readlink, - [GF_FOP_MKNOD] = server_mknod, - [GF_FOP_MKDIR] = server_mkdir, - [GF_FOP_UNLINK] = server_unlink, - [GF_FOP_RMDIR] = server_rmdir, - [GF_FOP_SYMLINK] = server_symlink, - [GF_FOP_RENAME] = server_rename, - [GF_FOP_LINK] = server_link, - [GF_FOP_TRUNCATE] = server_truncate, - [GF_FOP_OPEN] = server_open, - [GF_FOP_READ] = server_readv, - [GF_FOP_WRITE] = server_writev, - [GF_FOP_STATFS] = server_statfs, - [GF_FOP_FLUSH] = server_flush, - [GF_FOP_FSYNC] = server_fsync, - [GF_FOP_SETXATTR] = server_setxattr, - [GF_FOP_GETXATTR] = server_getxattr, - [GF_FOP_FGETXATTR] = server_fgetxattr, - [GF_FOP_FSETXATTR] = server_fsetxattr, - [GF_FOP_REMOVEXATTR] = server_removexattr, - [GF_FOP_OPENDIR] = server_opendir, - [GF_FOP_FSYNCDIR] = server_fsyncdir, - [GF_FOP_ACCESS] = server_access, - [GF_FOP_CREATE] = server_create, - [GF_FOP_FTRUNCATE] = server_ftruncate, - [GF_FOP_FSTAT] = server_fstat, - [GF_FOP_LK] = server_lk, - [GF_FOP_LOOKUP] = server_lookup, - [GF_FOP_READDIR] = server_readdir, - [GF_FOP_READDIRP] = server_readdirp, - [GF_FOP_INODELK] = server_inodelk, - [GF_FOP_FINODELK] = server_finodelk, - [GF_FOP_ENTRYLK] = server_entrylk, - [GF_FOP_FENTRYLK] = server_fentrylk, - [GF_FOP_CHECKSUM] = server_checksum, - [GF_FOP_RCHECKSUM] = server_rchecksum, - [GF_FOP_XATTROP] = server_xattrop, - [GF_FOP_FXATTROP] = server_fxattrop, - [GF_FOP_SETATTR] = server_setattr, - [GF_FOP_FSETATTR] = server_fsetattr, - [GF_FOP_SETDENTS] = server_setdents, - [GF_FOP_GETDENTS] = server_getdents, - [GF_FOP_LOCK_NOTIFY] = server_lock_notify, - [GF_FOP_LOCK_FNOTIFY] = server_lock_fnotify, + [GF_PROTO_FOP_STAT] = server_stat, + [GF_PROTO_FOP_READLINK] = server_readlink, + [GF_PROTO_FOP_MKNOD] = server_mknod, + [GF_PROTO_FOP_MKDIR] = server_mkdir, + [GF_PROTO_FOP_UNLINK] = server_unlink, + [GF_PROTO_FOP_RMDIR] = server_rmdir, + [GF_PROTO_FOP_SYMLINK] = server_symlink, + [GF_PROTO_FOP_RENAME] = server_rename, + [GF_PROTO_FOP_LINK] = server_link, + [GF_PROTO_FOP_TRUNCATE] = server_truncate, + [GF_PROTO_FOP_OPEN] = server_open, + [GF_PROTO_FOP_READ] = server_readv, + [GF_PROTO_FOP_WRITE] = server_writev, + [GF_PROTO_FOP_STATFS] = server_statfs, + [GF_PROTO_FOP_FLUSH] = server_flush, + [GF_PROTO_FOP_FSYNC] = server_fsync, + [GF_PROTO_FOP_SETXATTR] = server_setxattr, + [GF_PROTO_FOP_GETXATTR] = server_getxattr, + [GF_PROTO_FOP_FGETXATTR] = server_fgetxattr, + [GF_PROTO_FOP_FSETXATTR] = server_fsetxattr, + [GF_PROTO_FOP_REMOVEXATTR] = server_removexattr, + [GF_PROTO_FOP_OPENDIR] = server_opendir, + [GF_PROTO_FOP_FSYNCDIR] = server_fsyncdir, + [GF_PROTO_FOP_ACCESS] = server_access, + [GF_PROTO_FOP_CREATE] = server_create, + [GF_PROTO_FOP_FTRUNCATE] = server_ftruncate, + [GF_PROTO_FOP_FSTAT] = server_fstat, + [GF_PROTO_FOP_LK] = server_lk, + [GF_PROTO_FOP_LOOKUP] = server_lookup, + [GF_PROTO_FOP_READDIR] = server_readdir, + [GF_PROTO_FOP_READDIRP] = server_readdirp, + [GF_PROTO_FOP_INODELK] = server_inodelk, + [GF_PROTO_FOP_FINODELK] = server_finodelk, + [GF_PROTO_FOP_ENTRYLK] = server_entrylk, + [GF_PROTO_FOP_FENTRYLK] = server_fentrylk, + [GF_PROTO_FOP_CHECKSUM] = server_checksum, + [GF_PROTO_FOP_RCHECKSUM] = server_rchecksum, + [GF_PROTO_FOP_XATTROP] = server_xattrop, + [GF_PROTO_FOP_FXATTROP] = server_fxattrop, + [GF_PROTO_FOP_SETATTR] = server_setattr, + [GF_PROTO_FOP_FSETATTR] = server_fsetattr, + [GF_PROTO_FOP_SETDENTS] = server_setdents, + [GF_PROTO_FOP_GETDENTS] = server_getdents, + [GF_PROTO_FOP_LOCK_NOTIFY] = server_lock_notify, + [GF_PROTO_FOP_LOCK_FNOTIFY] = server_lock_fnotify, }; @@ -5989,7 +5989,7 @@ protocol_server_interpret (xlator_t *this, transport_t *trans, peerinfo = &trans->peerinfo; switch (type) { case GF_OP_TYPE_FOP_REQUEST: - if ((op < 0) || (op >= GF_FOP_MAXVALUE)) { + if ((op < 0) || (op >= GF_PROTO_FOP_MAXVALUE)) { gf_log (this->name, GF_LOG_ERROR, "invalid fop %"PRId32" from client %s", op, peerinfo->identifier); @@ -6529,9 +6529,6 @@ notify (xlator_t *this, int32_t event, void *data, ...) } -struct xlator_mops mops = { -}; - struct xlator_fops fops = { }; |