[RHEL7,COMMIT] fs/fuse kio: set the connection params for RDMA properly

Submitted by Konstantin Khorenko on June 18, 2020, 5:13 p.m.

Details

Message ID 202006181713.05IHDRjI002750@finist-ce7.sw.ru
State New
Series "fs/fuse kio: set the connection params for RDMA properly"
Headers show

Commit Message

Konstantin Khorenko June 18, 2020, 5:13 p.m.
The commit is pushed to "branch-rh7-3.10.0-1127.10.1.vz7.162.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1127.10.1.vz7.162.4
------>
commit 4a35fce2eb62e5af1246a2106f9b41e3ff42f2b8
Author: Ildar Ismagilov <Ildar.Ismagilov@acronis.com>
Date:   Thu Jun 18 20:13:27 2020 +0300

    fs/fuse kio: set the connection params for RDMA properly
    
    The responder_resources value must be less than or equal to RDMA device
    attribute max_qp_rd_atom. Also the initiator_depth value must be less
    than or equal to RDMA device attribute max_qp_init_rd_atom. So set
    the connection parameters properly.
    
    The problem with incorrect connection parameters was reproduced in
    case of mlx4 driver.
    
    Signed-off-by: Ildar Ismagilov <ildar.ismagilov@virtuozzo.com>
    Reviewed-by: Andrey Zaitsev <azaitsev@virtuozzo.com>
---
 fs/fuse/kio/pcs/pcs_rdma_conn.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

Patch hide | download patch | download mbox

diff --git a/fs/fuse/kio/pcs/pcs_rdma_conn.c b/fs/fuse/kio/pcs/pcs_rdma_conn.c
index ff6225afbbfaf..521089cdba589 100644
--- a/fs/fuse/kio/pcs/pcs_rdma_conn.c
+++ b/fs/fuse/kio/pcs/pcs_rdma_conn.c
@@ -14,11 +14,6 @@ 
 
 #define RESOLVE_TIMEOUT_MS 5000
 
-enum {
-    RDMA_MAX_RESP_RES = 0xFF,
-    RDMA_MAX_INIT_DEPTH = 0xFF
-};
-
 struct pcs_rdmaconnect
 {
 	struct pcs_rpc *ep;
@@ -35,7 +30,8 @@  struct pcs_rdmaconnect
 extern unsigned int rdmaio_queue_depth;
 
 static void
-conn_param_init(struct rdma_conn_param *cp, struct pcs_rdmaio_conn_req *cr)
+conn_param_init(struct rdma_conn_param *cp, struct pcs_rdmaio_conn_req *cr,
+		struct rdma_cm_id *cmid)
 {
 	memset(cp, 0, sizeof(*cp));
 
@@ -44,9 +40,8 @@  conn_param_init(struct rdma_conn_param *cp, struct pcs_rdmaio_conn_req *cr)
 		cp->private_data_len = sizeof(*cr);
 	}
 
-	/* these two guys are about RDMA reads: see man rdma_connect(3) */
-	cp->responder_resources = RDMA_MAX_RESP_RES;
-	cp->initiator_depth     = RDMA_MAX_INIT_DEPTH;
+	cp->responder_resources = min_t(int, U8_MAX, cmid->device->attrs.max_qp_rd_atom);
+	cp->initiator_depth     = min_t(int, U8_MAX, cmid->device->attrs.max_qp_init_rd_atom);
 
 	cp->flow_control        = 1; /* does not matter */
 	cp->retry_count         = 0; /* # retransmissions when no ACK received */
@@ -77,7 +72,7 @@  static int pcs_rdma_cm_event_handler(struct rdma_cm_id *cmid,
 			}
 			rc->cmid = NULL;
 
-			conn_param_init(&conn_param, &rc->rio->conn_req);
+			conn_param_init(&conn_param, &rc->rio->conn_req, cmid);
 			if (rdma_connect(cmid, &conn_param)) {
 				TRACE("rdma_connect failed: rio: 0x%p\n", rc->rio);
 				complete(&rc->cm_done);