From 1c89b24430f1c1d6398c37d55e1be0b2530bedec Mon Sep 17 00:00:00 2001 From: Chris Mason Date: Fri, 3 Feb 2012 11:07:39 -0500 Subject: [PATCH] RDS: make sure the ring is really full before we return with ENOMEM Signed-off-by: Chris Mason Signed-off-by: Bang Nguyen --- net/rds/ib_cm.c | 4 +--- net/rds/ib_send.c | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c index b91b6dacaf12a..b39d3ce10e0c2 100644 --- a/net/rds/ib_cm.c +++ b/net/rds/ib_cm.c @@ -264,10 +264,8 @@ void rds_ib_tasklet_fn_send(unsigned long data) ib_req_notify_cq(ic->i_scq, IB_CQ_SOLICITED); poll_cq(ic, ic->i_scq, ic->i_send_wc, &ack_state); - if (rds_conn_up(conn)) { - clear_bit(RDS_LL_SEND_FULL, &conn->c_flags); + if (rds_conn_up(conn) && !test_bit(RDS_LL_SEND_FULL, &conn->c_flags)) rds_send_xmit(ic->conn); - } } void rds_ib_tasklet_fn_recv(unsigned long data) diff --git a/net/rds/ib_send.c b/net/rds/ib_send.c index b152c018713b5..e36720d736bcf 100644 --- a/net/rds/ib_send.c +++ b/net/rds/ib_send.c @@ -512,10 +512,19 @@ int rds_ib_xmit(struct rds_connection *conn, struct rds_message *rm, work_alloc = rds_ib_ring_alloc(&ic->i_send_ring, i, &pos); if (work_alloc == 0) { + /* there is a window right here where someone could + * have freed up entries on the ring. Lets make + * sure it really really really is full. + */ set_bit(RDS_LL_SEND_FULL, &conn->c_flags); - rds_ib_stats_inc(s_ib_tx_ring_full); - ret = -ENOMEM; - goto out; + smp_mb(); + work_alloc = rds_ib_ring_alloc(&ic->i_send_ring, i, &pos); + if (work_alloc == 0) { + rds_ib_stats_inc(s_ib_tx_ring_full); + ret = -ENOMEM; + goto out; + } + clear_bit(RDS_LL_SEND_FULL, &conn->c_flags); } if (ic->i_flowctl) { -- 2.50.1