Whamcloud - gitweb
LU-12276 lnet: check const parameters for ib_post_send and ib_post_recv 41/34841/2
authorJian Yu <yujian@whamcloud.com>
Thu, 9 May 2019 21:00:46 +0000 (14:00 -0700)
committerOleg Drokin <green@whamcloud.com>
Sat, 11 May 2019 19:23:36 +0000 (19:23 +0000)
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.

This patch is back-ported from the following one:
Lustre-commit: eb4f04e89fecbf6525f00288dbf26487f47103ba
Lustre-change: https://review.whamcloud.com/34837

Change-Id: If7193a6a4fcb7b238f5d4ee64e878a5816433e7b
Test-Parameters: trivial
Signed-off-by: Jian Yu <yujian@whamcloud.com>
Reviewed-by: Sonia Sharma <sharmaso@whamcloud.com>
Reviewed-by: Amir Shehata <ashehata@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/34841
Tested-by: Jenkins
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/autoconf/lustre-lnet.m4
lnet/klnds/o2iblnd/o2iblnd_cb.c

index 8cfae97..990ff27 100644 (file)
@@ -578,6 +578,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 <linux/compat-2.6.h>
+               #endif
+               #include <rdma/ib_verbs.h>
+       ],[
+               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
index 4892118..1a16aba 100644 (file)
@@ -192,7 +192,12 @@ kiblnd_post_rx (kib_rx_t *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);
@@ -841,7 +846,12 @@ __must_hold(&conn->ibc_lock)
                         libcfs_nid2str(conn->ibc_peer->ibp_nid));
 
                bad = NULL;
+#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 = jiffies;