This patch is used to fix the following problems in the current connection method: 1. iscsi_iser_connect() waits until the connection is established or failed, and may block the caller for a long time. 2. Although there's a cm_thread handles communication events, but in fact it has no effects after the connection is established. 3. Resources are not released properly after reconnection failed. And once we try to reconnect again, the resources will leak permanently. (see iscsi_reconnect()). This patch eliminate cm_thread and handle communication events in the caller thread. Connection procedure: 1. Create a mock fd by eventfd() (or just use old_iscsi->fd while reconnecting), and assign it to iscsi->fd. 2. Create communication event channel, make it non-blocking and dup the notifier fd to iscsi->fd. 3. Handle communication events by iscsi_which_events()/iscsi_service() loop until connection established or falied. 4. If connection is established successfully, dup the notifier fd of completion queue (CQ) events to iscsi->fd. 5. Handle completion queue (CQ) events by iscsi_which_events()/iscsi_service() loop. The entire procedure is non-blocking. After established, whenever iscsi_service() is called with revents=0 or queue_pdu() is called with a NOP pdu, communication events will be checked. When connection failed, iser transport cleanup itself before callbacks. Signed-off-by: wanghonghao <wanghonghao@bytedance.com>
5.8 KiB
5.8 KiB