From 3d6e0fed8edc2f5d5439bee22c2fa153096c77ea Mon Sep 17 00:00:00 2001 From: Wengang Wang Date: Tue, 4 Aug 2015 16:00:55 +0800 Subject: [PATCH] rds_rdma: rds_sendmsg should return EAGAIN if connection not setup In rds_sendmsg(), in the case RDS_CMSG_RDMA_MAP is requested and rds_cmsg_send() is called, a "struct rds_mr" needs to be created. For creating the "struct rds_mr", the connection needs to be established(ready) for rds_ib_transport. Otherwise, __rds_rdma_map() would fail because it can't find the right rds_ib_device (which is associated with the ip address matching rds_sock's bound ip address). The ip address is set at the completion of the rdma connection. But actually in code, the connecting is triggered after the call of call rds_cmsg_send() so rds_cmsg_send() would fail with -NODEV. The fix is to move the trigger of connection before calling rds_cmsg_send() and return -EAGAIN in case connection is not ready yet when we are calling rds_cmsg_send(). Orabug: 21551474 Signed-off-by: Wengang Wang Reviewed-by: Chien-Hua Yen --- net/rds/send.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/net/rds/send.c b/net/rds/send.c index a8a2dc0881c9..3174eb02c166 100644 --- a/net/rds/send.c +++ b/net/rds/send.c @@ -1226,11 +1226,6 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len) rm->m_daddr = daddr; - /* Parse any control messages the user may have included. */ - ret = rds_cmsg_send(rs, rm, msg, &allocated_mr); - if (ret) - goto out; - if (rm->rdma.op_active) total_payload_len += rm->rdma.op_bytes; @@ -1318,6 +1313,16 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len) goto out; } + if (!rds_conn_up(conn)) { + ret = -EAGAIN; + goto out; + } + + /* Parse any control messages the user may have included. */ + ret = rds_cmsg_send(rs, rm, msg, &allocated_mr); + if (ret) + goto out; + while (!rds_send_queue_rm(rs, conn, rm, rs->rs_bound_port, dport, &queued)) { rds_stats_inc(s_send_queue_full); -- 2.49.0