一、主OSD读处理流程
OSD::ms_fast_dispatch()
|__OSD::dispatch_session_waiting()
|__OSD::dispatch_op_fast()
|__OSD::handle_op()
|__OSD::get_pg_or_queue_for_pg() 找到OpRequest中对应的PG和Pool信息
|__OSD::enqueue_op()
|__PG::queue_op()
|__OSD::ShardedThreadPool::ShardedWQ::queue() 将PG和Op一起放入队列中
OSD::ShardedOpWQ::_process() 负责处理OSD::ShardedThreadPool::ShardedWQ队列中的Op
|__PGQueueable::RunVis::operator()(const OpRequestRef &op)
|__OSD::dequeue_op()
|__ReplicatedPG::do_request()
|__检查当前PG是否处于flush或peering状态,若是则将op放入waiting_for_peered队列中等待PG变成可用状态
|__检查当前PG是否处于Active状态,若不是则将op放入waiting_for_active队列中
|__检查当前PG是否处于REPLAY状态,若是则将op放入waiting_for_active队列中
|__ReplicatedPG::do_op()
|__RepliatedPG::do_pg_op() 对于请求中包含对PG的操作CEPH_OSD_RMW_FLAG_PGOP
|__根据op请求创建hobject_t类对象(head)
|__检查对象名字长度/对象locator key长度/对象locator名称空间长度是否大于osd_max_object_name_len
|__通过FileStore检查object的head是否有效
|__检查op请求地址是否在OSDMap的blacklist中
|__对于写请求,检查写请求的数据大小是否大于osd_max_write_size值
|__对于op请求的head目前不可读,则将op放入waiting_for_unreadable_object队列中且调用maybe_kick_recovery()函数尝试启动recovery
|__ReplicatedPG::is_degraded_or_backfilling_object() 检查当前op请求的head是否处于recovery或backfill状态
|__ReplicatedPG::wait_for_degraded_object() 将当前op请求的head放入waiting_for_degraded_object队列中
|__检查head是否在objects_blocked_on_degraded_snap队列中,若是则将当前op请求的head放入waiting_for_degraded_object队列中
|__检查head是否在objects_blocked_on_snap_promotion队列中,若是则将当前op请求的head放入waiting_for_blocked_object队列中
|__检查head是否在objects_blocked_on_cache_full队列中,若是则将当前op请求的head放入waiting_for_cache_not_full队列中
|__检查head的snapdir是否不可读,若是则将head的snapdir放入waiting_for_unreadable_object队列中且调用maybe_kick_recovery()函数尝试启动recovery
|__检查head的snapdir是否处于recovery或backfill状态,若是则将head的snapdir放入waiting_for_degraded_object队列中
|__对于op写请求已经在PGLog中,则若已经完成了写操作则直接给客户端返回MOSDOpReply消息且设置CEPH_OSD_FLAG_ACK,否则将op放入到waiting_for_ack或waiting_for_ondisk队列中
|__ReplicatedPG::find_object_context() 得到object context信息
|__检查object context是否处于io blocked状态,若是则将op请求放入到waiting_for_blocked_object或waiting_for_degraded_object队列中
|__ReplicatedPG::execute_ctx()
|__ReplicatedPG::prepare_transaction()
|__创建MOSDOpReply消息实例
|__调用ReplicatePG::complete_read_ctx() 将读操作的结果返回给client端
来源:oschina
链接:https://my.oschina.net/u/206258/blog/678541