Skip to content

Commit e7be235

Browse files
committed
Merge branch 'net-smc-improve-termination-handling-part-3'
Karsten Graul says: ==================== net/smc: improve termination handling (part 3) Part 3 of the SMC termination patches improves the link group termination processing and introduces the ability to immediately terminate a link group. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 43da44c + 0b29ec6 commit e7be235

File tree

13 files changed

+250
-76
lines changed

13 files changed

+250
-76
lines changed

drivers/s390/net/ism.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
#define ISM_UNREG_SBA 0x11
3333
#define ISM_UNREG_IEQ 0x12
3434

35-
#define ISM_ERROR 0xFFFF
36-
3735
struct ism_req_hdr {
3836
u32 cmd;
3937
u16 : 16;

include/net/smc.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ struct smcd_dmb {
3737
#define ISM_EVENT_GID 1
3838
#define ISM_EVENT_SWR 2
3939

40+
#define ISM_ERROR 0xFFFF
41+
4042
struct smcd_event {
4143
u32 type;
4244
u32 code;
@@ -77,6 +79,8 @@ struct smcd_dev {
7779
bool pnetid_by_user;
7880
struct list_head lgr_list;
7981
spinlock_t lgr_lock;
82+
atomic_t lgr_cnt;
83+
wait_queue_head_t lgrs_deleted;
8084
u8 going_away : 1;
8185
};
8286

net/smc/smc_cdc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ int smc_cdc_get_slot_and_msg_send(struct smc_connection *conn)
131131
{
132132
int rc;
133133

134+
if (!conn->lgr || (conn->lgr->is_smcd && conn->lgr->peer_shutdown))
135+
return -EPIPE;
136+
134137
if (conn->lgr->is_smcd) {
135138
spin_lock_bh(&conn->send_lock);
136139
rc = smcd_cdc_msg_send(conn);

net/smc/smc_clc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ int smc_clc_wait_msg(struct smc_sock *smc, void *buf, int buflen,
349349
smc->peer_diagnosis = ntohl(dclc->peer_diagnosis);
350350
if (((struct smc_clc_msg_decline *)buf)->hdr.flag) {
351351
smc->conn.lgr->sync_err = 1;
352-
smc_lgr_terminate(smc->conn.lgr);
352+
smc_lgr_terminate(smc->conn.lgr, true);
353353
}
354354
}
355355

net/smc/smc_close.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,17 @@ int smc_close_abort(struct smc_connection *conn)
110110
return smc_cdc_get_slot_and_msg_send(conn);
111111
}
112112

113+
static void smc_close_cancel_work(struct smc_sock *smc)
114+
{
115+
struct sock *sk = &smc->sk;
116+
117+
release_sock(sk);
118+
cancel_work_sync(&smc->conn.close_work);
119+
cancel_delayed_work_sync(&smc->conn.tx_work);
120+
lock_sock(sk);
121+
sk->sk_state = SMC_CLOSED;
122+
}
123+
113124
/* terminate smc socket abnormally - active abort
114125
* link group is terminated, i.e. RDMA communication no longer possible
115126
*/
@@ -126,31 +137,33 @@ void smc_close_active_abort(struct smc_sock *smc)
126137
switch (sk->sk_state) {
127138
case SMC_ACTIVE:
128139
sk->sk_state = SMC_PEERABORTWAIT;
129-
release_sock(sk);
130-
cancel_delayed_work_sync(&smc->conn.tx_work);
131-
lock_sock(sk);
140+
smc_close_cancel_work(smc);
132141
sk->sk_state = SMC_CLOSED;
133142
sock_put(sk); /* passive closing */
134143
break;
135144
case SMC_APPCLOSEWAIT1:
136145
case SMC_APPCLOSEWAIT2:
137-
release_sock(sk);
138-
cancel_delayed_work_sync(&smc->conn.tx_work);
139-
lock_sock(sk);
146+
smc_close_cancel_work(smc);
140147
sk->sk_state = SMC_CLOSED;
141148
sock_put(sk); /* postponed passive closing */
142149
break;
143150
case SMC_PEERCLOSEWAIT1:
144151
case SMC_PEERCLOSEWAIT2:
145152
case SMC_PEERFINCLOSEWAIT:
153+
sk->sk_state = SMC_PEERABORTWAIT;
154+
smc_close_cancel_work(smc);
146155
sk->sk_state = SMC_CLOSED;
147156
smc_conn_free(&smc->conn);
148157
release_clcsock = true;
149158
sock_put(sk); /* passive closing */
150159
break;
151160
case SMC_PROCESSABORT:
152161
case SMC_APPFINCLOSEWAIT:
162+
sk->sk_state = SMC_PEERABORTWAIT;
163+
smc_close_cancel_work(smc);
153164
sk->sk_state = SMC_CLOSED;
165+
smc_conn_free(&smc->conn);
166+
release_clcsock = true;
154167
break;
155168
case SMC_INIT:
156169
case SMC_PEERABORTWAIT:

0 commit comments

Comments
 (0)