From dfa279f9568b934ec1126d8a6302b23a84046ab9 Mon Sep 17 00:00:00 2001 From: "Christopher J. Morrone" Date: Wed, 24 Aug 2016 16:35:44 -0700 Subject: [PATCH] LU-8540 o2iblnd: Add support for 5arg ib_map_mr_sg() Starting in kernel v4.7, ib_map_mr_sg() takes five arguments rather than four. It added an "sg_offset_p" offset pointer argument. RHEL7.3 also contains this change. Change-Id: Ie63c992421bdf4ca195cf55152e6dfed9cf40e1d Signed-off-by: Christopher J. Morrone Reviewed-on: http://review.whamcloud.com/22126 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Bob Glossman Reviewed-by: James Simmons Reviewed-by: Dmitry Eremin Reviewed-by: Li Dongyang Reviewed-by: Oleg Drokin --- lnet/autoconf/lustre-lnet.m4 | 27 +++++++++++++++++++++++++-- lnet/klnds/o2iblnd/o2iblnd.c | 5 +++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/lnet/autoconf/lustre-lnet.m4 b/lnet/autoconf/lustre-lnet.m4 index 47a4ff1..a1fdb5e 100644 --- a/lnet/autoconf/lustre-lnet.m4 +++ b/lnet/autoconf/lustre-lnet.m4 @@ -453,8 +453,8 @@ AS_IF([test $ENABLEO2IB != "no"], [ ]) # new fast registration API introduced in 4.4 - LB_CHECK_COMPILE([if 'ib_map_mr_sg' exists], - ib_map_mr_sg, [ + LB_CHECK_COMPILE([if 4arg 'ib_map_mr_sg' exists], + ib_map_mr_sg_4args, [ #ifdef HAVE_COMPAT_RDMA #undef PACKAGE_NAME #undef PACKAGE_TARNAME @@ -472,6 +472,29 @@ AS_IF([test $ENABLEO2IB != "no"], [ [ib_map_mr_sg exists]) ]) + # ib_map_mr_sg changes from 4 to 5 args (adding sg_offset_p) + # in kernel 4.7 (and RHEL 7.3) + LB_CHECK_COMPILE([if 5arg 'ib_map_mr_sg' exists], + ib_map_mr_sg_5args, [ + #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_map_mr_sg(NULL, NULL, 0, NULL, 0); + ],[ + AC_DEFINE(HAVE_IB_MAP_MR_SG, 1, + [ib_map_mr_sg exists]) + AC_DEFINE(HAVE_IB_MAP_MR_SG_5ARGS, 1, + [ib_map_mr_sg has 5 arguments]) + ]) + # ib_query_device() removed in 4.5 LB_CHECK_COMPILE([if 'struct ib_device' has member 'attrs'], ib_device.attrs, [ diff --git a/lnet/klnds/o2iblnd/o2iblnd.c b/lnet/klnds/o2iblnd/o2iblnd.c index aeecb30..9c6b8d5 100644 --- a/lnet/klnds/o2iblnd/o2iblnd.c +++ b/lnet/klnds/o2iblnd/o2iblnd.c @@ -1877,8 +1877,13 @@ again: } #ifdef HAVE_IB_MAP_MR_SG +#ifdef HAVE_IB_MAP_MR_SG_5ARGS + n = ib_map_mr_sg(mr, tx->tx_frags, + tx->tx_nfrags, NULL, PAGE_SIZE); +#else n = ib_map_mr_sg(mr, tx->tx_frags, tx->tx_nfrags, PAGE_SIZE); +#endif if (unlikely(n != tx->tx_nfrags)) { CERROR("Failed to map mr %d/%d " "elements\n", n, tx->tx_nfrags); -- 1.8.3.1