@@ -198,6 +198,7 @@ static void smc_lgr_free_work(struct work_struct *work)
198
198
static int smc_lgr_create (struct smc_sock * smc , struct smc_init_info * ini )
199
199
{
200
200
struct smc_link_group * lgr ;
201
+ struct list_head * lgr_list ;
201
202
struct smc_link * lnk ;
202
203
u8 rndvec [3 ];
203
204
int rc = 0 ;
@@ -233,6 +234,7 @@ static int smc_lgr_create(struct smc_sock *smc, struct smc_init_info *ini)
233
234
/* SMC-D specific settings */
234
235
lgr -> peer_gid = ini -> ism_gid ;
235
236
lgr -> smcd = ini -> ism_dev ;
237
+ lgr_list = & ini -> ism_dev -> lgr_list ;
236
238
} else {
237
239
/* SMC-R specific settings */
238
240
lgr -> role = smc -> listen_smc ? SMC_SERV : SMC_CLNT ;
@@ -245,6 +247,7 @@ static int smc_lgr_create(struct smc_sock *smc, struct smc_init_info *ini)
245
247
lnk -> link_id = SMC_SINGLE_LINK ;
246
248
lnk -> smcibdev = ini -> ib_dev ;
247
249
lnk -> ibport = ini -> ib_port ;
250
+ lgr_list = & smc_lgr_list .list ;
248
251
lnk -> path_mtu =
249
252
ini -> ib_dev -> pattr [ini -> ib_port - 1 ].active_mtu ;
250
253
if (!ini -> ib_dev -> initialized )
@@ -275,7 +278,7 @@ static int smc_lgr_create(struct smc_sock *smc, struct smc_init_info *ini)
275
278
}
276
279
smc -> conn .lgr = lgr ;
277
280
spin_lock_bh (& smc_lgr_list .lock );
278
- list_add (& lgr -> list , & smc_lgr_list . list );
281
+ list_add (& lgr -> list , lgr_list );
279
282
spin_unlock_bh (& smc_lgr_list .lock );
280
283
return 0 ;
281
284
@@ -512,9 +515,8 @@ void smc_smcd_terminate(struct smcd_dev *dev, u64 peer_gid, unsigned short vlan)
512
515
513
516
/* run common cleanup function and build free list */
514
517
spin_lock_bh (& smc_lgr_list .lock );
515
- list_for_each_entry_safe (lgr , l , & smc_lgr_list .list , list ) {
516
- if (lgr -> is_smcd && lgr -> smcd == dev &&
517
- (!peer_gid || lgr -> peer_gid == peer_gid ) &&
518
+ list_for_each_entry_safe (lgr , l , & dev -> lgr_list , list ) {
519
+ if ((!peer_gid || lgr -> peer_gid == peer_gid ) &&
518
520
(vlan == VLAN_VID_MASK || lgr -> vlan_id == vlan )) {
519
521
__smc_lgr_terminate (lgr );
520
522
list_move (& lgr -> list , & lgr_free_list );
@@ -604,10 +606,12 @@ static bool smcd_lgr_match(struct smc_link_group *lgr,
604
606
int smc_conn_create (struct smc_sock * smc , struct smc_init_info * ini )
605
607
{
606
608
struct smc_connection * conn = & smc -> conn ;
609
+ struct list_head * lgr_list ;
607
610
struct smc_link_group * lgr ;
608
611
enum smc_lgr_role role ;
609
612
int rc = 0 ;
610
613
614
+ lgr_list = ini -> is_smcd ? & ini -> ism_dev -> lgr_list : & smc_lgr_list .list ;
611
615
ini -> cln_first_contact = SMC_FIRST_CONTACT ;
612
616
role = smc -> listen_smc ? SMC_SERV : SMC_CLNT ;
613
617
if (role == SMC_CLNT && ini -> srv_first_contact )
@@ -616,7 +620,7 @@ int smc_conn_create(struct smc_sock *smc, struct smc_init_info *ini)
616
620
617
621
/* determine if an existing link group can be reused */
618
622
spin_lock_bh (& smc_lgr_list .lock );
619
- list_for_each_entry (lgr , & smc_lgr_list . list , list ) {
623
+ list_for_each_entry (lgr , lgr_list , list ) {
620
624
write_lock_bh (& lgr -> conns_lock );
621
625
if ((ini -> is_smcd ?
622
626
smcd_lgr_match (lgr , ini -> ism_dev , ini -> ism_gid ) :
@@ -1029,11 +1033,17 @@ void smc_core_exit(void)
1029
1033
{
1030
1034
struct smc_link_group * lgr , * lg ;
1031
1035
LIST_HEAD (lgr_freeing_list );
1036
+ struct smcd_dev * smcd ;
1032
1037
1033
1038
spin_lock_bh (& smc_lgr_list .lock );
1034
- if (!list_empty (& smc_lgr_list .list ))
1035
- list_splice_init (& smc_lgr_list .list , & lgr_freeing_list );
1039
+ list_splice_init (& smc_lgr_list .list , & lgr_freeing_list );
1036
1040
spin_unlock_bh (& smc_lgr_list .lock );
1041
+
1042
+ spin_lock (& smcd_dev_list .lock );
1043
+ list_for_each_entry (smcd , & smcd_dev_list .list , list )
1044
+ list_splice_init (& smcd -> lgr_list , & lgr_freeing_list );
1045
+ spin_unlock (& smcd_dev_list .lock );
1046
+
1037
1047
list_for_each_entry_safe (lgr , lg , & lgr_freeing_list , list ) {
1038
1048
list_del_init (& lgr -> list );
1039
1049
if (!lgr -> is_smcd ) {
0 commit comments