From: John L. Hammond Date: Thu, 14 Aug 2014 19:17:28 +0000 (-0500) Subject: LU-2675 lnet: add lnet/nidstr.h X-Git-Tag: 2.6.53~73 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=a9ab51fcbd1b4dbe4c23ff774782d598f6f91ffa;p=fs%2Flustre-release.git LU-2675 lnet: add lnet/nidstr.h Add lnet/include/lnet/nidstr.h to break the include loop between libcfs/libcfs.h and lnet/types.h. Where possible include lnet/types.h or lnet/nidstr.h rather than lnet/lnet.h. Remove the unneccessary headers lnet/{,darwin/,linux/}api-support.h. Signed-off-by: John L. Hammond Change-Id: Ide4cd79295eba8705c0d413449cbb812343cbec9 Reviewed-on: http://review.whamcloud.com/11506 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Liang Zhen Reviewed-by: Amir Shehata Reviewed-by: Isaac Huang Reviewed-by: Oleg Drokin --- diff --git a/libcfs/include/libcfs/libcfs_private.h b/libcfs/include/libcfs/libcfs_private.h index 0673b40..6f7953c 100644 --- a/libcfs/include/libcfs/libcfs_private.h +++ b/libcfs/include/libcfs/libcfs_private.h @@ -42,9 +42,6 @@ #ifndef __LIBCFS_PRIVATE_H__ #define __LIBCFS_PRIVATE_H__ -/* XXX this layering violation is for nidstrings */ -#include - #ifndef DEBUG_SUBSYSTEM # define DEBUG_SUBSYSTEM S_UNDEFINED #endif @@ -530,45 +527,6 @@ int cfs_percpt_atomic_summary(atomic_t **refs); */ #define CLASSERT(cond) do {switch (1) {case (cond): case 0: break; } } while (0) -/* support decl needed both by kernel and liblustre */ -int libcfs_isknown_lnd(int type); -char *libcfs_lnd2modname(int type); -char *libcfs_lnd2str(int type); -int libcfs_str2lnd(const char *str); -char *libcfs_net2str(__u32 net); -char *libcfs_nid2str(lnet_nid_t nid); -__u32 libcfs_str2net(const char *str); -lnet_nid_t libcfs_str2nid(const char *str); -int libcfs_str2anynid(lnet_nid_t *nid, const char *str); -char *libcfs_id2str(lnet_process_id_t id); -void cfs_free_nidlist(struct list_head *list); -int cfs_parse_nidlist(char *str, int len, struct list_head *list); -int cfs_print_nidlist(char *buffer, int count, - struct list_head *list); -int cfs_match_nid(lnet_nid_t nid, struct list_head *list); -bool cfs_nidrange_is_contiguous(struct list_head *nidlist); -void cfs_nidrange_find_min_max(struct list_head *nidlist, - char *min_nid, char *max_nid, - int nidstr_length); - -/** \addtogroup lnet_addr - * @{ */ -/* how an LNET NID encodes net:address */ -/** extract the address part of an lnet_nid_t */ -#define LNET_NIDADDR(nid) ((__u32)((nid) & 0xffffffff)) -/** extract the network part of an lnet_nid_t */ -#define LNET_NIDNET(nid) ((__u32)(((nid) >> 32)) & 0xffffffff) -/** make an lnet_nid_t from a network part and an address part */ -#define LNET_MKNID(net,addr) ((((__u64)(net))<<32)|((__u64)(addr))) -/* how net encodes type:number */ -#define LNET_NETNUM(net) ((net) & 0xffff) -#define LNET_NETTYP(net) (((net) >> 16) & 0xffff) -#define LNET_MKNET(typ,num) ((((__u32)(typ))<<16)|((__u32)(num))) -/** @} lnet_addr */ - -/* max value for numeric network address */ -#define MAX_NUMERIC_VALUE 0xffffffff - /* implication */ #define ergo(a, b) (!(a) || (b)) /* logical equivalence */ diff --git a/libcfs/include/libcfs/lucache.h b/libcfs/include/libcfs/lucache.h index 4a5cbeb..990ed79 100644 --- a/libcfs/include/libcfs/lucache.h +++ b/libcfs/include/libcfs/lucache.h @@ -38,6 +38,7 @@ #define _LUCACHE_H #include +#include /** \defgroup ucache ucache * diff --git a/libcfs/libcfs/linux/linux-utils.c b/libcfs/libcfs/linux/linux-utils.c index c76046d..c9ca655 100644 --- a/libcfs/libcfs/linux/linux-utils.c +++ b/libcfs/libcfs/linux/linux-utils.c @@ -41,7 +41,6 @@ */ #define DEBUG_SUBSYSTEM S_LNET #include -#include /* * Convert server error code to client format. Error codes are from diff --git a/libcfs/libcfs/module.c b/libcfs/libcfs/module.c index 16d0a16..7621023 100644 --- a/libcfs/libcfs/module.c +++ b/libcfs/libcfs/module.c @@ -43,6 +43,7 @@ #include #include #include +#include #include "tracefile.h" void diff --git a/libcfs/libcfs/nidstrings.c b/libcfs/libcfs/nidstrings.c index d5830f3..10e8f8d 100644 --- a/libcfs/libcfs/nidstrings.c +++ b/libcfs/libcfs/nidstrings.c @@ -41,13 +41,16 @@ #define DEBUG_SUBSYSTEM S_LNET #include -#include +#include #ifndef __KERNEL__ #ifdef HAVE_GETHOSTBYNAME # include #endif #endif +/* max value for numeric network address */ +#define MAX_NUMERIC_VALUE 0xffffffff + #define IPSTRING_LENGTH 16 /* CAVEAT VENDITOR! Keep the canonical string representation of nets/nids diff --git a/libcfs/libcfs/upcall_cache.c b/libcfs/libcfs/upcall_cache.c index 34bc7df..c794eb6 100644 --- a/libcfs/libcfs/upcall_cache.c +++ b/libcfs/libcfs/upcall_cache.c @@ -40,6 +40,7 @@ #define DEBUG_SUBSYSTEM S_SEC #include +#include static struct upcall_cache_entry *alloc_entry(struct upcall_cache *cache, __u64 key, void *args) diff --git a/libcfs/libcfs/util/l_ioctl.c b/libcfs/libcfs/util/l_ioctl.c index 9dcf1db..e27c404 100644 --- a/libcfs/libcfs/util/l_ioctl.c +++ b/libcfs/libcfs/util/l_ioctl.c @@ -21,7 +21,6 @@ #define __USE_FILE_OFFSET64 #include -#include #include static ioc_handler_t do_ioctl; /* forward ref */ diff --git a/lnet/include/lnet/Makefile.am b/lnet/include/lnet/Makefile.am index e40e743..1a34a9f 100644 --- a/lnet/include/lnet/Makefile.am +++ b/lnet/include/lnet/Makefile.am @@ -3,6 +3,14 @@ lnetdir=$(includedir)/lnet SUBDIRS = linux DIST_SUBDIRS = linux -EXTRA_DIST = api.h api-support.h \ - lib-dlc.h lib-lnet.h lib-types.h lnet.h lnetctl.h types.h \ - socklnd.h lnetst.h +EXTRA_DIST = \ + api.h \ + lib-dlc.h \ + lib-lnet.h \ + lib-types.h \ + lnet.h \ + lnetctl.h \ + lnetst.h \ + nidstr.h \ + socklnd.h \ + types.h diff --git a/lnet/include/lnet/api-support.h b/lnet/include/lnet/api-support.h deleted file mode 100644 index bdd4ff0..0000000 --- a/lnet/include/lnet/api-support.h +++ /dev/null @@ -1,44 +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) 2003, 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_API_SUPPORT_H__ -#define __LNET_API_SUPPORT_H__ - -#include - -#include -#include -#include - -#endif diff --git a/lnet/include/lnet/linux/Makefile.am b/lnet/include/lnet/linux/Makefile.am index 29df720..7efb58d 100644 --- a/lnet/include/lnet/linux/Makefile.am +++ b/lnet/include/lnet/linux/Makefile.am @@ -1 +1 @@ -EXTRA_DIST = lib-lnet.h lib-types.h lnet.h api-support.h +EXTRA_DIST = lib-lnet.h lib-types.h lnet.h diff --git a/lnet/include/lnet/linux/api-support.h b/lnet/include/lnet/linux/api-support.h deleted file mode 100644 index e5b71e9..0000000 --- a/lnet/include/lnet/linux/api-support.h +++ /dev/null @@ -1,73 +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) 2007, 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 __LINUX_API_SUPPORT_H__ -#define __LINUX_API_SUPPORT_H__ - -#ifndef __LNET_API_SUPPORT_H__ -#error Do not #include this file directly. #include instead -#endif - -#ifndef __KERNEL__ -# include -# include -# include -# include - -/* Lots of POSIX dependencies to support PtlEQWait_timeout */ -# include -# include -# include - -#ifdef HAVE_LIBREADLINE -#define READLINE_LIBRARY -#include - -/* readline.h pulls in a #define that conflicts with one in libcfs.h */ -#undef RETURN - -/* completion_matches() is #if 0-ed out in modern glibc */ -#ifndef completion_matches -# define completion_matches rl_completion_matches -#endif - -#endif /* HAVE_LIBREADLINE */ - -extern void using_history(void); -extern void stifle_history(int); -extern void add_history(char *); - -#endif /* !__KERNEL__ */ - -#endif diff --git a/lnet/include/lnet/lnet.h b/lnet/include/lnet/lnet.h index 85eb9d6..6b86a22 100644 --- a/lnet/include/lnet/lnet.h +++ b/lnet/include/lnet/lnet.h @@ -44,8 +44,6 @@ #include #include - -#define LNET_NIDSTR_COUNT 1024 /* # of nidstrings */ -#define LNET_NIDSTR_SIZE 32 /* size of each one (see below for usage) */ +#include #endif diff --git a/lnet/include/lnet/lnetst.h b/lnet/include/lnet/lnetst.h index 4d53849..803cfef 100644 --- a/lnet/include/lnet/lnetst.h +++ b/lnet/include/lnet/lnetst.h @@ -42,7 +42,6 @@ #define __LNET_ST_H__ #include -#include #include #define LST_FEAT_NONE (0) diff --git a/lnet/include/lnet/nidstr.h b/lnet/include/lnet/nidstr.h new file mode 100644 index 0000000..d2ab743 --- /dev/null +++ b/lnet/include/lnet/nidstr.h @@ -0,0 +1,29 @@ +#ifndef _LNET_NIDSTRINGS_H +#define _LNET_NIDSTRINGS_H +#include + +struct list_head; + +#define LNET_NIDSTR_COUNT 1024 /* # of nidstrings */ +#define LNET_NIDSTR_SIZE 32 /* size of each one (see below for usage) */ + +/* support decl needed both by kernel and liblustre */ +int libcfs_isknown_lnd(int type); +char *libcfs_lnd2modname(int type); +char *libcfs_lnd2str(int type); +int libcfs_str2lnd(const char *str); +char *libcfs_net2str(__u32 net); +char *libcfs_nid2str(lnet_nid_t nid); +__u32 libcfs_str2net(const char *str); +lnet_nid_t libcfs_str2nid(const char *str); +int libcfs_str2anynid(lnet_nid_t *nid, const char *str); +char *libcfs_id2str(lnet_process_id_t id); +void cfs_free_nidlist(struct list_head *list); +int cfs_parse_nidlist(char *str, int len, struct list_head *list); +int cfs_print_nidlist(char *buffer, int count, struct list_head *list); +int cfs_match_nid(lnet_nid_t nid, struct list_head *list); +bool cfs_nidrange_is_contiguous(struct list_head *nidlist); +void cfs_nidrange_find_min_max(struct list_head *nidlist, char *min_nid, + char *max_nid, int nidstr_length); + +#endif /* _LNET_NIDSTRINGS_H */ diff --git a/lnet/include/lnet/types.h b/lnet/include/lnet/types.h index 2982801..997fbc1 100644 --- a/lnet/include/lnet/types.h +++ b/lnet/include/lnet/types.h @@ -40,7 +40,7 @@ /** \addtogroup lnet * @{ */ -#include +#include /** \addtogroup lnet_addr * @{ */ @@ -77,6 +77,39 @@ typedef __u32 lnet_pid_t; #define LNET_TIME_FOREVER (-1) +/* how an LNET NID encodes net:address */ +/** extract the address part of an lnet_nid_t */ + +static inline __u32 LNET_NIDADDR(lnet_nid_t nid) +{ + return nid & 0xffffffff; +} + +static inline __u32 LNET_NIDNET(lnet_nid_t nid) +{ + return (nid >> 32) & 0xffffffff; +} + +static inline lnet_nid_t LNET_MKNID(__u32 net, __u32 addr) +{ + return (((__u64)net) << 32) | addr; +} + +static inline __u32 LNET_NETNUM(__u32 net) +{ + return net & 0xffff; +} + +static inline __u32 LNET_NETTYP(__u32 net) +{ + return (net >> 16) & 0xffff; +} + +static inline __u32 LNET_MKNET(__u32 type, __u32 num) +{ + return (type << 16) | num; +} + /** * Objects maintained by the LNet are accessed through handles. Handle types * have names of the form lnet_handle_xx_t, where xx is one of the two letter diff --git a/lnet/utils/Makefile.am b/lnet/utils/Makefile.am index dd7b9e4..8ff8cca 100644 --- a/lnet/utils/Makefile.am +++ b/lnet/utils/Makefile.am @@ -38,6 +38,8 @@ #COMPILE = $(CC) -Wall -g -I$(srcdir)/../include -I../../include #LINK = $(CC) -o $@ +AM_CFLAGS = $(LLCFLAGS) + LIBCFS= $(top_builddir)/libcfs/libcfs/libcfs.a LIBCFSUTIL= $(top_builddir)/libcfs/libcfs/libcfsutil.a diff --git a/lnet/utils/debug.c b/lnet/utils/debug.c index e1dd37b..40de598 100644 --- a/lnet/utils/debug.c +++ b/lnet/utils/debug.c @@ -728,10 +728,12 @@ int jt_dbg_clear_debug_buf(int argc, char **argv) int jt_dbg_mark_debug_buf(int argc, char **argv) { static char scratch[MAX_MARK_SIZE] = ""; - struct libcfs_ioctl_data data = { 0 }; + struct libcfs_ioctl_data data; char *text; int rc; + memset(&data, 0, sizeof(data)); + if (argc > 1) { int count, max_size = sizeof(scratch) - 1; diff --git a/lnet/utils/lst.c b/lnet/utils/lst.c index 64d1f3f..044cbcd 100644 --- a/lnet/utils/lst.c +++ b/lnet/utils/lst.c @@ -38,11 +38,10 @@ * Author: Liang Zhen */ -#define _GNU_SOURCE - #include #include #include +#include /* NB: these includes are layering violation */ #include #include diff --git a/lnet/utils/portals.c b/lnet/utils/portals.c index 42d2f67..fcfb91b 100644 --- a/lnet/utils/portals.c +++ b/lnet/utils/portals.c @@ -19,7 +19,7 @@ */ #include -#include +#include #include #include #include diff --git a/lnet/utils/wirecheck.c b/lnet/utils/wirecheck.c index 95d2aa6..8273a84 100644 --- a/lnet/utils/wirecheck.c +++ b/lnet/utils/wirecheck.c @@ -37,9 +37,12 @@ #endif #include +#include +#include +#include #include #include -#include +#include #include diff --git a/lustre/include/lustre/lustre_idl.h b/lustre/include/lustre/lustre_idl.h index 016e665..6a311e4 100644 --- a/lustre/include/lustre/lustre_idl.h +++ b/lustre/include/lustre/lustre_idl.h @@ -92,6 +92,7 @@ #define _LUSTRE_IDL_H_ #include /* for LPUX64, etc */ +#include #include /* Defn's shared with user-space. */ #include #include diff --git a/lustre/mdt/mdt_lib.c b/lustre/mdt/mdt_lib.c index 30fcaf0..2a8e2fd 100644 --- a/lustre/mdt/mdt_lib.c +++ b/lustre/mdt/mdt_lib.c @@ -49,8 +49,7 @@ #define DEBUG_SUBSYSTEM S_MDS #include "mdt_internal.h" -#include - +#include typedef enum ucred_init_type { NONE_INIT = 0, diff --git a/lustre/mdt/mdt_lproc.c b/lustre/mdt/mdt_lproc.c index 7a5936c..f8d0c0a 100644 --- a/lustre/mdt/mdt_lproc.c +++ b/lustre/mdt/mdt_lproc.c @@ -45,7 +45,7 @@ #include #include - +#include /* LUSTRE_VERSION_CODE */ #include /* @@ -61,7 +61,6 @@ #include #include #include "mdt_internal.h" -#include /** * The rename stats output would be YAML formats, like diff --git a/lustre/nodemap/nodemap_handler.c b/lustre/nodemap/nodemap_handler.c index 1f68532..6c04f65 100644 --- a/lustre/nodemap/nodemap_handler.c +++ b/lustre/nodemap/nodemap_handler.c @@ -24,6 +24,7 @@ * Author: Joshua Walgenbach */ #include +#include #include #include "nodemap_internal.h" diff --git a/lustre/utils/gss/l_idmap.c b/lustre/utils/gss/l_idmap.c index 663520b..cde42b4 100644 --- a/lustre/utils/gss/l_idmap.c +++ b/lustre/utils/gss/l_idmap.c @@ -3,7 +3,7 @@ #include /* For basename() */ #include - +#include #include "lsupport.h" int main(int argc, char **argv) diff --git a/lustre/utils/gss/lsupport.c b/lustre/utils/gss/lsupport.c index 2fa31de..4dc6a68 100644 --- a/lustre/utils/gss/lsupport.c +++ b/lustre/utils/gss/lsupport.c @@ -60,7 +60,7 @@ #ifdef HAVE_GETHOSTBYNAME # include #endif - +#include #ifdef _NEW_BUILD_ # include "lgss_utils.h" #else diff --git a/lustre/utils/gss/lsupport.h b/lustre/utils/gss/lsupport.h index 576cefa..11005e3 100644 --- a/lustre/utils/gss/lsupport.h +++ b/lustre/utils/gss/lsupport.h @@ -40,6 +40,7 @@ #include #include +#include #define GSSD_CLI (0) #define GSSD_SVC (1) diff --git a/lustre/utils/l_getidentity.c b/lustre/utils/l_getidentity.c index 307cf3f..c4e07cd 100644 --- a/lustre/utils/l_getidentity.c +++ b/lustre/utils/l_getidentity.c @@ -49,6 +49,7 @@ #include #include +#include #include #include diff --git a/lustre/utils/llog_reader.c b/lustre/utils/llog_reader.c index 2a1903b..a0d0b3a 100644 --- a/lustre/utils/llog_reader.c +++ b/lustre/utils/llog_reader.c @@ -44,6 +44,7 @@ #include #include +#include #include #include diff --git a/lustre/utils/loadgen.c b/lustre/utils/loadgen.c index fbc145e..494c5ed 100644 --- a/lustre/utils/loadgen.c +++ b/lustre/utils/loadgen.c @@ -58,6 +58,7 @@ #include #include +#include #include #include #include "obdctl.h" diff --git a/lustre/utils/lustre_cfg.c b/lustre/utils/lustre_cfg.c index 29b3ae1..7a6790b 100644 --- a/lustre/utils/lustre_cfg.c +++ b/lustre/utils/lustre_cfg.c @@ -50,6 +50,7 @@ #include #include +#include #include #include #include diff --git a/lustre/utils/mkfs_lustre.c b/lustre/utils/mkfs_lustre.c index 5310276..e585e8d 100644 --- a/lustre/utils/mkfs_lustre.c +++ b/lustre/utils/mkfs_lustre.c @@ -64,7 +64,7 @@ #include #include #include - +#include #include #include #include diff --git a/lustre/utils/mount_lustre.c b/lustre/utils/mount_lustre.c index 64da5e5..8e9b00a 100644 --- a/lustre/utils/mount_lustre.c +++ b/lustre/utils/mount_lustre.c @@ -53,6 +53,7 @@ #include #include #include +#include #include #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 10, 53, 0) /* diff --git a/lustre/utils/obd.c b/lustre/utils/obd.c index 235e785..76fba40 100644 --- a/lustre/utils/obd.c +++ b/lustre/utils/obd.c @@ -64,7 +64,7 @@ #include "obdctl.h" #include -#include +#include #include #include #include