(一)reactor框架: thread线程 和 poller函数
(1.1)SPDK的主线程
SPDK(APP)在启动时候会让指定绑定在那些core上运行,这样在每个core上会创建一个线程(他叫reactor),这个线程不停的做polling操作,而如果你要在这个线程上做事情,则需要注册poller( 可以理解为一个poller就是SPDK中一个事情的thread入口函数,但是),这个线程就不停的调用poller的机型函数执行你要执行的动作。
spdk_app_start
spdk_reactors_start
reactor_run
reactor_interrupt_run
spdk_fd_group_wait
event_handler->fn
_reactor_run
event_queue_run_batch
spdk_ring_dequeue
spdk_event->fn
spdk_thread_poll
thread_poll
msg_queue_run_batch
spdk_ring_dequeue
spdk_msg->fn
<FOREACH> spdk_thread->active_pollers
thread_execute_poller
spdk_poller->fn
thread_execute_timed_poller
spdk_poller->fn
spdk_fd_group_wait
event_handler->fn
reactor_post_process_lw_thread
_reactor_schedule_thread
spdk_event_allocate
spdk_event_call
(二)上层服务与reactor
(2.1)概述:
(a)vhost-virtio服务
(b)iSCSI-Target服务
(c)NVMe-oF-Target服务
(2.2)vhost-virtio:
spdk_thread_poll
thread_poll
thread_execute_poller
vdev_worker
process_vq
vhost_vq_avail_ring_get
process_blk_task
vhost_vq_avail_ring_get
process_blk_task
process_blk_request
spdk_bdev_readv
spdk_bdev_writev
process_scsi_task
bdev_scsi_execute
bdev_scsi_readwrite
spdk_bdev_readv_blocks
spdk_bdev_writev_blocks
(三)spdk-bdev框架
(3.1)spdk-bdev框架对上层服务提供的读写API接口
读接口:spdk_bdev_read / spdk_bdev_readv
写接口:spdk_bdev_write / spdk_bdev_writev
[bdev_io_submit]
_bdev_io_submit
bdev_io_do_submit
spdk_bdev->fn_table->submit_request
<A> bdev_nvme_submit_request
<B> bdev_pmem_submit_request
<C> bdev_virtio_submit_request
<D> bdev_iscsi_submit_request
<E> bdev_aio_submit_r