Skip to content

Commit

Permalink
Merge branch 'smc-fixes'
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
davem330 committed Feb 1, 2019
2 parents 7596175 + 46ad022 commit ec34f79
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 21 deletions.
11 changes: 10 additions & 1 deletion net/smc/af_smc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1505,6 +1505,11 @@ static int smc_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,

smc = smc_sk(sk);
lock_sock(sk);
if (sk->sk_state == SMC_CLOSED && (sk->sk_shutdown & RCV_SHUTDOWN)) {
/* socket was connected before, no more data to read */
rc = 0;
goto out;
}
if ((sk->sk_state == SMC_INIT) ||
(sk->sk_state == SMC_LISTEN) ||
(sk->sk_state == SMC_CLOSED))
Expand Down Expand Up @@ -1840,7 +1845,11 @@ static ssize_t smc_splice_read(struct socket *sock, loff_t *ppos,

smc = smc_sk(sk);
lock_sock(sk);

if (sk->sk_state == SMC_CLOSED && (sk->sk_shutdown & RCV_SHUTDOWN)) {
/* socket was connected before, no more data to read */
rc = 0;
goto out;
}
if (sk->sk_state == SMC_INIT ||
sk->sk_state == SMC_LISTEN ||
sk->sk_state == SMC_CLOSED)
Expand Down
5 changes: 4 additions & 1 deletion net/smc/smc_cdc.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ static int smcr_cdc_get_slot_and_msg_send(struct smc_connection *conn)
if (rc)
return rc;

return smc_cdc_msg_send(conn, wr_buf, pend);
spin_lock_bh(&conn->send_lock);
rc = smc_cdc_msg_send(conn, wr_buf, pend);
spin_unlock_bh(&conn->send_lock);
return rc;
}

int smc_cdc_get_slot_and_msg_send(struct smc_connection *conn)
Expand Down
2 changes: 1 addition & 1 deletion net/smc/smc_clc.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ int smc_clc_send_decline(struct smc_sock *smc, u32 peer_diag_info)
vec.iov_len = sizeof(struct smc_clc_msg_decline);
len = kernel_sendmsg(smc->clcsock, &msg, &vec, 1,
sizeof(struct smc_clc_msg_decline));
if (len < sizeof(struct smc_clc_msg_decline))
if (len < 0 || len < sizeof(struct smc_clc_msg_decline))
len = -EPROTO;
return len > 0 ? 0 : len;
}
Expand Down
4 changes: 4 additions & 0 deletions net/smc/smc_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ static void smc_lgr_unregister_conn(struct smc_connection *conn)
{
struct smc_link_group *lgr = conn->lgr;

if (!lgr)
return;
write_lock_bh(&lgr->conns_lock);
if (conn->alert_token_local) {
__smc_lgr_unregister_conn(conn);
Expand Down Expand Up @@ -628,6 +630,8 @@ int smc_conn_create(struct smc_sock *smc, bool is_smcd, int srv_first_contact,
local_contact = SMC_REUSE_CONTACT;
conn->lgr = lgr;
smc_lgr_register_conn(conn); /* add smc conn to lgr */
if (delayed_work_pending(&lgr->free_work))
cancel_delayed_work(&lgr->free_work);
write_unlock_bh(&lgr->conns_lock);
break;
}
Expand Down
6 changes: 3 additions & 3 deletions net/smc/smc_ib.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,16 +289,16 @@ int smc_ib_create_protection_domain(struct smc_link *lnk)

static void smc_ib_qp_event_handler(struct ib_event *ibevent, void *priv)
{
struct smc_ib_device *smcibdev =
(struct smc_ib_device *)ibevent->device;
struct smc_link *lnk = (struct smc_link *)priv;
struct smc_ib_device *smcibdev = lnk->smcibdev;
u8 port_idx;

switch (ibevent->event) {
case IB_EVENT_DEVICE_FATAL:
case IB_EVENT_GID_CHANGE:
case IB_EVENT_PORT_ERR:
case IB_EVENT_QP_ACCESS_ERR:
port_idx = ibevent->element.port_num - 1;
port_idx = ibevent->element.qp->port - 1;
set_bit(port_idx, &smcibdev->port_event_mask);
schedule_work(&smcibdev->port_event_work);
break;
Expand Down
2 changes: 1 addition & 1 deletion net/smc/smc_pnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
static struct nla_policy smc_pnet_policy[SMC_PNETID_MAX + 1] = {
[SMC_PNETID_NAME] = {
.type = NLA_NUL_STRING,
.len = SMC_MAX_PNETID_LEN - 1
.len = SMC_MAX_PNETID_LEN
},
[SMC_PNETID_ETHNAME] = {
.type = NLA_NUL_STRING,
Expand Down
17 changes: 7 additions & 10 deletions net/smc/smc_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,11 @@ int smc_tx_sendmsg(struct smc_sock *smc, struct msghdr *msg, size_t len)
conn->local_tx_ctrl.prod_flags.urg_data_pending = 1;

if (!atomic_read(&conn->sndbuf_space) || conn->urg_tx_pend) {
if (send_done)
return send_done;
rc = smc_tx_wait(smc, msg->msg_flags);
if (rc) {
if (send_done)
return send_done;
if (rc)
goto out_err;
}
continue;
}

Expand Down Expand Up @@ -489,25 +488,23 @@ static int smcr_tx_sndbuf_nonempty(struct smc_connection *conn)
struct smc_wr_buf *wr_buf;
int rc;

spin_lock_bh(&conn->send_lock);
rc = smc_cdc_get_free_slot(conn, &wr_buf, &pend);
if (rc < 0) {
if (rc == -EBUSY) {
struct smc_sock *smc =
container_of(conn, struct smc_sock, conn);

if (smc->sk.sk_err == ECONNABORTED) {
rc = sock_error(&smc->sk);
goto out_unlock;
}
if (smc->sk.sk_err == ECONNABORTED)
return sock_error(&smc->sk);
rc = 0;
if (conn->alert_token_local) /* connection healthy */
mod_delayed_work(system_wq, &conn->tx_work,
SMC_TX_WORK_DELAY);
}
goto out_unlock;
return rc;
}

spin_lock_bh(&conn->send_lock);
if (!conn->local_tx_ctrl.prod_flags.urg_data_present) {
rc = smc_tx_rdma_writes(conn);
if (rc) {
Expand Down
8 changes: 4 additions & 4 deletions net/smc/smc_wr.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,10 @@ int smc_wr_tx_put_slot(struct smc_link *link,
u32 idx = pend->idx;

/* clear the full struct smc_wr_tx_pend including .priv */
memset(&link->wr_tx_pends[pend->idx], 0,
sizeof(link->wr_tx_pends[pend->idx]));
memset(&link->wr_tx_bufs[pend->idx], 0,
sizeof(link->wr_tx_bufs[pend->idx]));
memset(&link->wr_tx_pends[idx], 0,
sizeof(link->wr_tx_pends[idx]));
memset(&link->wr_tx_bufs[idx], 0,
sizeof(link->wr_tx_bufs[idx]));
test_and_clear_bit(idx, link->wr_tx_mask);
return 1;
}
Expand Down

0 comments on commit ec34f79

Please sign in to comment.