Skip to content

Commit

Permalink
Merge branch 'rds-net'
Browse files Browse the repository at this point in the history
Herton R. Krzesinski says:

====================
Small fixes/changes for RDS

I got a report of one issue within RDS (after investigation it was a double
free), and I'm sending the fix (patch 3/3) which reporter said it works (no more
WARNING triggered on a specially instrumented kernel). The report/test was done
on a very old kernel (RHEL 5, 2.6.18 based with backports), but the problem the
patch handles still exists and should not change. Besides that, while
reviewing some of the code but being unable to reproduce with rds_tcp, I
noticed two small improvements/fixes which are in patches 1 and 2.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Oct 3, 2014
2 parents ee042ec + 593cbb3 commit fba7516
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
11 changes: 7 additions & 4 deletions net/rds/send.c
Original file line number Diff line number Diff line change
Expand Up @@ -593,8 +593,11 @@ static void rds_send_remove_from_sock(struct list_head *messages, int status)
sock_put(rds_rs_to_sk(rs));
}
rs = rm->m_rs;
sock_hold(rds_rs_to_sk(rs));
if (rs)
sock_hold(rds_rs_to_sk(rs));
}
if (!rs)
goto unlock_and_drop;
spin_lock(&rs->rs_lock);

if (test_and_clear_bit(RDS_MSG_ON_SOCK, &rm->m_flags)) {
Expand Down Expand Up @@ -638,9 +641,6 @@ static void rds_send_remove_from_sock(struct list_head *messages, int status)
* queue. This means that in the TCP case, the message may not have been
* assigned the m_ack_seq yet - but that's fine as long as tcp_is_acked
* checks the RDS_MSG_HAS_ACK_SEQ bit.
*
* XXX It's not clear to me how this is safely serialized with socket
* destruction. Maybe it should bail if it sees SOCK_DEAD.
*/
void rds_send_drop_acked(struct rds_connection *conn, u64 ack,
is_acked_func is_acked)
Expand Down Expand Up @@ -711,6 +711,9 @@ void rds_send_drop_to(struct rds_sock *rs, struct sockaddr_in *dest)
*/
if (!test_and_clear_bit(RDS_MSG_ON_CONN, &rm->m_flags)) {
spin_unlock_irqrestore(&conn->c_lock, flags);
spin_lock_irqsave(&rm->m_rs_lock, flags);
rm->m_rs = NULL;
spin_unlock_irqrestore(&rm->m_rs_lock, flags);
continue;
}
list_del_init(&rm->m_conn_item);
Expand Down
5 changes: 4 additions & 1 deletion net/rds/tcp_connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,14 @@ int rds_tcp_conn_connect(struct rds_connection *conn)
rds_tcp_set_callbacks(sock, conn);
ret = sock->ops->connect(sock, (struct sockaddr *)&dest, sizeof(dest),
O_NONBLOCK);
sock = NULL;

rdsdebug("connect to address %pI4 returned %d\n", &conn->c_faddr, ret);
if (ret == -EINPROGRESS)
ret = 0;
if (ret == 0)
sock = NULL;
else
rds_tcp_restore_callbacks(sock, conn->c_transport_data);

out:
if (sock)
Expand Down
3 changes: 1 addition & 2 deletions net/rds/threads.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ void rds_connect_complete(struct rds_connection *conn)
"current state is %d\n",
__func__,
atomic_read(&conn->c_state));
atomic_set(&conn->c_state, RDS_CONN_ERROR);
queue_work(rds_wq, &conn->c_down_w);
rds_conn_drop(conn);
return;
}

Expand Down

0 comments on commit fba7516

Please sign in to comment.