Skip to content

Commit 9e53269

Browse files
SantoshShilimkargerd-rausch
authored andcommitted
RDS: establish connection for legitimate remote RDMA message
The first message to a remote node should prompt a new connection even if it is RDMA operation via CMSG. So that means before CMSG parsing, the connection needs to be established. Commit 3d6e0fe ("rds_rdma: rds_sendmsg should return EAGAIN if connection not setup")' tried to address that issue as part of bug 20232581. But it inadvertently broke the QoS policy evaluation. Basically QoS has opposite requirement where it needs information from CMSG to evaluate if the message is legitimate to be sent over the wire. It basically needs to know how the total payload which should include the actual payload and additional rdma bytes. It then evaluates total payload with the systems QoS thresholds to determine if the message is legitimate to be sent. Patch addresses these two opposite requirement by fetching only the rdma bytes information for QoS evaluation and let the full CMSG parsing happen after the connection is initiated. Since the connection establishment is asynchronous, we make sure the map failure because of unavailable connection reach to the user by appropriate error code. Orabug: 22139696 Signed-off-by: Wengang Wang <[email protected]> Signed-off-by: Santosh Shilimkar <[email protected]> Reviewed-by: Ajaykumar Hotchandani <[email protected]> Orabug: 27364391 (cherry picked from commit 825878a) cherry-pick-repo=linux-uek.git Signed-off-by: Gerd Rausch <[email protected]> Signed-off-by: Somasundaram Krishnasamy <[email protected]>
1 parent 8f2a6a7 commit 9e53269

File tree

1 file changed

+34
-6
lines changed

1 file changed

+34
-6
lines changed

net/rds/send.c

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,6 +1133,11 @@ static int rds_cmsg_send(struct rds_sock *rs, struct rds_message *rm,
11331133
ret = rds_cmsg_rdma_map(rs, rm, cmsg);
11341134
if (!ret)
11351135
*allocated_mr = 1;
1136+
else if (ret == -ENODEV)
1137+
/* Accomodate the get_mr() case which can fail
1138+
* if connection isn't established yet.
1139+
*/
1140+
ret = -EAGAIN;
11361141
break;
11371142
case RDS_CMSG_ATOMIC_CSWP:
11381143
case RDS_CMSG_ATOMIC_FADD:
@@ -1154,6 +1159,22 @@ static int rds_cmsg_send(struct rds_sock *rs, struct rds_message *rm,
11541159
return ret;
11551160
}
11561161

1162+
static inline unsigned int rds_rdma_bytes(struct msghdr *msg)
1163+
{
1164+
struct rds_rdma_args *args;
1165+
struct cmsghdr *cmsg;
1166+
unsigned int rdma_bytes = 0;
1167+
1168+
for_each_cmsghdr(cmsg, msg) {
1169+
if (cmsg->cmsg_type == RDS_CMSG_RDMA_ARGS) {
1170+
args = CMSG_DATA(cmsg);
1171+
rdma_bytes += args->remote_vec.bytes;
1172+
}
1173+
}
1174+
1175+
return rdma_bytes;
1176+
}
1177+
11571178
int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len)
11581179
{
11591180
struct sock *sk = sock->sk;
@@ -1228,13 +1249,11 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len)
12281249

12291250
rm->m_daddr = daddr;
12301251

1231-
/* Parse any control messages the user may have included. */
1232-
ret = rds_cmsg_send(rs, rm, msg, &allocated_mr);
1233-
if (ret)
1234-
goto out;
1235-
1252+
/* For RDMA operation(s), add up rmda bytes to payload to make
1253+
* sure its within system QoS threshold limits.
1254+
*/
12361255
if (rm->rdma.op_active)
1237-
total_payload_len += rm->rdma.op_bytes;
1256+
total_payload_len += rds_rdma_bytes(msg);
12381257

12391258
if (rds_check_qos_threshold(rs->rs_tos, total_payload_len)) {
12401259
ret = -EINVAL;
@@ -1289,6 +1308,15 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len)
12891308
}
12901309
}
12911310

1311+
/* Parse any control messages the user may have included. */
1312+
ret = rds_cmsg_send(rs, rm, msg, &allocated_mr);
1313+
if (ret) {
1314+
/* Trigger connection so that its ready for the next retry */
1315+
if ( ret == -EAGAIN)
1316+
rds_conn_connect_if_down(conn);
1317+
goto out;
1318+
}
1319+
12921320
/* Not accepting new sends until all the failed ops have been reaped */
12931321
if (rds_async_send_enabled && conn->c_pending_flush) {
12941322
ret = -EAGAIN;

0 commit comments

Comments
 (0)