[Devel] [PATCH RHEL8 COMMIT] fs/fuse kio: post rdma work requests only after connection is established

Konstantin Khorenko khorenko at virtuozzo.com
Fri Apr 23 11:54:58 MSK 2021


The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.vz8.5.19
------>
commit e51d1596819cad531f4493cbb3d4328d4fbca8f6
Author: Ildar Ismagilov <ildar.ismagilov at virtuozzo.com>
Date:   Fri Apr 23 11:54:58 2021 +0300

    fs/fuse kio: post rdma work requests only after connection is established
    
    Some RDMA drivers only generate completions for work requests
    that are posted after connection is established. And if connection
    is rejected our posted works will never be completed, as result we
    have a resource leak. To fix this problem we don't post work requests
    until connection is established.
    
    https://pmc.acronis.com/browse/VSTOR-38116
    
    Signed-off-by: Ildar Ismagilov <ildar.ismagilov at virtuozzo.com>
    
    Reviewed-by: Andrey Zaitsev <azaitsev at virtuozzo.com>
---
 fs/fuse/kio/pcs/pcs_rdma_conn.c |  4 ++++
 fs/fuse/kio/pcs/pcs_rdma_io.c   | 25 +++++++++++++------------
 fs/fuse/kio/pcs/pcs_rdma_io.h   |  1 +
 3 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/fs/fuse/kio/pcs/pcs_rdma_conn.c b/fs/fuse/kio/pcs/pcs_rdma_conn.c
index 521089cdba58..4db903151de0 100644
--- a/fs/fuse/kio/pcs/pcs_rdma_conn.c
+++ b/fs/fuse/kio/pcs/pcs_rdma_conn.c
@@ -80,6 +80,10 @@ static int pcs_rdma_cm_event_handler(struct rdma_cm_id *cmid,
 			break;
 		case RDMA_CM_EVENT_ESTABLISHED:
 			cmid->context = &rc->rio->id;
+			if (pcs_rdma_established(rc->rio)) {
+				TRACE("pcs_rdma_established failed, rio: 0x%p\n", rc->rio);
+				rc->cm_event = RDMA_CM_EVENT_REJECTED;
+			}
 			complete(&rc->cm_done);
 			break;
 		case RDMA_CM_EVENT_REJECTED:
diff --git a/fs/fuse/kio/pcs/pcs_rdma_io.c b/fs/fuse/kio/pcs/pcs_rdma_io.c
index e5cf699afe9b..cec3e556a7bf 100644
--- a/fs/fuse/kio/pcs/pcs_rdma_io.c
+++ b/fs/fuse/kio/pcs/pcs_rdma_io.c
@@ -1174,7 +1174,6 @@ struct pcs_rdmaio* pcs_rdma_create(int hdr_size, struct rdma_cm_id *cmid,
 				   int queue_depth, struct pcs_rpc *ep)
 {
 	struct pcs_rdmaio *rio;
-	struct rio_rx *rx;
 	struct ib_cq_init_attr cq_attr = {};
 	struct ib_qp_init_attr qp_attr = {};
 	int recv_queue_depth = queue_depth * 2 + 2;
@@ -1295,21 +1294,10 @@ struct pcs_rdmaio* pcs_rdma_create(int hdr_size, struct rdma_cm_id *cmid,
 		goto free_cq;
 	}
 
-	for (rx = rio->rx_descs; rx - rio->rx_descs < recv_queue_depth; rx++)
-		if (rio_rx_post(rio, rx, RIO_MSG_SIZE)) {
-			TRACE("rio_rx_post failed: rio: 0x%p\n", rio);
-			break;
-		}
-
-	if (rio->n_rx_posted != recv_queue_depth)
-		goto free_qp;
-
 	TRACE("rio: 0x%p, dev: 0x%p, queue_depth: %d\n", rio, rio->dev, queue_depth);
 
 	return rio;
 
-free_qp:
-	rdma_destroy_qp(rio->cmid);
 free_cq:
 	ib_destroy_cq(rio->cq);
 free_dev:
@@ -1324,6 +1312,19 @@ struct pcs_rdmaio* pcs_rdma_create(int hdr_size, struct rdma_cm_id *cmid,
 	return NULL;
 }
 
+int pcs_rdma_established(struct pcs_rdmaio *rio)
+{
+	struct rio_rx *rx;
+
+	for (rx = rio->rx_descs; rx - rio->rx_descs < rio->recv_queue_depth; rx++)
+		if (rio_rx_post(rio, rx, RIO_MSG_SIZE)) {
+			TRACE("rio_rx_post failed: rio: 0x%p\n", rio);
+			break;
+		}
+
+	return rio->n_rx_posted == rio->recv_queue_depth ? 0 : -EINVAL;
+}
+
 static void rio_cleanup(struct pcs_rdmaio *rio)
 {
 	rio_perform_tx_jobs(rio);
diff --git a/fs/fuse/kio/pcs/pcs_rdma_io.h b/fs/fuse/kio/pcs/pcs_rdma_io.h
index b411098eaebb..69d817d98d78 100644
--- a/fs/fuse/kio/pcs/pcs_rdma_io.h
+++ b/fs/fuse/kio/pcs/pcs_rdma_io.h
@@ -106,6 +106,7 @@ struct pcs_rdmaio
 
 struct pcs_rdmaio* pcs_rdma_create(int hdr_size, struct rdma_cm_id *cmid,
 		int queue_depth, struct pcs_rpc *ep);
+int pcs_rdma_established(struct pcs_rdmaio *rio);
 void pcs_rdma_destroy(struct pcs_rdmaio *rio);
 void pcs_rdma_ioconn_destruct(struct pcs_ioconn *ioconn);
 


More information about the Devel mailing list