Commit 048c15e6 authored by Tina Yang's avatar Tina Yang Committed by David S. Miller

RDS: Fix send locking issue

Fix a deadlock between rds_rdma_send_complete() and
rds_send_remove_from_sock() when rds socket lock and
rds message lock are acquired out-of-order.
Signed-off-by: default avatarTina Yang <Tina.Yang@oracle.com>
Signed-off-by: default avatarAndy Grover <andy.grover@oracle.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2e7b3b99
...@@ -533,14 +533,13 @@ void rds_send_remove_from_sock(struct list_head *messages, int status) ...@@ -533,14 +533,13 @@ void rds_send_remove_from_sock(struct list_head *messages, int status)
if (rs != rm->m_rs) { if (rs != rm->m_rs) {
if (rs) { if (rs) {
spin_unlock(&rs->rs_lock);
rds_wake_sk_sleep(rs); rds_wake_sk_sleep(rs);
sock_put(rds_rs_to_sk(rs)); sock_put(rds_rs_to_sk(rs));
} }
rs = rm->m_rs; rs = rm->m_rs;
spin_lock(&rs->rs_lock);
sock_hold(rds_rs_to_sk(rs)); sock_hold(rds_rs_to_sk(rs));
} }
spin_lock(&rs->rs_lock);
if (test_and_clear_bit(RDS_MSG_ON_SOCK, &rm->m_flags)) { if (test_and_clear_bit(RDS_MSG_ON_SOCK, &rm->m_flags)) {
struct rds_rdma_op *ro = rm->m_rdma_op; struct rds_rdma_op *ro = rm->m_rdma_op;
...@@ -560,6 +559,7 @@ void rds_send_remove_from_sock(struct list_head *messages, int status) ...@@ -560,6 +559,7 @@ void rds_send_remove_from_sock(struct list_head *messages, int status)
rds_message_put(rm); rds_message_put(rm);
rm->m_rs = NULL; rm->m_rs = NULL;
} }
spin_unlock(&rs->rs_lock);
unlock_and_drop: unlock_and_drop:
spin_unlock(&rm->m_rs_lock); spin_unlock(&rm->m_rs_lock);
...@@ -567,7 +567,6 @@ void rds_send_remove_from_sock(struct list_head *messages, int status) ...@@ -567,7 +567,6 @@ void rds_send_remove_from_sock(struct list_head *messages, int status)
} }
if (rs) { if (rs) {
spin_unlock(&rs->rs_lock);
rds_wake_sk_sleep(rs); rds_wake_sk_sleep(rs);
sock_put(rds_rs_to_sk(rs)); sock_put(rds_rs_to_sk(rs));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment