librados 處理過程

librados是ceph rados對外提供服務的原生api,本文是libradso接口調用的過程(從之前的文中摘錄)。
設置image 的id

ioctx->exec(oid, "rbd", "set_id", in, out)
       >io_ctx_impl->exec(obj, cls, method, inbl, outbl)
           >(::ObjectOperation)rd.call(cls, method, inbl) //將該操作封裝成OSDOp,放入ObjectOperation對象的vector集合中
               >add_call(CEPH_OSD_OP_CALL, cname, method, indata, NULL, NULL, NULL)
           >operate_read(oid, &rd, &outbl) //發起讀請求
               >Objecter::Op *objecter_op = objecter->prepare_read_op(oid, oloc,*o, snap_seq, pbl, flags,onack, &ver) //創建Op的實例   數據結構變成Op
               >objecter->op_submit(objecter_op) //提交到objecter層 操作對象爲Objecter::Op
                   >_op_submit_with_budget(op, lc, ctx_budget)
                       >int op_budget = _take_op_budget(op) //減去該Op的預算for throttle;
                           >int op_budget = calc_op_budget(op) //預算值是該Op的字節大小
                           > _throttle_op(op, op_budget) //這裏是Objecter的Throttle層,如果keep_balanced_budget=true,能實現對速度的限制(op_throttle_bytes&op_throttle_ops)
                       >_op_submit(op, lc)
                           >_calc_target(&op->target, &op->last_force_resend) //計算該op的操作對象(用到CRUSH算法)
                           >_get_session(op->target.osd, &s, lc) //爲該Op構建與osd對應的OSDSession
                           >_send_op_account(op) //登記該次op操作
                           > m = _prepare_osd_op(op) //使用Op中的信息,初始化MOSDOp的實例
                           >_session_op_assign(s, op) //將Op與OSDSession相關聯。
                           > _send_op(op, m)
                               >op->session->con->send_message(m) //進入Massenger層,操作對象MOSDOp
                                   >static_cast<SimpleMessenger*>(msgr)->send_message(m, this) //使用使用massenger層的SimpleMessenger的實例發生消息
                                       >_send_message(m, con)
                                           >submit_message(m, static_cast<PipeConnection*>(con),con->get_peer_addr(), con->get_peer_type(), false) //提交信息
                                               >static_cast<PipeConnection*>(con)->try_get_pipe(&pipe) //獲取該PipConnection對應的Pipe的實例
                                                   >pipe->_send(m) //通過Pipe發送消息,即:把消息放入到Pipe::out_q隊列中,並通知Pipe中的寫線程來做實際的發生操作。
                                                       >out_q[m->get_priority()].push_back(m);
                                                   >dispatch_queue.local_delivery(m, m->get_priority()) //如果發送端與接收端是同一個,則直接將消息投遞到DispathcQueue::local_messages中。

寫入數據

m_ictx->data_ctx.aio_operate(m_oid, rados_completion, &m_write,m_snap_seq, m_snaps)
   >io_ctx_impl->aio_operate(obj, (::ObjectOperation*)o->impl, c->pc,snapc, 0)
       >objecter->mutate(oid, oloc, *o, snap_context, ut, flags, onack, oncommit,&c->objver) //進入Objecter層
           >prepare_mutate_op(oid, oloc, op, snapc, mtime, flags, onack, oncommit, objver) //封裝成Op
           >objecter->op_submit(objecter_op) //提交到objecter層 操作對象爲Objecter::Op
               >_op_submit_with_budget(op, lc, ctx_budget)
                   >int op_budget = _take_op_budget(op) //減去該Op的預算for throttle;
                       >int op_budget = calc_op_budget(op) //預算值是該Op的字節大小
                       > _throttle_op(op, op_budget) //這裏是Objecter的Throttle層,如果keep_balanced_budget=true,能實現對速度的限制(op_throttle_bytes&op_throttle_ops)
                   >_op_submit(op, lc)
                       >_calc_target(&op->target, &op->last_force_resend) //計算該op的操作對象(用到CRUSH算法)
                       >_get_session(op->target.osd, &s, lc) //爲該Op構建與osd對應的OSDSession
                       >_send_op_account(op) //登記該次op操作
                       > m = _prepare_osd_op(op) //使用Op中的信息,初始化MOSDOp的實例
                       >_session_op_assign(s, op) //將Op與OSDSession相關聯。
                       > _send_op(op, m)
                           >op->session->con->send_message(m) //進入Massenger層,操作對象MOSDOp
                               >static_cast<SimpleMessenger*>(msgr)->send_message(m, this) //使用使用massenger層的SimpleMessenger的實例發生消息
                                   >_send_message(m, con)
                                       >submit_message(m, static_cast<PipeConnection*>(con),con->get_peer_addr(), con->get_peer_type(), false) //提交信息
                                           >static_cast<PipeConnection*>(con)->try_get_pipe(&pipe) //獲取該PipConnection對應的Pipe的實例
                                               >pipe->_send(m) //通過Pipe發送消息,即:把消息放入到Pipe::out_q隊列中,並通知Pipe中的寫線程來做實際的發生操作。
                                                   >out_q[m->get_priority()].push_back(m);
                                               >dispatch_queue.local_delivery(m, m->get_priority()) //如果發送端與接收端是同一個,則直接將消息投遞到DispathcQueue::local_messages中。

摘錄於
摘錄於

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章