设为首页 收藏本站
查看: 1661|回复: 0

[经验分享] ceph主要数据结构解析1

[复制链接]

尚未签到

发表于 2015-9-10 07:35:38 | 显示全部楼层 |阅读模式
  1.Msgr.h文件:定义消息传输层的数据类型,以供ceph使用


(1)默认的监控端口:
#define CEPH_MON_PORT    6789

(2)客户端处理端口范围定义:




#define CEPH_PORT_FIRST  6789//监控
#define CEPH_PORT_START  6800  //开始
#define CEPH_PORT_LAST   6900//结束

(3)tcp协议标识和版本信息:


#define CEPH_BANNER "ceph v027"
#define CEPH_BANNER_MAX_LEN 30//最大长度

(4)ceph中的实体名称:在网络传输中使用,例如mds0表示元数据服务器0


struct ceph_entity_name {
__u8 type;      /* CEPH_ENTITY_TYPE_* */
__le64 num;
} __attribute__ ((packed));//按照紧凑模式分配内存,而不是内存对齐
#define CEPH_ENTITY_TYPE_MON    0x01//监控服务器实体
#define CEPH_ENTITY_TYPE_MDS    0x02//元数据服务器实体
#define CEPH_ENTITY_TYPE_OSD    0x04//对象存储设备实体
#define CEPH_ENTITY_TYPE_CLIENT 0x08//客户端实体
#define CEPH_ENTITY_TYPE_AUTH   0x20//权限实体
#define CEPH_ENTITY_TYPE_ANY    0xFF//任何

同时提供一个函数用于将类型转换为名字字符串的函数如下:


const char *ceph_entity_type_name(int type)
{
switch (type) {
case CEPH_ENTITY_TYPE_MDS: return "mds";
case CEPH_ENTITY_TYPE_OSD: return "osd";
case CEPH_ENTITY_TYPE_MON: return "mon";
case CEPH_ENTITY_TYPE_CLIENT: return "client";
case CEPH_ENTITY_TYPE_AUTH: return "auth";
default: return "unknown";
}
}

(5)实体网络地址以及与名字实体的对应关系结构体


struct ceph_entity_addr {
__le32 type;
__le32 nonce;  /* unique id for process (e.g. pid) */
struct sockaddr_storage in_addr;
} __attribute__ ((packed));
struct ceph_entity_inst {
struct ceph_entity_name name;
struct ceph_entity_addr addr;
} __attribute__ ((packed));

(6)消息交换协议定义:


#define CEPH_MSGR_TAG_READY         1  /* server->client: ready for messages */
#define CEPH_MSGR_TAG_RESETSESSION  2  /* server->client: reset, try again */
#define CEPH_MSGR_TAG_WAIT          3  /* server->client: wait for racing
incoming connection */
#define CEPH_MSGR_TAG_RETRY_SESSION 4  /* server->client + cseq: try again
with higher cseq */
#define CEPH_MSGR_TAG_RETRY_GLOBAL  5  /* server->client + gseq: try again
with higher gseq */
#define CEPH_MSGR_TAG_CLOSE         6  /* closing pipe */
#define CEPH_MSGR_TAG_MSG           7  /* message */
#define CEPH_MSGR_TAG_ACK           8  /* message ack */
#define CEPH_MSGR_TAG_KEEPALIVE     9  /* just a keepalive byte! */
#define CEPH_MSGR_TAG_BADPROTOVER  10  /* bad protocol version */
#define CEPH_MSGR_TAG_BADAUTHORIZER 11 /* bad authorizer */
#define CEPH_MSGR_TAG_FEATURES      12 /* insufficient features */
#define CEPH_MSGR_TAG_SEQ           13 /* 64-bit int follows with seen seq number */

(7)连接协商


struct ceph_msg_connect {//连接消息结构体
__le64 features;     /* supported feature bits */支持的特征位
__le32 host_type;    /* CEPH_ENTITY_TYPE_* */上面提到的实体类型
__le32 global_seq;   /* count connections initiated by this host */主机初始化的连接数量
__le32 connect_seq;  /* count connections initiated in this session */在这个对话中的连接数量
__le32 protocol_version;//协议版本
__le32 authorizer_protocol;//权限协议
__le32 authorizer_len;//权限长度
__u8  flags;         /* CEPH_MSG_CONNECT_* */
} __attribute__ ((packed));
struct ceph_msg_connect_reply {//连接回复消息结构体
__u8 tag;//上面定义传递消息的类型
__le64 features;     /* feature bits for this session */这个对话的特征位
__le32 global_seq;
__le32 connect_seq;
__le32 protocol_version;
__le32 authorizer_len;
__u8 flags;
} __attribute__ ((packed));
#define CEPH_MSG_CONNECT_LOSSY  1  /* messages i send may be safely dropped */

(8)消息头部结构:有老的


struct ceph_msg_header_old {
__le64 seq;       /* message seq# for this session */消息序列号
__le64 tid;       /* transaction id */传输id
__le16 type;      /* message type */消息类型
__le16 priority;  /* priority.  higher value == higher priority */优先级,值高优先级就高
__le16 version;   /* version of message encoding */消息编码版本
__le32 front_len; /* bytes in main payload */开头主要的有效数据的长度
__le32 middle_len;/* bytes in middle payload */
__le32 data_len;  /* bytes of data payload */数据
__le16 data_off;  /* sender: include full offset;
receiver: mask against ~PAGE_MASK */
struct ceph_entity_inst src, orig_src;
__le32 reserved;
__le32 crc;       /* header crc32c */
} __attribute__ ((packed));
struct ceph_msg_header {
__le64 seq;       /* message seq# for this session */
__le64 tid;       /* transaction id */
__le16 type;      /* message type */
__le16 priority;  /* priority.  higher value == higher priority */
__le16 version;   /* version of message encoding */
__le32 front_len; /* bytes in main payload */
__le32 middle_len;/* bytes in middle payload */
__le32 data_len;  /* bytes of data payload */
__le16 data_off;  /* sender: include full offset;
receiver: mask against ~PAGE_MASK */
struct ceph_entity_name src;
/* oldest code we think can decode this.  unknown if zero. */
__le16 compat_version;
__le16 reserved;
__le32 crc;       /* header crc32c */
} __attribute__ ((packed));
#define CEPH_MSG_PRIO_LOW     64
#define CEPH_MSG_PRIO_DEFAULT 127
#define CEPH_MSG_PRIO_HIGH    196
#define CEPH_MSG_PRIO_HIGHEST 255

(9)数据有效载荷结构


struct ceph_msg_footer {
__le32 front_crc, middle_crc, data_crc;
__u8 flags;
} __attribute__ ((packed));
#define CEPH_MSG_FOOTER_COMPLETE  (1<<0)   /* msg wasn't aborted */
#define CEPH_MSG_FOOTER_NOCRC     (1<<1)   /* no data crc */

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-111643-1-1.html 上篇帖子: ceph相关 下篇帖子: ceph rpm foor rhel6
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表