接上次說到的objecter的流程正什,現(xiàn)在看下文件的寫入在osd側(cè)的流程啥纸。
OSD::ms_fast_dispatch -> OSD::enqueue_op,enqueue_op會(huì)把請(qǐng)求入到op_shardedwq的隊(duì)列中婴氮,op_shardedwq是一個(gè)按照pg做sharded的多線程的任務(wù)隊(duì)列斯棒,其中每個(gè)隊(duì)列的任務(wù)也是有多個(gè)線程在執(zhí)行的,相關(guān)配置有: osd_op_num_shards主经、osd_op_num_threads_per_shard荣暮。
op_sharededwq里的請(qǐng)求,最終由OSD::ShardedOpWQ::_process來進(jìn)行處理罩驻。
這里用到了boost::static_visitor模式穗酥,用這種方式來實(shí)現(xiàn)多態(tài)。
調(diào)用的方法實(shí)際上是這個(gè):
void PGQueueable::RunVis::operator()(const OpRequestRef &op) {
return osd->dequeue_op(pg, op, handle);
}
然后是 pg->do_request(op, handle);
在然后void PrimaryLogPG::do_request( OpRequestRef& op, ThreadPool::TPHandle &handle)
注意惠遏,在這一步有判斷pg的狀態(tài)砾跃,如果pg不是active并且peered的話,請(qǐng)求會(huì)加到waiting_for_peered等待隊(duì)列里节吮,等pg狀態(tài)正常了才會(huì)處理:
if (!is_peered()) {
// Delay unless PGBackend says it's ok
if (pgbackend->can_handle_while_inactive(op)) {
bool handled = pgbackend->handle_message(op);
assert(handled);
return;
} else {
waiting_for_peered.push_back(op);
op->mark_delayed("waiting for peered");
return;
}
}
后面PrimaryLogPG::do_op(OpRequestRef& op)
PrimaryLogPG::execute_ctx
然后這里進(jìn)行事務(wù)相關(guān)的處理抽高。
PrimaryLogPG::execute_ctx里會(huì)調(diào)用prepare_transaction,然后再調(diào)用issue_repop课锌,在issue_repop里調(diào)用了pgbackend->submit_transaction厨内。