Skip to content

Commit 2f1b6b7

Browse files
Sagi GrimbergNicholas Bellinger
authored andcommitted
iser-target: release stale iser connections
When receiving a new iser connect request we serialize the pending requests by adding the newly created iser connection to the np accept list and let the login thread process the connect request one by one (np_accept_wait). In case we received a disconnect request before the iser_conn has begun processing (still linked in np_accept_list) we should detach it from the list and clean it up and not have the login thread process a stale connection. We do it only when the connection state is not already terminating (initiator driven disconnect) as this might lead us to access np_accept_mutex after the np was released in live shutdown scenarios. Signed-off-by: Sagi Grimberg <[email protected]> Signed-off-by: Jenny Falkovich <[email protected]> Cc: [email protected] # 3.10+ Signed-off-by: Nicholas Bellinger <[email protected]>
1 parent 9253e66 commit 2f1b6b7

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

drivers/infiniband/ulp/isert/ib_isert.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ static int
6565
isert_rdma_accept(struct isert_conn *isert_conn);
6666
struct rdma_cm_id *isert_setup_id(struct isert_np *isert_np);
6767

68+
static void isert_release_work(struct work_struct *work);
69+
6870
static inline bool
6971
isert_prot_cmd(struct isert_conn *conn, struct se_cmd *cmd)
7072
{
@@ -648,6 +650,7 @@ isert_init_conn(struct isert_conn *isert_conn)
648650
mutex_init(&isert_conn->mutex);
649651
spin_lock_init(&isert_conn->pool_lock);
650652
INIT_LIST_HEAD(&isert_conn->fr_pool);
653+
INIT_WORK(&isert_conn->release_work, isert_release_work);
651654
}
652655

653656
static void
@@ -925,19 +928,33 @@ isert_disconnected_handler(struct rdma_cm_id *cma_id,
925928
{
926929
struct isert_np *isert_np = cma_id->context;
927930
struct isert_conn *isert_conn;
931+
bool terminating = false;
928932

929933
if (isert_np->np_cm_id == cma_id)
930934
return isert_np_cma_handler(cma_id->context, event);
931935

932936
isert_conn = cma_id->qp->qp_context;
933937

934938
mutex_lock(&isert_conn->mutex);
939+
terminating = (isert_conn->state == ISER_CONN_TERMINATING);
935940
isert_conn_terminate(isert_conn);
936941
mutex_unlock(&isert_conn->mutex);
937942

938943
isert_info("conn %p completing wait\n", isert_conn);
939944
complete(&isert_conn->wait);
940945

946+
if (terminating)
947+
goto out;
948+
949+
mutex_lock(&isert_np->np_accept_mutex);
950+
if (!list_empty(&isert_conn->accept_node)) {
951+
list_del_init(&isert_conn->accept_node);
952+
isert_put_conn(isert_conn);
953+
queue_work(isert_release_wq, &isert_conn->release_work);
954+
}
955+
mutex_unlock(&isert_np->np_accept_mutex);
956+
957+
out:
941958
return 0;
942959
}
943960

@@ -3368,7 +3385,6 @@ static void isert_wait_conn(struct iscsi_conn *conn)
33683385
isert_wait4flush(isert_conn);
33693386
isert_wait4logout(isert_conn);
33703387

3371-
INIT_WORK(&isert_conn->release_work, isert_release_work);
33723388
queue_work(isert_release_wq, &isert_conn->release_work);
33733389
}
33743390

0 commit comments

Comments
 (0)