iSER patches for linux-6.2
Subsystems (2)
Max Gurtovoy
maintainercover iSER patches for linux-6.2
Hi Sagi/Jason,
These small patches add safety checks and simplify the code. Please consider including them in the next merge window.
Max Gurtovoy (2):
IB/iser: add safety checks for state_mutex lock
IB/iser: open code iser_disconnected_handler
Sergey Gorenko (1):
IB/iser: open code iser_conn_state_comp_exch
drivers/infiniband/ulp/iser/iser_verbs.c | 67 ++++++++++-------------- 1 file changed, 29 insertions(+), 38 deletions(-)
Signature · 1 line
2.18.1
Max Gurtovoy
maintainerPATCH 1/3 IB/iser: open code iser_conn_state_comp_exch
From: Sergey Gorenko <[email protected]>
There is a single caller to iser_conn_state_comp_exch. Open code its logic and remove it.
--- drivers/infiniband/ulp/iser/iser_verbs.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-)
drivers/infiniband/ulp/iser/iser_verbs.c +2 -18
@@ -347,22 +347,6 @@ static void iser_device_try_release(struct iser_device *device)mutex_unlock (&ig.device_list_mutex); } -/* -* Called with state mutex held -*/ -static int iser_conn_state_comp_exch (struct iser_conn *iser_conn, -enum iser_conn_state comp, -enum iser_conn_state exch) -{ -int ret; - - ret = (iser_conn->state == comp); -if (ret) - iser_conn->state = exch; - -return ret; -} -void iser_release_work (struct work_struct *work) {struct iser_conn *iser_conn;
@@ -465,10 +449,10 @@ int iser_conn_terminate(struct iser_conn *iser_conn)int err =0 ;/* terminate the iser conn only if the conn state is UP */ -if (!iser_conn_state_comp_exch (iser_conn,ISER_CONN_UP , -ISER_CONN_TERMINATING )) +if (iser_conn->state !=ISER_CONN_UP )return 0 ; + iser_conn->state =ISER_CONN_TERMINATING ;iser_info ("iser_conn %p state %d\n" , iser_conn, iser_conn->state);/* suspend queuing of new iscsi commands */
Signature · 1 line
2.18.1
Re: [PATCH 1/3] IB/iser: open code iser_conn_state_comp_exch
Max Gurtovoy
maintainerPATCH 2/3 IB/iser: add safety checks for state_mutex lock
In reply to Max GurtovoyIn some cases, we need to make sure that state_mutex is taken. Use lockdep_assert_held to warn us in case it doesn't while it should.
--- drivers/infiniband/ulp/iser/iser_verbs.c | 26 ++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-)
drivers/infiniband/ulp/iser/iser_verbs.c +20 -6
@@ -448,6 +448,8 @@ int iser_conn_terminate(struct iser_conn *iser_conn)struct ib_conn *ib_conn = &iser_conn->ib_conn;int err =0 ; +lockdep_assert_held (&iser_conn->state_mutex); +/* terminate the iser conn only if the conn state is UP */ if (iser_conn->state !=ISER_CONN_UP )return 0 ;
@@ -482,9 +484,10 @@ int iser_conn_terminate(struct iser_conn *iser_conn)*/ static void iser_connect_error (struct rdma_cm_id *cma_id) { -struct iser_conn *iser_conn; +struct iser_conn *iser_conn = cma_id->context; + +lockdep_assert_held (&iser_conn->state_mutex); - iser_conn = cma_id->context; iser_conn->state =ISER_CONN_TERMINATING ; }
@@ -526,12 +529,13 @@ static void iser_calc_scsi_params(struct iser_conn *iser_conn,*/ static void iser_addr_handler (struct rdma_cm_id *cma_id) { +struct iser_conn *iser_conn = cma_id->context;struct iser_device *device; -struct iser_conn *iser_conn;struct ib_conn *ib_conn;int ret; - iser_conn = cma_id->context; +lockdep_assert_held (&iser_conn->state_mutex); +if (iser_conn->state !=ISER_CONN_PENDING )/* bailout */ return ;
@@ -581,6 +585,8 @@ static void iser_route_handler(struct rdma_cm_id *cma_id)struct ib_conn *ib_conn = &iser_conn->ib_conn;struct ib_device *ib_dev = ib_conn->device->ib_device; +lockdep_assert_held (&iser_conn->state_mutex); +if (iser_conn->state !=ISER_CONN_PENDING )/* bailout */ return ;
@@ -613,14 +619,18 @@ static void iser_route_handler(struct rdma_cm_id *cma_id)iser_connect_error (cma_id); } +/* +* Called with state mutex held +*/ static void iser_connected_handler (struct rdma_cm_id *cma_id,const void *private_data) { -struct iser_conn *iser_conn; +struct iser_conn *iser_conn = cma_id->context;struct ib_qp_attr attr;struct ib_qp_init_attr init_attr; - iser_conn = cma_id->context; +lockdep_assert_held (&iser_conn->state_mutex); +if (iser_conn->state !=ISER_CONN_PENDING )/* bailout */ return ;
@@ -654,11 +664,15 @@ static void iser_disconnected_handler(struct rdma_cm_id *cma_id) } } +/* +* Called with state mutex held +*/ static void iser_cleanup_handler (struct rdma_cm_id *cma_id,bool destroy) {struct iser_conn *iser_conn = cma_id->context; +lockdep_assert_held (&iser_conn->state_mutex);/* * We are not guaranteed that we visited disconnected_handler * by now, call it here to be safe that we handle CM drep
Signature · 1 line
2.18.1
Re: [PATCH 2/3] IB/iser: add safety checks for state_mutex lock
Max Gurtovoy
maintainerPATCH 3/3 IB/iser: open code iser_disconnected_handler
In reply to Max GurtovoyThere is a single caller to iser_disconnected_handler. Open code its logic and remove it.
--- drivers/infiniband/ulp/iser/iser_verbs.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-)
drivers/infiniband/ulp/iser/iser_verbs.c +7 -14
@@ -651,19 +651,6 @@ static void iser_connected_handler(struct rdma_cm_id *cma_id,complete (&iser_conn->up_completion); } -static void iser_disconnected_handler (struct rdma_cm_id *cma_id) -{ -struct iser_conn *iser_conn = cma_id->context; - -if (iser_conn_terminate (iser_conn)) { -if (iser_conn->iscsi_conn) -iscsi_conn_failure (iser_conn->iscsi_conn, -ISCSI_ERR_CONN_FAILED ); -else -iser_err ("iscsi_iser connection isn't bound\n" ); - } -} -/* * Called with state mutex held */
@@ -678,7 +665,13 @@ static void iser_cleanup_handler(struct rdma_cm_id *cma_id,* by now, call it here to be safe that we handle CM drep * and flush errors. */ -iser_disconnected_handler (cma_id); +if (iser_conn_terminate (iser_conn)) { +if (iser_conn->iscsi_conn) +iscsi_conn_failure (iser_conn->iscsi_conn, +ISCSI_ERR_CONN_FAILED ); +else +iser_err ("iscsi_iser connection isn't bound\n" ); + }iser_free_ib_conn_res (iser_conn, destroy);complete (&iser_conn->ib_completion); }
Signature · 1 line
2.18.1
Re: [PATCH 3/3] IB/iser: open code iser_disconnected_handler
Leon Romanovsky
AppliedQuoted 8 lines · Max Gurtovoy
These small patches add safety checks and simplify the code. Please consider including them in the next merge window.
Max Gurtovoy (2):
IB/iser: add safety checks forstate_mutexlock
IB/iser: open codeiser_disconnected_handler[...]
Applied, thanks!
[1/3] IB/iser: open code iser_conn_state_comp_exch
https://git.kernel.org/rdma/rdma/c/acc7d94ab431fb [2/3] IB/iser: add safety checks for state_mutex lock https://git.kernel.org/rdma/rdma/c/a75243ae08d232 [3/3] IB/iser: open code iser_disconnected_handler https://git.kernel.org/rdma/rdma/c/c1842f34fceef4
Best regards,
Signature · 1 line
Leon Romanovsky <[email protected]>