@@ -553,23 +553,12 @@ static int smc_connect_decline_fallback(struct smc_sock *smc, int reason_code,
553
553
}
554
554
555
555
/* abort connecting */
556
- static int smc_connect_abort (struct smc_sock * smc , int reason_code ,
557
- int local_first )
556
+ static void smc_connect_abort (struct smc_sock * smc , int local_first )
558
557
{
559
- bool is_smcd = smc -> conn .lgr -> is_smcd ;
560
-
561
558
if (local_first )
562
559
smc_lgr_cleanup_early (& smc -> conn );
563
560
else
564
561
smc_conn_free (& smc -> conn );
565
- if (is_smcd )
566
- /* there is only one lgr role for SMC-D; use server lock */
567
- mutex_unlock (& smc_server_lgr_pending );
568
- else
569
- mutex_unlock (& smc_client_lgr_pending );
570
-
571
- smc -> connect_nonblock = 0 ;
572
- return reason_code ;
573
562
}
574
563
575
564
/* check if there is a rdma device available for this connection. */
@@ -764,43 +753,47 @@ static int smc_connect_rdma(struct smc_sock *smc,
764
753
break ;
765
754
}
766
755
}
767
- if (!link )
768
- return smc_connect_abort (smc , SMC_CLC_DECL_NOSRVLINK ,
769
- ini -> first_contact_local );
756
+ if (!link ) {
757
+ reason_code = SMC_CLC_DECL_NOSRVLINK ;
758
+ goto connect_abort ;
759
+ }
770
760
smc -> conn .lnk = link ;
771
761
}
772
762
773
763
/* create send buffer and rmb */
774
- if (smc_buf_create (smc , false))
775
- return smc_connect_abort (smc , SMC_CLC_DECL_MEM ,
776
- ini -> first_contact_local );
764
+ if (smc_buf_create (smc , false)) {
765
+ reason_code = SMC_CLC_DECL_MEM ;
766
+ goto connect_abort ;
767
+ }
777
768
778
769
if (ini -> first_contact_local )
779
770
smc_link_save_peer_info (link , aclc );
780
771
781
- if (smc_rmb_rtoken_handling (& smc -> conn , link , aclc ))
782
- return smc_connect_abort (smc , SMC_CLC_DECL_ERR_RTOK ,
783
- ini -> first_contact_local );
772
+ if (smc_rmb_rtoken_handling (& smc -> conn , link , aclc )) {
773
+ reason_code = SMC_CLC_DECL_ERR_RTOK ;
774
+ goto connect_abort ;
775
+ }
784
776
785
777
smc_close_init (smc );
786
778
smc_rx_init (smc );
787
779
788
780
if (ini -> first_contact_local ) {
789
- if (smc_ib_ready_link (link ))
790
- return smc_connect_abort (smc , SMC_CLC_DECL_ERR_RDYLNK ,
791
- ini -> first_contact_local );
781
+ if (smc_ib_ready_link (link )) {
782
+ reason_code = SMC_CLC_DECL_ERR_RDYLNK ;
783
+ goto connect_abort ;
784
+ }
792
785
} else {
793
- if (smcr_lgr_reg_rmbs (link , smc -> conn .rmb_desc ))
794
- return smc_connect_abort (smc , SMC_CLC_DECL_ERR_REGRMB ,
795
- ini -> first_contact_local );
786
+ if (smcr_lgr_reg_rmbs (link , smc -> conn .rmb_desc )) {
787
+ reason_code = SMC_CLC_DECL_ERR_REGRMB ;
788
+ goto connect_abort ;
789
+ }
796
790
}
797
791
smc_rmb_sync_sg_for_device (& smc -> conn );
798
792
799
793
reason_code = smc_clc_send_confirm (smc , ini -> first_contact_local ,
800
794
SMC_V1 );
801
795
if (reason_code )
802
- return smc_connect_abort (smc , reason_code ,
803
- ini -> first_contact_local );
796
+ goto connect_abort ;
804
797
805
798
smc_tx_init (smc );
806
799
@@ -810,8 +803,7 @@ static int smc_connect_rdma(struct smc_sock *smc,
810
803
reason_code = smcr_clnt_conf_first_link (smc );
811
804
smc_llc_flow_stop (link -> lgr , & link -> lgr -> llc_flow_lcl );
812
805
if (reason_code )
813
- return smc_connect_abort (smc , reason_code ,
814
- ini -> first_contact_local );
806
+ goto connect_abort ;
815
807
}
816
808
mutex_unlock (& smc_client_lgr_pending );
817
809
@@ -821,6 +813,12 @@ static int smc_connect_rdma(struct smc_sock *smc,
821
813
smc -> sk .sk_state = SMC_ACTIVE ;
822
814
823
815
return 0 ;
816
+ connect_abort :
817
+ smc_connect_abort (smc , ini -> first_contact_local );
818
+ mutex_unlock (& smc_client_lgr_pending );
819
+ smc -> connect_nonblock = 0 ;
820
+
821
+ return reason_code ;
824
822
}
825
823
826
824
/* The server has chosen one of the proposed ISM devices for the communication.
@@ -872,11 +870,10 @@ static int smc_connect_ism(struct smc_sock *smc,
872
870
873
871
/* Create send and receive buffers */
874
872
rc = smc_buf_create (smc , true);
875
- if (rc )
876
- return smc_connect_abort (smc , (rc == - ENOSPC ) ?
877
- SMC_CLC_DECL_MAX_DMB :
878
- SMC_CLC_DECL_MEM ,
879
- ini -> first_contact_local );
873
+ if (rc ) {
874
+ rc = (rc == - ENOSPC ) ? SMC_CLC_DECL_MAX_DMB : SMC_CLC_DECL_MEM ;
875
+ goto connect_abort ;
876
+ }
880
877
881
878
smc_conn_save_peer_info (smc , aclc );
882
879
smc_close_init (smc );
@@ -886,7 +883,7 @@ static int smc_connect_ism(struct smc_sock *smc,
886
883
rc = smc_clc_send_confirm (smc , ini -> first_contact_local ,
887
884
aclc -> hdr .version );
888
885
if (rc )
889
- return smc_connect_abort ( smc , rc , ini -> first_contact_local ) ;
886
+ goto connect_abort ;
890
887
mutex_unlock (& smc_server_lgr_pending );
891
888
892
889
smc_copy_sock_settings_to_clc (smc );
@@ -895,6 +892,12 @@ static int smc_connect_ism(struct smc_sock *smc,
895
892
smc -> sk .sk_state = SMC_ACTIVE ;
896
893
897
894
return 0 ;
895
+ connect_abort :
896
+ smc_connect_abort (smc , ini -> first_contact_local );
897
+ mutex_unlock (& smc_server_lgr_pending );
898
+ smc -> connect_nonblock = 0 ;
899
+
900
+ return rc ;
898
901
}
899
902
900
903
/* check if received accept type and version matches a proposed one */
@@ -1478,11 +1481,12 @@ static void smc_find_ism_v2_device_serv(struct smc_sock *new_smc,
1478
1481
struct smc_clc_v2_extension * smc_v2_ext ;
1479
1482
struct smc_clc_msg_smcd * pclc_smcd ;
1480
1483
unsigned int matches = 0 ;
1484
+ u8 smcd_version ;
1481
1485
u8 * eid = NULL ;
1482
1486
int i ;
1483
1487
1484
1488
if (!(ini -> smcd_version & SMC_V2 ) || !smcd_indicated (ini -> smc_type_v2 ))
1485
- return ;
1489
+ goto not_found ;
1486
1490
1487
1491
pclc_smcd = smc_get_clc_msg_smcd (pclc );
1488
1492
smc_v2_ext = smc_get_clc_v2_ext (pclc );
@@ -1516,6 +1520,7 @@ static void smc_find_ism_v2_device_serv(struct smc_sock *new_smc,
1516
1520
}
1517
1521
1518
1522
/* separate - outside the smcd_dev_list.lock */
1523
+ smcd_version = ini -> smcd_version ;
1519
1524
for (i = 0 ; i < matches ; i ++ ) {
1520
1525
ini -> smcd_version = SMC_V2 ;
1521
1526
ini -> is_smcd = true;
@@ -1525,6 +1530,8 @@ static void smc_find_ism_v2_device_serv(struct smc_sock *new_smc,
1525
1530
continue ;
1526
1531
return ; /* matching and usable V2 ISM device found */
1527
1532
}
1533
+ /* no V2 ISM device could be initialized */
1534
+ ini -> smcd_version = smcd_version ; /* restore original value */
1528
1535
1529
1536
not_found :
1530
1537
ini -> smcd_version &= ~SMC_V2 ;
@@ -1661,7 +1668,6 @@ static void smc_listen_work(struct work_struct *work)
1661
1668
smc_listen_work );
1662
1669
u8 version = smc_ism_v2_capable ? SMC_V2 : SMC_V1 ;
1663
1670
struct socket * newclcsock = new_smc -> clcsock ;
1664
- struct smc_clc_msg_accept_confirm_v2 * cclc2 ;
1665
1671
struct smc_clc_msg_accept_confirm * cclc ;
1666
1672
struct smc_clc_msg_proposal_area * buf ;
1667
1673
struct smc_clc_msg_proposal * pclc ;
@@ -1737,11 +1743,9 @@ static void smc_listen_work(struct work_struct *work)
1737
1743
mutex_unlock (& smc_server_lgr_pending );
1738
1744
1739
1745
/* receive SMC Confirm CLC message */
1740
- cclc2 = (struct smc_clc_msg_accept_confirm_v2 * )buf ;
1741
- cclc = (struct smc_clc_msg_accept_confirm * )cclc2 ;
1742
- memset (buf , 0 , sizeof (struct smc_clc_msg_proposal_area ));
1743
- rc = smc_clc_wait_msg (new_smc , cclc2 ,
1744
- sizeof (struct smc_clc_msg_proposal_area ),
1746
+ memset (buf , 0 , sizeof (* buf ));
1747
+ cclc = (struct smc_clc_msg_accept_confirm * )buf ;
1748
+ rc = smc_clc_wait_msg (new_smc , cclc , sizeof (* buf ),
1745
1749
SMC_CLC_CONFIRM , CLC_WAIT_TIME );
1746
1750
if (rc ) {
1747
1751
if (!ini -> is_smcd )
0 commit comments