(1)集群内部子版本协议类型宏定义:与公共协议保持独立性,以便消息类型和协议升级受影响
#define CEPH_OSDC_PROTOCOL 24 /* server/client */OSD服务器集群与客户端协议版本
#define CEPH_MDSC_PROTOCOL 32 /* server/client */MDS与客户端
#define CEPH_MONC_PROTOCOL 15 /* server/client */监控与客户端
#define CEPH_INO_ROOT 1 //根目录节点的inode号
#define CEPH_INO_CEPH 2 /* hidden .ceph dir */隐藏目录.ceph的inode节点号
/* arbitrary limit on max # of monitors (cluster of 3 is typical) */
#define CEPH_MAX_MON 31 //最大的监控集群数量
(2)文件布局:描述一个文件(inode)的数据布局
struct ceph_file_layout {
/* file -> object mapping */文件到对象的映射
__le32 fl_stripe_unit; /* stripe unit, in bytes. must be multiple
of page size. */条带大小,必须是页的多倍
__le32 fl_stripe_count; /* over this many objects */
__le32 fl_object_size; /* until objects are this big, then move to
new objects */
__le32 fl_cas_hash; /* UNUSED. 0 = none; 1 = sha256 */
/* pg -> disk layout */PG到磁盘的布局
__le32 fl_object_stripe_unit; /* UNUSED. for per-object parity, if any */
/* object -> pg layout */对象到PG的布局
__le32 fl_pg_preferred; /* preferred primary for pg (-1 for none) */
__le32 fl_pg_pool; /* namespace, crush ruleset, rep level */
} __attribute__ ((packed));
#define CEPH_MIN_STRIPE_UNIT 65536//最小的条带单位
//判断文件布局是否有效的函数
int ceph_file_layout_is_valid(const struct ceph_file_layout *layout)
{
__u32 su = le32_to_cpu(layout->fl_stripe_unit);//大小端转换
__u32 sc = le32_to_cpu(layout->fl_stripe_count);
__u32 os = le32_to_cpu(layout->fl_object_size);
/* stripe unit, object size must be non-zero, 64k increment */条带单元和对象大小非零
if (!su || (su & (CEPH_MIN_STRIPE_UNIT-1)))
return 0;
if (!os || (os & (CEPH_MIN_STRIPE_UNIT-1)))
return 0;
/* object size must be a multiple of stripe unit */对象大小必须是条带的整数倍
if (os < su || os % su)
return 0;
/* stripe count must be non-zero */条带数量非零
if (!sc)
return 0;
return 1;
}
struct ceph_dir_layout {//目录的布局
__u8 dl_dir_hash; /* see ceph_hash.h for ids */
__u8 dl_unused1;
__u16 dl_unused2;
__u32 dl_unused3;
} __attribute__ ((packed));
(3)加密算法和安全权限协议宏定义:
#define CEPH_CRYPTO_NONE 0x0 //没有加密
#define CEPH_CRYPTO_AES 0x1 //AES加密
#define CEPH_AES_IV "cephsageyudagreg"
#define CEPH_AUTH_UNKNOWN
0x0 //不知道的权限
#define CEPH_AUTH_NONE
0x1 //没有权限
#define CEPH_AUTH_CEPHX
0x2 // CEPHX
#define CEPH_AUTH_UID_DEFAULT ((__u64) -1)