From 8ba026e938688af32d10f598c3af3ab711695789 Mon Sep 17 00:00:00 2001 From: Rahul Deshmukh Date: Mon, 7 Jun 2010 12:01:55 +0530 Subject: [PATCH] b=21951 2.6.32-fc13 patchless client support for HEAD i=zhen.liang Sebastien's patch to use sg_init_table for fc13 patchless client (2.6.32 kernel) --- libcfs/autoconf/lustre-libcfs.m4 | 17 +++++++++++++++++ libcfs/include/libcfs/linux/portals_compat25.h | 4 ++++ lnet/klnds/o2iblnd/o2iblnd_cb.c | 25 ++++++++++++++++++++++++- 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/libcfs/autoconf/lustre-libcfs.m4 b/libcfs/autoconf/lustre-libcfs.m4 index d6adcfe..49c5a21 100644 --- a/libcfs/autoconf/lustre-libcfs.m4 +++ b/libcfs/autoconf/lustre-libcfs.m4 @@ -452,6 +452,22 @@ LB_LINUX_TRY_COMPILE([ ]) ]) +# from 2.6.24 please use sg_init_table +AC_DEFUN([LIBCFS_SCATTERLIST_INITTABLE], +[AC_MSG_CHECKING([if sg_init_table is defined]) +LB_LINUX_TRY_COMPILE([ + #include +],[ + sg_init_table(NULL,0); +],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_SCATTERLIST_INITTABLE, 1, + [sg_init_table is defined]) +],[ + AC_MSG_RESULT(NO) +]) +]) + # 2.6.24 AC_DEFUN([LIBCFS_NETWORK_NAMESPACE], [AC_MSG_CHECKING([for network stack has namespaces]) @@ -693,6 +709,7 @@ LIBCFS_NETLINK_CBMUTEX # 2.6.24 LIBCFS_SYSCTL_UNNUMBERED LIBCFS_SCATTERLIST_SETPAGE +LIBCFS_SCATTERLIST_INITTABLE LIBCFS_NL_BROADCAST_GFP LIBCFS_NETWORK_NAMESPACE LIBCFS_NETLINK_NETNS diff --git a/libcfs/include/libcfs/linux/portals_compat25.h b/libcfs/include/libcfs/linux/portals_compat25.h index da9eecb..7a87224 100644 --- a/libcfs/include/libcfs/linux/portals_compat25.h +++ b/libcfs/include/libcfs/linux/portals_compat25.h @@ -179,4 +179,8 @@ int proc_call_handler(void *data, int write, int (*handler)(void *data, int write, loff_t pos, void *buffer, int len)); +#ifndef HAVE_SCATTERLIST_INITTABLE +#define sg_init_table(sgl, n) memset(sgl, 0, sizeof(*sgl) * n) +#endif + #endif /* _PORTALS_COMPAT_H */ diff --git a/lnet/klnds/o2iblnd/o2iblnd_cb.c b/lnet/klnds/o2iblnd/o2iblnd_cb.c index afbb352..957fe31 100644 --- a/lnet/klnds/o2iblnd/o2iblnd_cb.c +++ b/lnet/klnds/o2iblnd/o2iblnd_cb.c @@ -713,6 +713,28 @@ kiblnd_setup_rd_iov(lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd, return kiblnd_map_tx(ni, tx, rd, sg - tx->tx_frags); } +static inline int +get_kiov_length (int nkiov, lnet_kiov_t *kiov, int offset, int nob) +{ + int fragnob; + int count = 0; + + do { + LASSERT (nkiov > 0); + + fragnob = min((int)(kiov->kiov_len - offset), nob); + + count++; + + offset = 0; + kiov++; + nkiov--; + nob -= fragnob; + } while (nob > 0); + + return count; +} + int kiblnd_setup_rd_kiov (lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd, int nkiov, lnet_kiov_t *kiov, int offset, int nob) @@ -735,12 +757,13 @@ kiblnd_setup_rd_kiov (lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd, } sg = tx->tx_frags; + tx->tx_nfrags = get_kiov_length(nkiov, kiov, offset, nob); + sg_init_table(sg, tx->tx_nfrags); do { LASSERT (nkiov > 0); fragnob = min((int)(kiov->kiov_len - offset), nob); - memset(sg, 0, sizeof(*sg)); sg_set_page(sg, kiov->kiov_page, fragnob, kiov->kiov_offset + offset); sg++; -- 1.8.3.1