aboutsummaryrefslogtreecommitdiffstats
path: root/net/rds/send.c
diff options
context:
space:
mode:
authorTina Yang <tina.yang@oracle.com>2010-03-11 08:50:03 -0500
committerDavid S. Miller <davem@davemloft.net>2010-03-17 00:16:58 -0400
commit550a8002e4340eaf3bc333e33b59427e9c20272d (patch)
tree545fe5bccea8aa087233ccecd1dc18570d634d7e /net/rds/send.c
parent97069788d6784ac92d050557a02f6e7bf4d1f53d (diff)
RDS: Fix locking in rds_send_drop_to()
It seems rds_send_drop_to() called __rds_rdma_send_complete(rs, rm, RDS_RDMA_CANCELED) with only rds_sock lock, but not rds_message lock. It raced with other threads that is attempting to modify the rds_message as well, such as from within rds_rdma_send_complete(). Signed-off-by: Tina Yang <tina.yang@oracle.com> Signed-off-by: Andy Grover <andy.grover@oracle.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/rds/send.c')
-rw-r--r--net/rds/send.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/net/rds/send.c b/net/rds/send.c
index 1a2ef24fbc94..192a480076d0 100644
--- a/net/rds/send.c
+++ b/net/rds/send.c
@@ -632,9 +632,6 @@ void rds_send_drop_to(struct rds_sock *rs, struct sockaddr_in *dest)
632 list_move(&rm->m_sock_item, &list); 632 list_move(&rm->m_sock_item, &list);
633 rds_send_sndbuf_remove(rs, rm); 633 rds_send_sndbuf_remove(rs, rm);
634 clear_bit(RDS_MSG_ON_SOCK, &rm->m_flags); 634 clear_bit(RDS_MSG_ON_SOCK, &rm->m_flags);
635
636 /* If this is a RDMA operation, notify the app. */
637 __rds_rdma_send_complete(rs, rm, RDS_RDMA_CANCELED);
638 } 635 }
639 636
640 /* order flag updates with the rs lock */ 637 /* order flag updates with the rs lock */
@@ -643,9 +640,6 @@ void rds_send_drop_to(struct rds_sock *rs, struct sockaddr_in *dest)
643 640
644 spin_unlock_irqrestore(&rs->rs_lock, flags); 641 spin_unlock_irqrestore(&rs->rs_lock, flags);
645 642
646 if (wake)
647 rds_wake_sk_sleep(rs);
648
649 conn = NULL; 643 conn = NULL;
650 644
651 /* now remove the messages from the conn list as needed */ 645 /* now remove the messages from the conn list as needed */
@@ -653,6 +647,10 @@ void rds_send_drop_to(struct rds_sock *rs, struct sockaddr_in *dest)
653 /* We do this here rather than in the loop above, so that 647 /* We do this here rather than in the loop above, so that
654 * we don't have to nest m_rs_lock under rs->rs_lock */ 648 * we don't have to nest m_rs_lock under rs->rs_lock */
655 spin_lock_irqsave(&rm->m_rs_lock, flags2); 649 spin_lock_irqsave(&rm->m_rs_lock, flags2);
650 /* If this is a RDMA operation, notify the app. */
651 spin_lock(&rs->rs_lock);
652 __rds_rdma_send_complete(rs, rm, RDS_RDMA_CANCELED);
653 spin_unlock(&rs->rs_lock);
656 rm->m_rs = NULL; 654 rm->m_rs = NULL;
657 spin_unlock_irqrestore(&rm->m_rs_lock, flags2); 655 spin_unlock_irqrestore(&rm->m_rs_lock, flags2);
658 656
@@ -681,6 +679,9 @@ void rds_send_drop_to(struct rds_sock *rs, struct sockaddr_in *dest)
681 if (conn) 679 if (conn)
682 spin_unlock_irqrestore(&conn->c_lock, flags); 680 spin_unlock_irqrestore(&conn->c_lock, flags);
683 681
682 if (wake)
683 rds_wake_sk_sleep(rs);
684
684 while (!list_empty(&list)) { 685 while (!list_empty(&list)) {
685 rm = list_entry(list.next, struct rds_message, m_sock_item); 686 rm = list_entry(list.next, struct rds_message, m_sock_item);
686 list_del_init(&rm->m_sock_item); 687 list_del_init(&rm->m_sock_item);