Files
scst/srpt/session-management.txt
Bart Van Assche 143e9c9684 ib_srpt: Use a workqueue for processing RDMA completions
Use a workqueue for processing RDMA completions instead of creating one
kernel thread per RDMA channel. This change improves performance if the
number of RDMA channels is large by reducing the number of context
switches between kernel threads while processing RDMA completions. An
additional change is that srpt_set_ch_state() no longer wakes up the
RDMA completion context but that srpt_cm_rtu_recv() wakes up the RDMA
completion context instead.
    
See also https://github.com/bvanassche/scst/issues/33 .


git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@9178 d57e44dd-8a1f-0410-8b47-8ef2f437770f
2020-11-03 04:56:01 +00:00

41 lines
2.3 KiB
Plaintext

ib_srpt and session management
==============================
The following actions related to SRP sessions can all occur concurrently:
* The communication manager invokes either srpt_ib_cm_handler() or
srpt_rdma_cm_handler().
* HCA driver invokes the queue pair (QP) completion handler srpt_completion().
* HCA driver invokes the QP async event handler srpt_qp_event().
* HCA transfers data between initiator and target via RDMA.
* srpt_do_compl_work() polls the QP.
* SCST core invokes one of the callback functions defined in srpt_template.
The actions that occur over the lifetime of a session are as follows:
- A REQ message is received from the initiator.
- srpt_cm_req_recv() is invoked, allocates an I/O context ring and a queue pair
and creates an SCST session.
- If the connection request is not accepted, a REJ message is sent and
srpt_close_ch() is invoked. The srpt_close_ch() call causes the allocated
resources to be freed asynchronously.
- If the connection request is accepted a REP message is sent to the initiator.
- Once an RTU message is received from the initiator, srpt_cm_rtu_recv() is
invoked. That function changes the queue pair state into RTS, the channel
state into CH_LIVE and triggers processing of the wait list.
- RDMA communication starts and continues until either a DREQ message is
received or sent. A DREQ is sent either because a target port is disabled or
because the SCST core requested to close the session.
- After a DREQ has been sent either a DREP will be received or the TimeWait
state will be reached. Both trigger a srpt_close_ch() call.
- srpt_close_ch() changes the channel state into CH_DRAINING, the
queue pair state into IB_QPS_ERR and queues a zero-length write.
- Upon receipt of the zero-length write completion the channel state is
changed into CH_DISCONNECTED. This is the last work completion so once the
channel state has reached CH_DISCONNECTED it is guaranteed that the queue
pair completion handler won't be invoked again.
- scst_unregister_session() is called.
- Once scst_unregister_session() has finished srpt_unreg_sess() is invoked.
- srpt_unreg_sess() destroys the CM ID and decrements the channel refcount.
- Once the channel refcount drops to zero srpt_free_ch() is invoked which
frees the queue pair and other IB resources.