From aab1d832130ee5c181cf7e0e5aa555244d150b00 Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Thu, 4 Dec 2014 11:10:44 -0600 Subject: [PATCH 1/1] LU-2675 lnet: remove lnet/include/lnet/linux/ Remove the linux specific headers from lnet/include/lnet/linux/, moving whatever was worthwhile from them to their parent headers or elsewhere. Also remove lnet/klnds/socklnd/socklnd_lib-linux.h and rename lnet/klnds/socklnd/socklnd_lib-linux.c to socklnd_lib.c. Signed-off-by: John L. Hammond Change-Id: Id10683e95277791f9c99492907369a608b28a1fb Reviewed-on: http://review.whamcloud.com/12932 Tested-by: Jenkins Reviewed-by: Isaac Huang Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- lnet/autoconf/lustre-lnet.m4 | 1 - lnet/include/lnet/Makefile.am | 3 - lnet/include/lnet/lib-lnet.h | 2 +- lnet/include/lnet/lib-types.h | 8 +- lnet/include/lnet/linux/.gitignore | 1 - lnet/include/lnet/linux/Makefile.am | 1 - lnet/include/lnet/linux/lib-lnet.h | 80 ------------------- lnet/include/lnet/linux/lib-types.h | 50 ------------ lnet/include/lnet/linux/lnet.h | 66 ---------------- lnet/include/lnet/lnet.h | 1 - lnet/klnds/gnilnd/gnilnd_cb.c | 3 +- lnet/klnds/mxlnd/mxlnd_cb.c | 4 +- lnet/klnds/o2iblnd/o2iblnd.c | 7 +- lnet/klnds/ralnd/ralnd_cb.c | 5 +- lnet/klnds/socklnd/Makefile.in | 7 +- lnet/klnds/socklnd/autoMakefile.am | 10 +-- lnet/klnds/socklnd/socklnd.h | 48 +++++++++++- lnet/klnds/socklnd/socklnd_lib-linux.h | 90 ---------------------- .../socklnd/{socklnd_lib-linux.c => socklnd_lib.c} | 4 +- 19 files changed, 78 insertions(+), 313 deletions(-) delete mode 100644 lnet/include/lnet/linux/.gitignore delete mode 100644 lnet/include/lnet/linux/Makefile.am delete mode 100644 lnet/include/lnet/linux/lib-lnet.h delete mode 100644 lnet/include/lnet/linux/lib-types.h delete mode 100644 lnet/include/lnet/linux/lnet.h delete mode 100644 lnet/klnds/socklnd/socklnd_lib-linux.h rename lnet/klnds/socklnd/{socklnd_lib-linux.c => socklnd_lib.c} (99%) diff --git a/lnet/autoconf/lustre-lnet.m4 b/lnet/autoconf/lustre-lnet.m4 index 9b0924f..ad390bf 100644 --- a/lnet/autoconf/lustre-lnet.m4 +++ b/lnet/autoconf/lustre-lnet.m4 @@ -705,7 +705,6 @@ lnet/autoconf/Makefile lnet/doc/Makefile lnet/include/Makefile lnet/include/lnet/Makefile -lnet/include/lnet/linux/Makefile lnet/klnds/Makefile lnet/klnds/autoMakefile lnet/klnds/mxlnd/autoMakefile diff --git a/lnet/include/lnet/Makefile.am b/lnet/include/lnet/Makefile.am index 1a34a9f..50530b5 100644 --- a/lnet/include/lnet/Makefile.am +++ b/lnet/include/lnet/Makefile.am @@ -1,8 +1,5 @@ lnetdir=$(includedir)/lnet -SUBDIRS = linux -DIST_SUBDIRS = linux - EXTRA_DIST = \ api.h \ lib-dlc.h \ diff --git a/lnet/include/lnet/lib-lnet.h b/lnet/include/lnet/lib-lnet.h index a48a5d3..baee919 100644 --- a/lnet/include/lnet/lib-lnet.h +++ b/lnet/include/lnet/lib-lnet.h @@ -41,7 +41,7 @@ #ifndef __LNET_LIB_LNET_H__ #define __LNET_LIB_LNET_H__ -#include +#define LNET_ROUTER #include #include diff --git a/lnet/include/lnet/lib-types.h b/lnet/include/lnet/lib-types.h index b55d598..6d2bb38 100644 --- a/lnet/include/lnet/lib-types.h +++ b/lnet/include/lnet/lib-types.h @@ -42,7 +42,13 @@ #ifndef __LNET_LIB_TYPES_H__ #define __LNET_LIB_TYPES_H__ -#include +#ifdef __KERNEL__ +# include +# include +#else /* !__KERNEL__ */ +# define LNET_USE_LIB_FREELIST +# include +#endif /* __KERNEL__ */ #include #include diff --git a/lnet/include/lnet/linux/.gitignore b/lnet/include/lnet/linux/.gitignore deleted file mode 100644 index 10a7e8d..0000000 --- a/lnet/include/lnet/linux/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/Makefile.in diff --git a/lnet/include/lnet/linux/Makefile.am b/lnet/include/lnet/linux/Makefile.am deleted file mode 100644 index 7efb58d..0000000 --- a/lnet/include/lnet/linux/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -EXTRA_DIST = lib-lnet.h lib-types.h lnet.h diff --git a/lnet/include/lnet/linux/lib-lnet.h b/lnet/include/lnet/linux/lib-lnet.h deleted file mode 100644 index a7ad1b8..0000000 --- a/lnet/include/lnet/linux/lib-lnet.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - */ - -#ifndef __LNET_LINUX_LIB_LNET_H__ -#define __LNET_LINUX_LIB_LNET_H__ - -#ifndef __LNET_LIB_LNET_H__ -#error Do not #include this file directly. #include instead -#endif - -#ifdef __KERNEL__ -# include -# include -# include -# include - -static inline __u64 -lnet_page2phys (struct page *p) -{ - /* compiler optimizer will elide unused branches */ - - switch (sizeof(typeof(page_to_phys(p)))) { - case 4: - /* page_to_phys returns a 32 bit physical address. This must - * be a 32 bit machine with <= 4G memory and we must ensure we - * don't sign extend when converting to 64 bits. */ - return (unsigned long)page_to_phys(p); - - case 8: - /* page_to_phys returns a 64 bit physical address :) */ - return page_to_phys(p); - - default: - LBUG(); - return 0; - } -} - -#else /* __KERNEL__ */ -# include -# include -# ifdef HAVE_LIBPTHREAD -# include -# endif -#endif - -#define LNET_ROUTER - -#endif /* __LNET_LINUX_LIB_LNET_H__ */ diff --git a/lnet/include/lnet/linux/lib-types.h b/lnet/include/lnet/linux/lib-types.h deleted file mode 100644 index 6e6ed5d..0000000 --- a/lnet/include/lnet/linux/lib-types.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - */ - -#ifndef __LNET_LINUX_LIB_TYPES_H__ -#define __LNET_LINUX_LIB_TYPES_H__ - -#ifndef __LNET_LIB_TYPES_H__ -#error Do not #include this file directly. #include instead -#endif - -#ifdef __KERNEL__ -# include -# include -#else -# define LNET_USE_LIB_FREELIST -# include -#endif - -#endif diff --git a/lnet/include/lnet/linux/lnet.h b/lnet/include/lnet/linux/lnet.h deleted file mode 100644 index d641bce..0000000 --- a/lnet/include/lnet/linux/lnet.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2011, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - */ - -#ifndef __LNET_LINUX_LNET_H__ -#define __LNET_LINUX_LNET_H__ - -#ifndef __LNET_H__ -#error Do not #include this file directly. #include instead -#endif - -/* - * lnet.h - * - * User application interface file - */ - -#if defined (__KERNEL__) -#include -#include - -#ifdef HAVE_TCP_SENDPAGE_USE_SOCKET -#define cfs_tcp_sendpage(sk, page, offset, size, flags) \ - tcp_sendpage((sk)->sk_socket, page, offset, size, flags) -#else -#define cfs_tcp_sendpage(sk, page, offset, size, flags) \ - tcp_sendpage(sk, page, offset, size, flags) -#endif -#else -#include -#include -#endif - -#endif diff --git a/lnet/include/lnet/lnet.h b/lnet/include/lnet/lnet.h index 6b86a22..bc27a2e 100644 --- a/lnet/include/lnet/lnet.h +++ b/lnet/include/lnet/lnet.h @@ -40,7 +40,6 @@ * * User application interface file */ -#include #include #include diff --git a/lnet/klnds/gnilnd/gnilnd_cb.c b/lnet/klnds/gnilnd/gnilnd_cb.c index 7a176e1..705a341 100644 --- a/lnet/klnds/gnilnd/gnilnd_cb.c +++ b/lnet/klnds/gnilnd/gnilnd_cb.c @@ -23,6 +23,7 @@ * */ +#include #include #include "gnilnd.h" @@ -709,7 +710,7 @@ kgnilnd_setup_phys_buffer(kgn_tx_t *tx, int nkiov, lnet_kiov_t *kiov, "nkiov %u offset %u\n", kiov->kiov_page, kiov->kiov_offset, kiov->kiov_len, nob, nkiov, offset); - phys->address = lnet_page2phys(kiov->kiov_page); + phys->address = page_to_phys(kiov->kiov_page); phys++; kiov++; nkiov--; diff --git a/lnet/klnds/mxlnd/mxlnd_cb.c b/lnet/klnds/mxlnd/mxlnd_cb.c index 191af47..9c54d54 100644 --- a/lnet/klnds/mxlnd/mxlnd_cb.c +++ b/lnet/klnds/mxlnd/mxlnd_cb.c @@ -41,6 +41,7 @@ * Author: Scott Atchley */ +#include #include "mxlnd.h" mx_endpoint_addr_t MX_EPA_NULL; /* use to determine if an endpoint is NULL */ @@ -1885,7 +1886,8 @@ mxlnd_setup_kiov(kmx_ctx_t *ctx, u32 niov, lnet_kiov_t *kiov, u32 offset, u32 no ctx->mxc_nseg = niov; sum = 0; for (i = 0; i < niov; i++) { - seg[i].segment_ptr = lnet_page2phys(kiov[first_kiov + i].kiov_page); + seg[i].segment_ptr = + page_to_phys(kiov[first_kiov + i].kiov_page); seg[i].segment_length = kiov[first_kiov + i].kiov_len; if (i == 0) { seg[i].segment_ptr += (u64) first_kiov_offset; diff --git a/lnet/klnds/o2iblnd/o2iblnd.c b/lnet/klnds/o2iblnd/o2iblnd.c index 8734120..135f5ef 100644 --- a/lnet/klnds/o2iblnd/o2iblnd.c +++ b/lnet/klnds/o2iblnd/o2iblnd.c @@ -38,6 +38,7 @@ * Author: Eric Barton */ +#include #include "o2iblnd.h" static lnd_t the_o2iblnd; @@ -1262,9 +1263,9 @@ kiblnd_map_rx_descs(kib_conn_t *conn) rx->rx_msgaddr)); KIBLND_UNMAP_ADDR_SET(rx, rx_msgunmap, rx->rx_msgaddr); - CDEBUG(D_NET,"rx %d: %p "LPX64"("LPX64")\n", - i, rx->rx_msg, rx->rx_msgaddr, - lnet_page2phys(pg) + pg_off); + CDEBUG(D_NET, "rx %d: %p "LPX64"("LPX64")\n", + i, rx->rx_msg, rx->rx_msgaddr, + (__u64)(page_to_phys(pg) + pg_off)); pg_off += IBLND_MSG_SIZE; LASSERT (pg_off <= PAGE_SIZE); diff --git a/lnet/klnds/ralnd/ralnd_cb.c b/lnet/klnds/ralnd/ralnd_cb.c index b9e2bc0..2e6ba70 100644 --- a/lnet/klnds/ralnd/ralnd_cb.c +++ b/lnet/klnds/ralnd/ralnd_cb.c @@ -38,6 +38,7 @@ * Author: Eric Barton */ +#include #include "ralnd.h" void @@ -229,7 +230,7 @@ kranal_setup_phys_buffer (kra_tx_t *tx, int nkiov, lnet_kiov_t *kiov, tx->tx_nob = nob; tx->tx_buffer = (void *)((unsigned long)(kiov->kiov_offset + offset)); - phys->Address = lnet_page2phys(kiov->kiov_page); + phys->Address = page_to_phys(kiov->kiov_page); phys++; resid = nob - (kiov->kiov_len - offset); @@ -254,7 +255,7 @@ kranal_setup_phys_buffer (kra_tx_t *tx, int nkiov, lnet_kiov_t *kiov, return -EMSGSIZE; } - phys->Address = lnet_page2phys(kiov->kiov_page); + phys->Address = page_to_phys(kiov->kiov_page); phys++; resid -= PAGE_SIZE; diff --git a/lnet/klnds/socklnd/Makefile.in b/lnet/klnds/socklnd/Makefile.in index e517d75f..b29f617 100644 --- a/lnet/klnds/socklnd/Makefile.in +++ b/lnet/klnds/socklnd/Makefile.in @@ -1,5 +1,10 @@ MODULES := ksocklnd -ksocklnd-objs := socklnd.o socklnd_cb.o socklnd_proto.o socklnd_modparams.o socklnd_lib-linux.o +ksocklnd-objs := \ + socklnd.o \ + socklnd_cb.o \ + socklnd_lib.o \ + socklnd_modparams.o \ + socklnd_proto.o @INCLUDE_RULES@ diff --git a/lnet/klnds/socklnd/autoMakefile.am b/lnet/klnds/socklnd/autoMakefile.am index 8fac7a6..1141b1c 100644 --- a/lnet/klnds/socklnd/autoMakefile.am +++ b/lnet/klnds/socklnd/autoMakefile.am @@ -1,11 +1,7 @@ if MODULES -if LINUX - - modulenet_DATA := ksocklnd$(KMODEXT) - -endif # LINUX +modulenet_DATA := ksocklnd$(KMODEXT) endif # MODULES -EXTRA_DIST := $(ksocklnd-objs:%.o=%.c) socklnd_lib-linux.h socklnd.h +EXTRA_DIST := $(ksocklnd-objs:%.o=%.c) socklnd.h -MOSTLYCLEANFILES = @MOSTLYCLEANFILES@ socklnd_lib.c +MOSTLYCLEANFILES = @MOSTLYCLEANFILES@ diff --git a/lnet/klnds/socklnd/socklnd.h b/lnet/klnds/socklnd/socklnd.h index a795a96e..052b9ee 100644 --- a/lnet/klnds/socklnd/socklnd.h +++ b/lnet/klnds/socklnd/socklnd.h @@ -25,16 +25,48 @@ * */ +#ifndef _SOCKLND_SOCKLND_H_ +#define _SOCKLND_SOCKLND_H_ + #define DEBUG_PORTAL_ALLOC #define DEBUG_SUBSYSTEM S_LND -#include "socklnd_lib-linux.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include #include +#ifdef HAVE_TCP_SENDPAGE_USE_SOCKET +# define cfs_tcp_sendpage(sk, page, offset, size, flags) \ + tcp_sendpage((sk)->sk_socket, page, offset, size, flags) +#else /* !HAVE_TCP_SENDPAGE_USE_SOCKET */ +# define cfs_tcp_sendpage(sk, page, offset, size, flags) \ + tcp_sendpage(sk, page, offset, size, flags) +#endif /* HAVE_TCP_SENDPAGE_USE_SOCKET */ + +/* assume one thread for each connection type */ +#define SOCKNAL_NSCHEDS 3 +#define SOCKNAL_NSCHEDS_HIGH (SOCKNAL_NSCHEDS << 1) + #define SOCKNAL_PEER_HASH_SIZE 101 /* # peer lists */ #define SOCKNAL_RESCHED 100 /* # scheduler loops before reschedule */ #define SOCKNAL_INSANITY_RECONN 5000 /* connd is trying on reconn infinitely */ @@ -446,6 +478,18 @@ extern ksock_proto_t ksocknal_protocol_v3x; #define CPU_MASK_NONE 0UL #endif +static inline __u32 ksocknal_csum(__u32 crc, unsigned char const *p, size_t len) +{ +#if 1 + return crc32_le(crc, p, len); +#else + while (len-- > 0) + crc = ((crc + 0x100) & ~0xff) | ((crc + *p++) & 0xff) ; + + return crc; +#endif +} + static inline int ksocknal_route_mask(void) { @@ -641,3 +685,5 @@ extern void ksocknal_lib_csum_tx(ksock_tx_t *tx); extern int ksocknal_lib_memory_pressure(ksock_conn_t *conn); extern int ksocknal_lib_bind_thread_to_cpu(int id); + +#endif /* _SOCKLND_SOCKLND_H_ */ diff --git a/lnet/klnds/socklnd/socklnd_lib-linux.h b/lnet/klnds/socklnd/socklnd_lib-linux.h deleted file mode 100644 index 6979809..0000000 --- a/lnet/klnds/socklnd/socklnd_lib-linux.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2012, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - */ - -#define DEBUG_PORTAL_ALLOC - -#ifndef __LINUX_SOCKNAL_LIB_H__ -#define __LINUX_SOCKNAL_LIB_H__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -static inline __u32 ksocknal_csum(__u32 crc, unsigned char const *p, size_t len) -{ -#if 1 - return crc32_le(crc, p, len); -#else - while (len-- > 0) - crc = ((crc + 0x100) & ~0xff) | ((crc + *p++) & 0xff) ; - return crc; -#endif -} - -#define SOCKNAL_WSPACE(sk) sk_stream_wspace(sk) -#define SOCKNAL_MIN_WSPACE(sk) sk_stream_min_wspace(sk) - -/* assume one thread for each connection type */ -#define SOCKNAL_NSCHEDS 3 -#define SOCKNAL_NSCHEDS_HIGH (SOCKNAL_NSCHEDS << 1) - -#endif diff --git a/lnet/klnds/socklnd/socklnd_lib-linux.c b/lnet/klnds/socklnd/socklnd_lib.c similarity index 99% rename from lnet/klnds/socklnd/socklnd_lib-linux.c rename to lnet/klnds/socklnd/socklnd_lib.c index 2815a36..a5f63f0 100644 --- a/lnet/klnds/socklnd/socklnd_lib-linux.c +++ b/lnet/klnds/socklnd/socklnd_lib.c @@ -1000,8 +1000,8 @@ ksocknal_write_space (struct sock *sk) read_lock(&ksocknal_data.ksnd_global_lock); conn = sk->sk_user_data; - wspace = SOCKNAL_WSPACE(sk); - min_wpace = SOCKNAL_MIN_WSPACE(sk); + wspace = sk_stream_wspace(sk); + min_wpace = sk_stream_min_wspace(sk); CDEBUG(D_NET, "sk %p wspace %d low water %d conn %p%s%s%s\n", sk, wspace, min_wpace, conn, -- 1.8.3.1