From 91ef75669c7e41091378a8401ca0c093b7f17174 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Wed, 17 Aug 2016 13:48:09 -0400 Subject: [PATCH] LU-6245 libcfs: cleanup list handling For the kernel space side we should use list.h directly expect in the case of kernel API changes that impact us then we use linux-list.h that handles those API changes. A few of the user land utilities use a list implementation so we provide a separate list implementation for the libcfs library. Signed-off-by: James Simmons Change-Id: I1280d74a629dbaa9c11a3c506fd635fab99ce182 Reviewed-on: http://review.whamcloud.com/15200 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Dmitry Eremin Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin --- libcfs/include/libcfs/Makefile.am | 1 - libcfs/include/libcfs/libcfs.h | 2 -- libcfs/include/libcfs/linux/Makefile.am | 2 +- libcfs/include/libcfs/linux/linux-list.h | 52 ++++++++++++++++++++++++++++++++ libcfs/include/libcfs/util/Makefile.am | 2 +- libcfs/include/libcfs/{ => util}/list.h | 36 ++-------------------- libcfs/include/libcfs/util/string.h | 2 +- libcfs/libcfs/hash.c | 1 + lnet/utils/cyaml/cyaml.c | 2 +- lnet/utils/lst.c | 2 +- lustre/include/lu_ref.h | 2 +- lustre/include/lustre_disk.h | 5 +++ lustre/ldlm/ldlm_flock.c | 2 +- lustre/ldlm/ldlm_lockd.c | 2 +- lustre/lfsck/lfsck_lib.c | 2 +- lustre/obdclass/cl_io.c | 2 +- lustre/obdclass/cl_lock.c | 2 +- lustre/obdclass/cl_object.c | 2 +- lustre/obdclass/cl_page.c | 2 +- lustre/obdclass/class_obd.c | 2 +- lustre/obdclass/dt_object.c | 2 +- lustre/obdclass/lu_object.c | 4 +-- lustre/ptlrpc/gss/gss_keyring.c | 1 + lustre/ptlrpc/gss/gss_pipefs.c | 1 + lustre/ptlrpc/llog_client.c | 2 +- lustre/ptlrpc/recover.c | 2 +- lustre/tests/it_test.c | 1 + lustre/utils/mount_utils.h | 1 + lustre/utils/obd.c | 1 + 29 files changed, 85 insertions(+), 55 deletions(-) create mode 100644 libcfs/include/libcfs/linux/linux-list.h rename libcfs/include/libcfs/{ => util}/list.h (91%) diff --git a/libcfs/include/libcfs/Makefile.am b/libcfs/include/libcfs/Makefile.am index 80deadab..6c5a811 100644 --- a/libcfs/include/libcfs/Makefile.am +++ b/libcfs/include/libcfs/Makefile.am @@ -24,5 +24,4 @@ EXTRA_DIST = \ libcfs_string.h \ libcfs_time.h \ libcfs_workitem.h \ - list.h \ types.h diff --git a/libcfs/include/libcfs/libcfs.h b/libcfs/include/libcfs/libcfs.h index fa6b84f..e8bee85 100644 --- a/libcfs/include/libcfs/libcfs.h +++ b/libcfs/include/libcfs/libcfs.h @@ -37,8 +37,6 @@ #ifndef __LIBCFS_LIBCFS_H__ #define __LIBCFS_LIBCFS_H__ -#include - #ifdef __KERNEL__ # include # include diff --git a/libcfs/include/libcfs/linux/Makefile.am b/libcfs/include/libcfs/linux/Makefile.am index f19c8c5..67a647c 100644 --- a/libcfs/include/libcfs/linux/Makefile.am +++ b/libcfs/include/libcfs/linux/Makefile.am @@ -1,2 +1,2 @@ EXTRA_DIST = libcfs.h linux-misc.h linux-fs.h linux-mem.h linux-time.h linux-cpu.h \ - linux-crypto.h + linux-list.h linux-crypto.h diff --git a/libcfs/include/libcfs/linux/linux-list.h b/libcfs/include/libcfs/linux/linux-list.h new file mode 100644 index 0000000..e4a8e8d --- /dev/null +++ b/libcfs/include/libcfs/linux/linux-list.h @@ -0,0 +1,52 @@ +/* + * 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 COPYING file that accompanied this code. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * GPL HEADER END + */ + +#ifndef __LIBCFS_LINUX_LIST_H__ +#define __LIBCFS_LINUX_LIST_H__ + +#include + +#ifdef HAVE_HLIST_FOR_EACH_3ARG +#define cfs_hlist_for_each_entry(tpos, pos, head, member) \ + hlist_for_each_entry(tpos, head, member) +#define cfs_hlist_for_each_entry_safe(tpos, pos, n, head, member) \ + hlist_for_each_entry_safe(tpos, n, head, member) +#define cfs_hlist_for_each_entry_continue(tpos, pos, member) \ + hlist_for_each_entry_continue(tpos, member) +#define cfs_hlist_for_each_entry_from(tpos, pos, member) \ + hlist_for_each_entry_from(tpos, member) +#else +#define cfs_hlist_for_each_entry(tpos, pos, head, member) \ + hlist_for_each_entry(tpos, pos, head, member) +#define cfs_hlist_for_each_entry_safe(tpos, pos, n, head, member) \ + hlist_for_each_entry_safe(tpos, pos, n, head, member) +#define cfs_hlist_for_each_entry_continue(tpos, pos, member) \ + hlist_for_each_entry_continue(tpos, pos, member) +#define cfs_hlist_for_each_entry_from(tpos, pos, member) \ + hlist_for_each_entry_from(tpos, pos, member) +#endif + +#ifdef HAVE_HLIST_ADD_AFTER +#define hlist_add_behind(hnode, tail) hlist_add_after(tail, hnode) +#endif /* HAVE_HLIST_ADD_AFTER */ + +#endif /* __LIBCFS_LINUX_LIST_H__ */ diff --git a/libcfs/include/libcfs/util/Makefile.am b/libcfs/include/libcfs/util/Makefile.am index 8dc52ce..7d332a8 100644 --- a/libcfs/include/libcfs/util/Makefile.am +++ b/libcfs/include/libcfs/util/Makefile.am @@ -1 +1 @@ -EXTRA_DIST = ioctl.h parser.h param.h string.h +EXTRA_DIST = ioctl.h parser.h param.h list.h string.h diff --git a/libcfs/include/libcfs/list.h b/libcfs/include/libcfs/util/list.h similarity index 91% rename from libcfs/include/libcfs/list.h rename to libcfs/include/libcfs/util/list.h index 353b656..2372f5b 100644 --- a/libcfs/include/libcfs/list.h +++ b/libcfs/include/libcfs/util/list.h @@ -20,12 +20,8 @@ * GPL HEADER END */ -#ifndef __LIBCFS_LIST_H__ -#define __LIBCFS_LIST_H__ - -#ifdef __KERNEL__ -# include -#else /* __KERNEL__ */ +#ifndef __LIBCFS_UTIL_LIST_H__ +#define __LIBCFS_UTIL_LIST_H__ /* * Simple doubly linked list implementation. @@ -487,30 +483,4 @@ static inline void hlist_add_after(struct hlist_node *n, &pos->member != (head); \ pos = n, n = list_entry(n->member.next, typeof(*n), member)) -#endif /* __KERNEL__ */ - -#ifdef HAVE_HLIST_FOR_EACH_3ARG -#define cfs_hlist_for_each_entry(tpos, pos, head, member) \ - hlist_for_each_entry(tpos, head, member) -#define cfs_hlist_for_each_entry_safe(tpos, pos, n, head, member) \ - hlist_for_each_entry_safe(tpos, n, head, member) -#define cfs_hlist_for_each_entry_continue(tpos, pos, member) \ - hlist_for_each_entry_continue(tpos, member) -#define cfs_hlist_for_each_entry_from(tpos, pos, member) \ - hlist_for_each_entry_from(tpos, member) -#else -#define cfs_hlist_for_each_entry(tpos, pos, head, member) \ - hlist_for_each_entry(tpos, pos, head, member) -#define cfs_hlist_for_each_entry_safe(tpos, pos, n, head, member) \ - hlist_for_each_entry_safe(tpos, pos, n, head, member) -#define cfs_hlist_for_each_entry_continue(tpos, pos, member) \ - hlist_for_each_entry_continue(tpos, pos, member) -#define cfs_hlist_for_each_entry_from(tpos, pos, member) \ - hlist_for_each_entry_from(tpos, pos, member) -#endif - -#ifdef HAVE_HLIST_ADD_AFTER -#define hlist_add_behind(hnode, tail) hlist_add_after(tail, hnode) -#endif /* HAVE_HLIST_ADD_AFTER */ - -#endif /* __LIBCFS_LUSTRE_LIST_H__ */ +#endif /* __LIBCFS_UTIL_LIST_H__ */ diff --git a/libcfs/include/libcfs/util/string.h b/libcfs/include/libcfs/util/string.h index 450c48c..fd34f84 100644 --- a/libcfs/include/libcfs/util/string.h +++ b/libcfs/include/libcfs/util/string.h @@ -46,7 +46,7 @@ #include #include -#include +#include #ifndef HAVE_STRLCPY /* not in glibc for RHEL 5.x, remove when obsolete */ size_t strlcpy(char *tgt, const char *src, size_t tgt_len); diff --git a/libcfs/libcfs/hash.c b/libcfs/libcfs/hash.c index 5027359..27e42f7 100644 --- a/libcfs/libcfs/hash.c +++ b/libcfs/libcfs/hash.c @@ -108,6 +108,7 @@ */ #include +#include #include #if CFS_HASH_DEBUG_LEVEL >= CFS_HASH_DEBUG_1 diff --git a/lnet/utils/cyaml/cyaml.c b/lnet/utils/cyaml/cyaml.c index 19436db..2a6f58f 100644 --- a/lnet/utils/cyaml/cyaml.c +++ b/lnet/utils/cyaml/cyaml.c @@ -44,7 +44,7 @@ #include #include #include -#include "libcfs/list.h" +#include "libcfs/util/list.h" #include "cyaml.h" #define INDENT 4 diff --git a/lnet/utils/lst.c b/lnet/utils/lst.c index 35b1948..c84a208 100644 --- a/lnet/utils/lst.c +++ b/lnet/utils/lst.c @@ -49,7 +49,7 @@ #include #include -#include +#include #include #include #include diff --git a/lustre/include/lu_ref.h b/lustre/include/lu_ref.h index 81ada8c..c7366c0 100644 --- a/lustre/include/lu_ref.h +++ b/lustre/include/lu_ref.h @@ -26,7 +26,7 @@ #ifndef __LUSTRE_LU_REF_H #define __LUSTRE_LU_REF_H -#include +#include /** \defgroup lu_ref lu_ref * diff --git a/lustre/include/lustre_disk.h b/lustre/include/lustre_disk.h index b56385e5..aea63f5 100644 --- a/lustre/include/lustre_disk.h +++ b/lustre/include/lustre_disk.h @@ -50,6 +50,11 @@ #include #include +#ifdef __KERNEL__ +#include +#else +#include +#endif #include /****************** on-disk files *********************/ diff --git a/lustre/ldlm/ldlm_flock.c b/lustre/ldlm/ldlm_flock.c index e900f00..f13bc5a 100644 --- a/lustre/ldlm/ldlm_flock.c +++ b/lustre/ldlm/ldlm_flock.c @@ -56,11 +56,11 @@ #define DEBUG_SUBSYSTEM S_LDLM +#include #include #include #include #include -#include #include "ldlm_internal.h" diff --git a/lustre/ldlm/ldlm_lockd.c b/lustre/ldlm/ldlm_lockd.c index 3f2b669..566b9d62 100644 --- a/lustre/ldlm/ldlm_lockd.c +++ b/lustre/ldlm/ldlm_lockd.c @@ -42,10 +42,10 @@ #define DEBUG_SUBSYSTEM S_LDLM #include +#include #include #include #include -#include #include "ldlm_internal.h" static int ldlm_num_threads; diff --git a/lustre/lfsck/lfsck_lib.c b/lustre/lfsck/lfsck_lib.c index 3ac83ac..9f2a321 100644 --- a/lustre/lfsck/lfsck_lib.c +++ b/lustre/lfsck/lfsck_lib.c @@ -32,7 +32,7 @@ #include #include -#include +#include #include #include #include diff --git a/lustre/obdclass/cl_io.c b/lustre/obdclass/cl_io.c index 49acb96..3ff7284 100644 --- a/lustre/obdclass/cl_io.c +++ b/lustre/obdclass/cl_io.c @@ -42,10 +42,10 @@ #define DEBUG_SUBSYSTEM S_CLASS #include +#include #include #include #include -#include #include #include "cl_internal.h" diff --git a/lustre/obdclass/cl_lock.c b/lustre/obdclass/cl_lock.c index 6be5ff9..ef2fd37 100644 --- a/lustre/obdclass/cl_lock.c +++ b/lustre/obdclass/cl_lock.c @@ -41,11 +41,11 @@ #define DEBUG_SUBSYSTEM S_CLASS +#include #include #include #include #include -#include #include #include "cl_internal.h" diff --git a/lustre/obdclass/cl_object.c b/lustre/obdclass/cl_object.c index c6f5fc5..3a4635f 100644 --- a/lustre/obdclass/cl_object.c +++ b/lustre/obdclass/cl_object.c @@ -50,12 +50,12 @@ #define DEBUG_SUBSYSTEM S_CLASS +#include #include /* class_put_type() */ #include #include #include -#include #include /* for cfs_hash stuff */ #include #include diff --git a/lustre/obdclass/cl_page.c b/lustre/obdclass/cl_page.c index 65cf9fe..f38c3a1 100644 --- a/lustre/obdclass/cl_page.c +++ b/lustre/obdclass/cl_page.c @@ -41,10 +41,10 @@ #define DEBUG_SUBSYSTEM S_CLASS +#include #include #include #include -#include #include #include "cl_internal.h" diff --git a/lustre/obdclass/class_obd.c b/lustre/obdclass/class_obd.c index 49a60d3..82c8cf7 100644 --- a/lustre/obdclass/class_obd.c +++ b/lustre/obdclass/class_obd.c @@ -41,6 +41,7 @@ # include #endif #include +#include #include #include @@ -48,7 +49,6 @@ #include #include #include -#include #include #ifdef HAVE_SERVER_SUPPORT # include diff --git a/lustre/obdclass/dt_object.c b/lustre/obdclass/dt_object.c index f44f879..8939f63 100644 --- a/lustre/obdclass/dt_object.c +++ b/lustre/obdclass/dt_object.c @@ -43,9 +43,9 @@ #define DEBUG_SUBSYSTEM S_CLASS +#include #include #include -#include /* fid_be_to_cpu() */ #include #include diff --git a/lustre/obdclass/lu_object.c b/lustre/obdclass/lu_object.c index e8c976d..3a78091 100644 --- a/lustre/obdclass/lu_object.c +++ b/lustre/obdclass/lu_object.c @@ -44,8 +44,9 @@ #define DEBUG_SUBSYSTEM S_CLASS -#include #include +#include +#include #include /* hash_long() */ #include #include @@ -53,7 +54,6 @@ #include #include #include -#include enum { LU_CACHE_PERCENT_MAX = 50, diff --git a/lustre/ptlrpc/gss/gss_keyring.c b/lustre/ptlrpc/gss/gss_keyring.c index e296049..daad690 100644 --- a/lustre/ptlrpc/gss/gss_keyring.c +++ b/lustre/ptlrpc/gss/gss_keyring.c @@ -51,6 +51,7 @@ #include #include +#include #include #include #include diff --git a/lustre/ptlrpc/gss/gss_pipefs.c b/lustre/ptlrpc/gss/gss_pipefs.c index 3391b1f..6b1d9e4 100644 --- a/lustre/ptlrpc/gss/gss_pipefs.c +++ b/lustre/ptlrpc/gss/gss_pipefs.c @@ -58,6 +58,7 @@ struct rpc_clnt; /* for rpc_pipefs */ #include +#include #include #include #include diff --git a/lustre/ptlrpc/llog_client.c b/lustre/ptlrpc/llog_client.c index ccc4a3e..e096e15 100644 --- a/lustre/ptlrpc/llog_client.c +++ b/lustre/ptlrpc/llog_client.c @@ -42,12 +42,12 @@ #define DEBUG_SUBSYSTEM S_LOG +#include #include #include #include #include -#include #define LLOG_CLIENT_ENTRY(ctxt, imp) do { \ mutex_lock(&ctxt->loc_mutex); \ diff --git a/lustre/ptlrpc/recover.c b/lustre/ptlrpc/recover.c index e2bca8a..7d23518 100644 --- a/lustre/ptlrpc/recover.c +++ b/lustre/ptlrpc/recover.c @@ -39,6 +39,7 @@ */ #define DEBUG_SUBSYSTEM S_RPC +#include #include #include #include @@ -47,7 +48,6 @@ #include #include #include -#include #include "ptlrpc_internal.h" diff --git a/lustre/tests/it_test.c b/lustre/tests/it_test.c index 2777143..d0a4168 100644 --- a/lustre/tests/it_test.c +++ b/lustre/tests/it_test.c @@ -44,6 +44,7 @@ #include #include #include +#include #include diff --git a/lustre/utils/mount_utils.h b/lustre/utils/mount_utils.h index 7fd9b34..bcacce4 100644 --- a/lustre/utils/mount_utils.h +++ b/lustre/utils/mount_utils.h @@ -58,6 +58,7 @@ #include #include +#include #include #include diff --git a/lustre/utils/obd.c b/lustre/utils/obd.c index 5f0fa5d..a872f3f 100644 --- a/lustre/utils/obd.c +++ b/lustre/utils/obd.c @@ -64,6 +64,7 @@ #include #include "obdctl.h" +#include #include #include #include -- 1.8.3.1