下面是伪代码object到osd的伪代码
locator =object_name
obj_hash =hash(locator)
pg =obj_hash %num_pg
OSDs_for_pg =crush(pg) # returns a list of OSDs
primary =osds_for_pg[0]
replicas =osds_for_pg[1:]
defcrush(pg):
all_osds=['osd.0','osd.1','osd.2',...]
result=[]
# size is the number of copies; primary+replicas
whilelen(result)<size:
r=hash(pg)
chosen=all_osds[r%len(all_osds)]
ifchoseninresult:
# OSD can be picked only once
continue
result.append(chosen)
returnresult
CRUSH READ
对于Ceph 集群的一次读写操作,客户端首先联系Ceph 的momtor 并获取一个集群
map 副本。集群map 帮助客户端获取Ceph 集群的状态和配置信息。使用对象和池名IID将数据转换为对象。然后将对象和