Whamcloud - gitweb
LU-14488 o2ib: Use rdma_connect_locked if it is defined 87/41887/5
authorSergey Gorenko <sergeygo@nvidia.com>
Thu, 4 Mar 2021 12:33:16 +0000 (14:33 +0200)
committerOleg Drokin <green@whamcloud.com>
Tue, 9 Mar 2021 18:19:27 +0000 (18:19 +0000)
rdma_connect_locked() is added in the upstream kernel 5.10 and
MOFED-5.2-2. After that, it is not allowed to call rdma_connect()
in RDMA CM event handler; rdma_connect_locked() must be used
instead.

This commit adds configure checks to detect whether
rdma_connect_locked() is available and updates the event handler
to call the correct function.

Test-Parameters: trivial
Signed-off-by: Sergey Gorenko <sergeygo@nvidia.com>
Change-Id: I8068d04810bf6f0200292a55f3fdcea8c71d44c1
Reviewed-on: https://review.whamcloud.com/41887
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/autoconf/lustre-lnet.m4
lnet/klnds/o2iblnd/o2iblnd.h
lnet/klnds/o2iblnd/o2iblnd_cb.c

index a9f05e3..03cd3c4 100644 (file)
@@ -554,6 +554,21 @@ AS_IF([test $ENABLEO2IB != "no"], [
                        [FMR pool API is available])
        ])
 
+       # rdma_connect_locked() was added in Linux 5.10,
+       # commit 071ba4cc559de47160761b9500b72e8fa09d923d
+       # and in MOFED-5.2-2. rdma_connect_locked() must
+       # be called instead of rdma_connect() in
+       # RDMA_CM_EVENT_ROUTE_RESOLVED handler.
+       LB_CHECK_COMPILE([if 'rdma_connect_locked' exists],
+       rdma_connect_locked, [
+               #include <rdma/rdma_cm.h>
+       ],[
+               rdma_connect_locked(NULL, NULL);
+       ],[
+               AC_DEFINE(HAVE_RDMA_CONNECT_LOCKED, 1,
+                       [rdma_connect_locked is defined])
+       ])
+
        EXTRA_CHECK_INCLUDE=""
        AC_DEFUN([LN_CONFIG_O2IB_SRC], [])
        AC_DEFUN([LN_CONFIG_O2IB_RESULTS], [])
index 3e4013f..a69c3d0 100644 (file)
@@ -1064,6 +1064,10 @@ static inline unsigned int kiblnd_sg_dma_len(struct ib_device *dev,
         return ib_sg_dma_len(dev, sg);
 }
 
+#ifndef HAVE_RDMA_CONNECT_LOCKED
+#define rdma_connect_locked(cmid, cpp) rdma_connect(cmid, cpp)
+#endif
+
 /* XXX We use KIBLND_CONN_PARAM(e) as writable buffer, it's not strictly
  * right because OFED1.2 defines it as const, to use it we have to add
  * (void *) cast to overcome "const" */
index 658d0ad..d63626d 100644 (file)
@@ -3115,8 +3115,7 @@ kiblnd_active_connect(struct rdma_cm_id *cmid)
 
         LASSERT(cmid->context == (void *)conn);
         LASSERT(conn->ibc_cmid == cmid);
-
-        rc = rdma_connect(cmid, &cp);
+       rc = rdma_connect_locked(cmid, &cp);
         if (rc != 0) {
                 CERROR("Can't connect to %s: %d\n",
                        libcfs_nid2str(peer_ni->ibp_nid), rc);