From eb4f04e89fecbf6525f00288dbf26487f47103ba Mon Sep 17 00:00:00 2001 From: Jian Yu Date: Thu, 9 May 2019 01:04:01 -0700 Subject: [PATCH] LU-12276 lnet: check const parameters for ib_post_send and ib_post_recv In MOFED 4.6, the second and third parameters for ib_post_send() and ib_post_recv() are declared with 'const'. This patch adds the check in configure file to resolve build failure. Change-Id: If7193a6a4fcb7b238f5d4ee64e878a5816433e7b Test-Parameters: trivial Signed-off-by: Jian Yu Reviewed-on: https://review.whamcloud.com/34837 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Sonia Sharma Reviewed-by: Amir Shehata Reviewed-by: Oleg Drokin --- lnet/autoconf/lustre-lnet.m4 | 26 ++++++++++++++++++++++++++ lnet/klnds/o2iblnd/o2iblnd_cb.c | 10 ++++++++++ 2 files changed, 36 insertions(+) diff --git a/lnet/autoconf/lustre-lnet.m4 b/lnet/autoconf/lustre-lnet.m4 index 4ea62ad..1a49733 100644 --- a/lnet/autoconf/lustre-lnet.m4 +++ b/lnet/autoconf/lustre-lnet.m4 @@ -537,6 +537,32 @@ AS_IF([test $ENABLEO2IB != "no"], [ [function ib_inc_rkey exist]) ]) + # In MOFED 4.6, the second and third parameters for + # ib_post_send() and ib_post_recv() are declared with + # 'const'. + tmp_flags="$EXTRA_KCFLAGS" + EXTRA_KCFLAGS="-Werror" + LB_CHECK_COMPILE([if 'ib_post_send() and ib_post_recv()' have const parameters], + ib_post_send_recv_const, [ + #ifdef HAVE_COMPAT_RDMA + #undef PACKAGE_NAME + #undef PACKAGE_TARNAME + #undef PACKAGE_VERSION + #undef PACKAGE_STRING + #undef PACKAGE_BUGREPORT + #undef PACKAGE_URL + #include + #endif + #include + ],[ + ib_post_send(NULL, (const struct ib_send_wr *)NULL, + (const struct ib_send_wr **)NULL); + ],[ + AC_DEFINE(HAVE_IB_POST_SEND_RECV_CONST, 1, + [ib_post_send and ib_post_recv have const parameters]) + ]) + EXTRA_KCFLAGS="$tmp_flags" + EXTRA_CHECK_INCLUDE="" ]) # ENABLEO2IB != "no" ]) # LN_CONFIG_O2IB diff --git a/lnet/klnds/o2iblnd/o2iblnd_cb.c b/lnet/klnds/o2iblnd/o2iblnd_cb.c index ab0f6f8..a0edce8 100644 --- a/lnet/klnds/o2iblnd/o2iblnd_cb.c +++ b/lnet/klnds/o2iblnd/o2iblnd_cb.c @@ -203,7 +203,12 @@ kiblnd_post_rx(struct kib_rx *rx, int credit) * own this rx (and rx::rx_conn) anymore, LU-5678. */ kiblnd_conn_addref(conn); +#ifdef HAVE_IB_POST_SEND_RECV_CONST + rc = ib_post_recv(conn->ibc_cmid->qp, &rx->rx_wrq, + (const struct ib_recv_wr **)&bad_wrq); +#else rc = ib_post_recv(conn->ibc_cmid->qp, &rx->rx_wrq, &bad_wrq); +#endif if (unlikely(rc != 0)) { CERROR("Can't post rx for %s: %d, bad_wrq: %p\n", libcfs_nid2str(conn->ibc_peer->ibp_nid), rc, bad_wrq); @@ -974,7 +979,12 @@ __must_hold(&conn->ibc_lock) if (lnet_send_error_simulation(tx->tx_lntmsg[0], &tx->tx_hstatus)) rc = -EINVAL; else +#ifdef HAVE_IB_POST_SEND_RECV_CONST + rc = ib_post_send(conn->ibc_cmid->qp, wr, + (const struct ib_send_wr **)&bad); +#else rc = ib_post_send(conn->ibc_cmid->qp, wr, &bad); +#endif } conn->ibc_last_send = ktime_get(); -- 1.8.3.1