Skip to content

Commit ec34f79

Browse files
committed
Merge branch 'smc-fixes'
Ursula Braun says: ==================== net/smc: fixes 2019-01-30 here are some fixes in different areas of the smc code for the net tree. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 7596175 + 46ad022 commit ec34f79

File tree

8 files changed

+34
-21
lines changed

8 files changed

+34
-21
lines changed

net/smc/af_smc.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1505,6 +1505,11 @@ static int smc_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
15051505

15061506
smc = smc_sk(sk);
15071507
lock_sock(sk);
1508+
if (sk->sk_state == SMC_CLOSED && (sk->sk_shutdown & RCV_SHUTDOWN)) {
1509+
/* socket was connected before, no more data to read */
1510+
rc = 0;
1511+
goto out;
1512+
}
15081513
if ((sk->sk_state == SMC_INIT) ||
15091514
(sk->sk_state == SMC_LISTEN) ||
15101515
(sk->sk_state == SMC_CLOSED))
@@ -1840,7 +1845,11 @@ static ssize_t smc_splice_read(struct socket *sock, loff_t *ppos,
18401845

18411846
smc = smc_sk(sk);
18421847
lock_sock(sk);
1843-
1848+
if (sk->sk_state == SMC_CLOSED && (sk->sk_shutdown & RCV_SHUTDOWN)) {
1849+
/* socket was connected before, no more data to read */
1850+
rc = 0;
1851+
goto out;
1852+
}
18441853
if (sk->sk_state == SMC_INIT ||
18451854
sk->sk_state == SMC_LISTEN ||
18461855
sk->sk_state == SMC_CLOSED)

net/smc/smc_cdc.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,10 @@ static int smcr_cdc_get_slot_and_msg_send(struct smc_connection *conn)
125125
if (rc)
126126
return rc;
127127

128-
return smc_cdc_msg_send(conn, wr_buf, pend);
128+
spin_lock_bh(&conn->send_lock);
129+
rc = smc_cdc_msg_send(conn, wr_buf, pend);
130+
spin_unlock_bh(&conn->send_lock);
131+
return rc;
129132
}
130133

131134
int smc_cdc_get_slot_and_msg_send(struct smc_connection *conn)

net/smc/smc_clc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ int smc_clc_send_decline(struct smc_sock *smc, u32 peer_diag_info)
378378
vec.iov_len = sizeof(struct smc_clc_msg_decline);
379379
len = kernel_sendmsg(smc->clcsock, &msg, &vec, 1,
380380
sizeof(struct smc_clc_msg_decline));
381-
if (len < sizeof(struct smc_clc_msg_decline))
381+
if (len < 0 || len < sizeof(struct smc_clc_msg_decline))
382382
len = -EPROTO;
383383
return len > 0 ? 0 : len;
384384
}

net/smc/smc_core.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ static void smc_lgr_unregister_conn(struct smc_connection *conn)
128128
{
129129
struct smc_link_group *lgr = conn->lgr;
130130

131+
if (!lgr)
132+
return;
131133
write_lock_bh(&lgr->conns_lock);
132134
if (conn->alert_token_local) {
133135
__smc_lgr_unregister_conn(conn);
@@ -628,6 +630,8 @@ int smc_conn_create(struct smc_sock *smc, bool is_smcd, int srv_first_contact,
628630
local_contact = SMC_REUSE_CONTACT;
629631
conn->lgr = lgr;
630632
smc_lgr_register_conn(conn); /* add smc conn to lgr */
633+
if (delayed_work_pending(&lgr->free_work))
634+
cancel_delayed_work(&lgr->free_work);
631635
write_unlock_bh(&lgr->conns_lock);
632636
break;
633637
}

net/smc/smc_ib.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,16 +289,16 @@ int smc_ib_create_protection_domain(struct smc_link *lnk)
289289

290290
static void smc_ib_qp_event_handler(struct ib_event *ibevent, void *priv)
291291
{
292-
struct smc_ib_device *smcibdev =
293-
(struct smc_ib_device *)ibevent->device;
292+
struct smc_link *lnk = (struct smc_link *)priv;
293+
struct smc_ib_device *smcibdev = lnk->smcibdev;
294294
u8 port_idx;
295295

296296
switch (ibevent->event) {
297297
case IB_EVENT_DEVICE_FATAL:
298298
case IB_EVENT_GID_CHANGE:
299299
case IB_EVENT_PORT_ERR:
300300
case IB_EVENT_QP_ACCESS_ERR:
301-
port_idx = ibevent->element.port_num - 1;
301+
port_idx = ibevent->element.qp->port - 1;
302302
set_bit(port_idx, &smcibdev->port_event_mask);
303303
schedule_work(&smcibdev->port_event_work);
304304
break;

net/smc/smc_pnet.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
static struct nla_policy smc_pnet_policy[SMC_PNETID_MAX + 1] = {
2828
[SMC_PNETID_NAME] = {
2929
.type = NLA_NUL_STRING,
30-
.len = SMC_MAX_PNETID_LEN - 1
30+
.len = SMC_MAX_PNETID_LEN
3131
},
3232
[SMC_PNETID_ETHNAME] = {
3333
.type = NLA_NUL_STRING,

net/smc/smc_tx.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,11 @@ int smc_tx_sendmsg(struct smc_sock *smc, struct msghdr *msg, size_t len)
165165
conn->local_tx_ctrl.prod_flags.urg_data_pending = 1;
166166

167167
if (!atomic_read(&conn->sndbuf_space) || conn->urg_tx_pend) {
168+
if (send_done)
169+
return send_done;
168170
rc = smc_tx_wait(smc, msg->msg_flags);
169-
if (rc) {
170-
if (send_done)
171-
return send_done;
171+
if (rc)
172172
goto out_err;
173-
}
174173
continue;
175174
}
176175

@@ -489,25 +488,23 @@ static int smcr_tx_sndbuf_nonempty(struct smc_connection *conn)
489488
struct smc_wr_buf *wr_buf;
490489
int rc;
491490

492-
spin_lock_bh(&conn->send_lock);
493491
rc = smc_cdc_get_free_slot(conn, &wr_buf, &pend);
494492
if (rc < 0) {
495493
if (rc == -EBUSY) {
496494
struct smc_sock *smc =
497495
container_of(conn, struct smc_sock, conn);
498496

499-
if (smc->sk.sk_err == ECONNABORTED) {
500-
rc = sock_error(&smc->sk);
501-
goto out_unlock;
502-
}
497+
if (smc->sk.sk_err == ECONNABORTED)
498+
return sock_error(&smc->sk);
503499
rc = 0;
504500
if (conn->alert_token_local) /* connection healthy */
505501
mod_delayed_work(system_wq, &conn->tx_work,
506502
SMC_TX_WORK_DELAY);
507503
}
508-
goto out_unlock;
504+
return rc;
509505
}
510506

507+
spin_lock_bh(&conn->send_lock);
511508
if (!conn->local_tx_ctrl.prod_flags.urg_data_present) {
512509
rc = smc_tx_rdma_writes(conn);
513510
if (rc) {

net/smc/smc_wr.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,10 @@ int smc_wr_tx_put_slot(struct smc_link *link,
218218
u32 idx = pend->idx;
219219

220220
/* clear the full struct smc_wr_tx_pend including .priv */
221-
memset(&link->wr_tx_pends[pend->idx], 0,
222-
sizeof(link->wr_tx_pends[pend->idx]));
223-
memset(&link->wr_tx_bufs[pend->idx], 0,
224-
sizeof(link->wr_tx_bufs[pend->idx]));
221+
memset(&link->wr_tx_pends[idx], 0,
222+
sizeof(link->wr_tx_pends[idx]));
223+
memset(&link->wr_tx_bufs[idx], 0,
224+
sizeof(link->wr_tx_bufs[idx]));
225225
test_and_clear_bit(idx, link->wr_tx_mask);
226226
return 1;
227227
}

0 commit comments

Comments
 (0)