From 60d55e42ed9e043341790bf7624627c93cc99200 Mon Sep 17 00:00:00 2001 From: Sergey Gorenko Date: Thu, 4 Mar 2021 14:33:16 +0200 Subject: [PATCH 1/1] LU-14488 o2ib: Use rdma_connect_locked if it is defined 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 Change-Id: I8068d04810bf6f0200292a55f3fdcea8c71d44c1 Reviewed-on: https://review.whamcloud.com/41887 Tested-by: jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Oleg Drokin --- lnet/autoconf/lustre-lnet.m4 | 15 +++++++++++++++ lnet/klnds/o2iblnd/o2iblnd.h | 4 ++++ lnet/klnds/o2iblnd/o2iblnd_cb.c | 3 +-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/lnet/autoconf/lustre-lnet.m4 b/lnet/autoconf/lustre-lnet.m4 index a9f05e3..03cd3c4 100644 --- a/lnet/autoconf/lustre-lnet.m4 +++ b/lnet/autoconf/lustre-lnet.m4 @@ -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_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], []) diff --git a/lnet/klnds/o2iblnd/o2iblnd.h b/lnet/klnds/o2iblnd/o2iblnd.h index 3e4013f..a69c3d0 100644 --- a/lnet/klnds/o2iblnd/o2iblnd.h +++ b/lnet/klnds/o2iblnd/o2iblnd.h @@ -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" */ diff --git a/lnet/klnds/o2iblnd/o2iblnd_cb.c b/lnet/klnds/o2iblnd/o2iblnd_cb.c index 658d0ad..d63626d 100644 --- a/lnet/klnds/o2iblnd/o2iblnd_cb.c +++ b/lnet/klnds/o2iblnd/o2iblnd_cb.c @@ -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); -- 1.8.3.1