From: Li Dongyang Date: Mon, 20 Jun 2016 02:46:30 +0000 (-0400) Subject: LU-8056 o2iblnd: ib_query_device removed in 4.5 X-Git-Tag: 2.8.56~97 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=31d6445718b896290198f5d127f86c174d499c6c LU-8056 o2iblnd: ib_query_device removed in 4.5 We should use the cached attributes in ib_device instead of calling ib_query_device since kernel 4.5 Linux-commit:182a2da0c768a9ec64abb0d6009667057f1c06af Linux-commit:cebfe5ca038e2a0f677b41e9682501708ffa2ff3 Signed-off-by: Li Dongyang Change-Id: Ie2ab681a3b508f0a1f89d3ff86bf2713b7257e62 Reviewed-on: http://review.whamcloud.com/20221 Tested-by: Jenkins Reviewed-by: Doug Oucharek Reviewed-by: James Simmons Tested-by: Maloo Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin --- diff --git a/lnet/autoconf/lustre-lnet.m4 b/lnet/autoconf/lustre-lnet.m4 index bfe4f10..bef6231 100644 --- a/lnet/autoconf/lustre-lnet.m4 +++ b/lnet/autoconf/lustre-lnet.m4 @@ -470,6 +470,28 @@ AS_IF([test $ENABLEO2IB != "no"], [ AC_DEFINE(HAVE_IB_MAP_MR_SG, 1, [ib_map_mr_sg exists]) ]) + + # ib_query_device() removed in 4.5 + LB_CHECK_COMPILE([if 'struct ib_device' has member 'attrs'], + ib_device.attrs, [ + #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 + ],[ + struct ib_device dev; + struct ib_device_attr dev_attr = {}; + dev.attrs = dev_attr; + ],[ + AC_DEFINE(HAVE_IB_DEVICE_ATTRS, 1, + [struct ib_device.attrs is defined]) + ]) EXTRA_CHECK_INCLUDE="" ]) # ENABLEO2IB != "no" ]) # LN_CONFIG_O2IB diff --git a/lnet/klnds/o2iblnd/o2iblnd.c b/lnet/klnds/o2iblnd/o2iblnd.c index d8e870b..6764421 100644 --- a/lnet/klnds/o2iblnd/o2iblnd.c +++ b/lnet/klnds/o2iblnd/o2iblnd.c @@ -1579,9 +1579,11 @@ kiblnd_create_fmr_pool(kib_fmr_poolset_t *fps, kib_fmr_pool_t **pp_fpo) kib_fmr_pool_t *fpo; int rc; +#ifndef HAVE_IB_DEVICE_ATTRS dev_attr = kmalloc(sizeof(*dev_attr), GFP_KERNEL); if (!dev_attr) return -ENOMEM; +#endif LIBCFS_CPT_ALLOC(fpo, lnet_cpt_table(), fps->fps_cpt, sizeof(*fpo)); if (!fpo) { @@ -1591,12 +1593,16 @@ kiblnd_create_fmr_pool(kib_fmr_poolset_t *fps, kib_fmr_pool_t **pp_fpo) fpo->fpo_hdev = kiblnd_current_hdev(dev); +#ifdef HAVE_IB_DEVICE_ATTRS + dev_attr = &fpo->fpo_hdev->ibh_ibdev->attrs; +#else rc = ib_query_device(fpo->fpo_hdev->ibh_ibdev, dev_attr); if (rc) { CERROR("Query device failed for %s: %d\n", fpo->fpo_hdev->ibh_ibdev->name, rc); goto out_dev_attr; } +#endif /* Check for FMR or FastReg support */ fpo->fpo_is_fmr = 0; @@ -1621,7 +1627,9 @@ kiblnd_create_fmr_pool(kib_fmr_poolset_t *fps, kib_fmr_pool_t **pp_fpo) if (rc) goto out_fpo; +#ifndef HAVE_IB_DEVICE_ATTRS kfree(dev_attr); +#endif fpo->fpo_deadline = cfs_time_shift(IBLND_POOL_DEADLINE); fpo->fpo_owner = fps; *pp_fpo = fpo; @@ -1633,7 +1641,9 @@ out_fpo: LIBCFS_FREE(fpo, sizeof(*fpo)); out_dev_attr: +#ifndef HAVE_IB_DEVICE_ATTRS kfree(dev_attr); +#endif return rc; } @@ -2463,8 +2473,10 @@ kiblnd_net_init_pools(kib_net_t *net, lnet_ni_t *ni, __u32 *cpts, int ncpts) static int kiblnd_hdev_get_attr(kib_hca_dev_t *hdev) { - struct ib_device_attr *attr; - int rc; +#ifndef HAVE_IB_DEVICE_ATTRS + struct ib_device_attr *attr; + int rc; +#endif /* It's safe to assume a HCA can handle a page size * matching that of the native system */ @@ -2472,6 +2484,9 @@ kiblnd_hdev_get_attr(kib_hca_dev_t *hdev) hdev->ibh_page_size = 1 << PAGE_SHIFT; hdev->ibh_page_mask = ~((__u64)hdev->ibh_page_size - 1); +#ifdef HAVE_IB_DEVICE_ATTRS + hdev->ibh_mr_size = hdev->ibh_ibdev->attrs.max_mr_size; +#else LIBCFS_ALLOC(attr, sizeof(*attr)); if (attr == NULL) { CERROR("Out of memory\n"); @@ -2488,6 +2503,7 @@ kiblnd_hdev_get_attr(kib_hca_dev_t *hdev) CERROR("Failed to query IB device: %d\n", rc); return rc; } +#endif if (hdev->ibh_mr_size == ~0ULL) { hdev->ibh_mr_shift = 64;