Whamcloud - gitweb
LU-6245 libcfs: remove userland headers from libcfs.h 14/16914/8
authorJames Simmons <uja.ornl@yahoo.com>
Thu, 7 Jan 2016 21:16:20 +0000 (16:16 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 2 Feb 2016 04:30:53 +0000 (04:30 +0000)
Currently libcfs.h is used as a master header that
contains all the needed headers. Since Lustre user
land utilities and applications no longer have a
strong dependency on libcfs.h we can remove all
the added user land headers contained in libcfs.h.

Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Change-Id: I6403d109875a1d42d8490a3a1c7635f2dac9fc90
Reviewed-on: http://review.whamcloud.com/16914
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
24 files changed:
libcfs/include/libcfs/curproc.h
libcfs/include/libcfs/libcfs.h
libcfs/include/libcfs/libcfs_cpu.h
libcfs/include/libcfs/libcfs_debug.h
libcfs/include/libcfs/libcfs_fail.h
libcfs/include/libcfs/libcfs_private.h
libcfs/include/libcfs/user-time.h
lnet/lnet/lib-eq.c
lustre/tests/group_lock_test.c
lustre/tests/it_test.c
lustre/tests/llapi_fid_test.c
lustre/tests/statone.c
lustre/utils/lctl.c
lustre/utils/lhsmtool_posix.c
lustre/utils/liblustreapi.c
lustre/utils/liblustreapi_hsm.c
lustre/utils/llog_reader.c
lustre/utils/lr_reader.c
lustre/utils/lustre_cfg.c
lustre/utils/lustre_lfsck.c
lustre/utils/lustre_rsync.c
lustre/utils/mount_utils.h
lustre/utils/req-layout.c
lustre/utils/wiretest.c

index a2956bf..6568ccb 100644 (file)
@@ -43,7 +43,7 @@
 #ifndef __LIBCFS_CURPROC_H__
 #define __LIBCFS_CURPROC_H__
 
-#if !defined(HAVE_UIDGID_HEADER) || !defined(__KERNEL__)
+#ifndef HAVE_UIDGID_HEADER
 
 #ifndef _LINUX_UIDGID_H
 #define _LINUX_UIDGID_H
@@ -57,14 +57,6 @@ typedef gid_t kgid_t;
 #define GLOBAL_ROOT_UID         0
 #define GLOBAL_ROOT_GID         0
 
-#ifndef __KERNEL__
-struct user_namespace {
-       unsigned int pad;
-};
-
-extern struct user_namespace init_user_ns;
-#endif
-
 static inline uid_t __kuid_val(kuid_t uid)
 {
        return uid;
index 97be523..8a04dd3 100644 (file)
 #include <libcfs/types.h>
 #include <libcfs/list.h>
 
-#ifdef __KERNEL__
-# include <libcfs/linux/libcfs.h>
-#else /* !__KERNEL__ */
-# include <assert.h>
-# include <ctype.h>
-# include <errno.h>
-# include <fcntl.h>
-# include <limits.h>
-# include <signal.h>
-# include <stdarg.h>
-# include <stdbool.h>
-# include <stddef.h>
-# include <stdint.h>
-# include <stdio.h>
-# include <stdlib.h>
-# include <string.h>
-# include <time.h>
-# include <sys/ioctl.h>
-# include <sys/socket.h>
-# include <sys/stat.h>
-# include <sys/time.h>
-# include <sys/types.h>
+#ifndef __KERNEL__
 # include <libcfs/user-time.h>
-#endif /* __KERNEL__ */
-
-#include "curproc.h"
+# else /* __KERNEL__ */
+# include <libcfs/linux/libcfs.h>
+# include "curproc.h"
 
 #define LIBCFS_VERSION "0.5.0"
 
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(a) ((sizeof (a)) / (sizeof ((a)[0])))
-#endif
-
-#if !defined(swap)
-#define swap(x,y) do { typeof(x) z = x; x = y; y = z; } while (0)
-#endif
-
-#if !defined(container_of)
-/* given a pointer @ptr to the field @member embedded into type (usually
- * struct) @type, return pointer to the embedding instance of @type. */
-#define container_of(ptr, type, member) \
-        ((type *)((char *)(ptr)-(char *)(&((type *)0)->member)))
-#endif
-
 static inline int __is_po2(unsigned long long val)
 {
         return !(val & (val - 1));
@@ -94,38 +58,13 @@ static inline int __is_po2(unsigned long long val)
 #define LOWEST_BIT_SET(x) ((x) & ~((x) - 1))
 
 /* Sparse annotations */
-#ifdef __KERNEL__
-# if !defined(__must_hold)
-#  ifdef __CHECKER__
-#   define __must_hold(x) __attribute__((context(x, 1, 1)))
-#  else        /* __CHECKER__ */
-#   define __must_hold(x)
-#  endif /* !__CHECKER__ */
-# endif /* !__must_hold */
-#else /* __KERNEL__ */
-# define __acquires(x)
-# define __releases(x)
-# define __must_hold(x)
-#endif /* !__KERNEL__ */
-
-/*
- * Lustre Error Checksum: calculates checksum
- * of Hex number by XORing each bit.
- */
-#define LERRCHKSUM(hexnum) (((hexnum) & 0xf) ^ ((hexnum) >> 4 & 0xf) ^ \
-                           ((hexnum) >> 8 & 0xf))
-
-/*
- * Some (nomina odiosa sunt) platforms define NULL as naked 0. This confuses
- * Lustre RETURN(NULL) macro.
- */
-#if defined(NULL)
-#undef NULL
-#endif
-
-#define NULL ((void *)0)
-
-#ifdef __KERNEL__
+#if !defined(__must_hold)
+# ifdef __CHECKER__
+#  define __must_hold(x) __attribute__((context(x, 1, 1)))
+# else /* __CHECKER__ */
+#  define __must_hold(x)
+# endif /* !__CHECKER__ */
+#endif /* !__must_hold */
 
 /* libcfs watchdogs */
 struct lc_watchdog;
@@ -148,8 +87,6 @@ void lc_watchdog_disable(struct lc_watchdog *lcw);
 /* Clean up the watchdog */
 void lc_watchdog_delete(struct lc_watchdog *lcw);
 
-#endif /* __KERNEL__ */
-
 /* need both kernel and user-land acceptor */
 #define LNET_ACCEPTOR_MIN_RESERVED_PORT    512
 #define LNET_ACCEPTOR_MAX_RESERVED_PORT    1023
@@ -179,6 +116,7 @@ unsigned int cfs_rand(void);
 /* seed the generator */
 void cfs_srand(unsigned int, unsigned int);
 void cfs_get_random_bytes(void *buf, int size);
+#endif /* __KERNEL__ */
 
 #include <libcfs/byteorder.h>
 #include <libcfs/libcfs_debug.h>
index 380be11..00aa9ad 100644 (file)
 
 #ifndef HAVE_LIBCFS_CPT
 
-#ifndef __KERNEL__
-typedef struct nodemask { DECLARE_BITMAP(bits, 1); } nodemask_t;
-typedef struct cpumask  { DECLARE_BITMAP(bits, 1); } cpumask_t;
-
-#define node_set(node, dst) __node_set((node), &(dst))
-static __always_inline void __node_set(int node, nodemask_t *dstp)
-{
-       set_bit(node, dstp->bits);
-}
-#endif /* __KERNEL__ */
-
 struct cfs_cpt_table {
        /* # of CPU partitions */
        int                     ctb_nparts;
index 85cfea3..fc89ce8 100644 (file)
@@ -267,6 +267,13 @@ do {                                                                    \
 
 #endif /* __KERNEL__ */
 
+/*
+ * Lustre Error Checksum: calculates checksum
+ * of Hex number by XORing each bit.
+ */
+#define LERRCHKSUM(hexnum) (((hexnum) & 0xf) ^ ((hexnum) >> 4 & 0xf) ^ \
+                          ((hexnum) >> 8 & 0xf))
+
 #define CWARN(format, ...)          CDEBUG_LIMIT(D_WARNING, format, ## __VA_ARGS__)
 #define CERROR(format, ...)         CDEBUG_LIMIT(D_ERROR, format, ## __VA_ARGS__)
 #define CNETERR(format, a...)       CDEBUG_LIMIT(D_NETERROR, format, ## a)
index 88c8f71..8529566 100644 (file)
@@ -156,7 +156,6 @@ static inline int cfs_fail_timeout_set(__u32 id, __u32 value, int ms, int set)
 #define CFS_FAULT_CHECK(id)                    \
        CFS_FAIL_CHECK(CFS_FAULT | (id))
 
-#ifdef __KERNEL__
 /* The idea here is to synchronise two threads to force a race. The
  * first thread that calls this with a matching fail_loc is put to
  * sleep. The next thread that calls with the same fail_loc wakes up
@@ -179,9 +178,5 @@ static inline void cfs_race(__u32 id)
        }
 }
 #define CFS_RACE(id) cfs_race(id)
-#else
-/* sigh.  an expedient fix until CFS_RACE is fixed up */
-#define CFS_RACE(foo) do {} while(0)
-#endif
 
 #endif /* _LIBCFS_FAIL_H */
index b4aeac6..1bd885c 100644 (file)
@@ -483,19 +483,6 @@ static inline size_t cfs_round_strlen(char *fset)
        return cfs_size_round(strlen(fset) + 1);
 }
 
-/* roundup \a val to power2 */
-static inline size_t cfs_power2_roundup(size_t val)
-{
-       if (val != LOWEST_BIT_SET(val)) { /* not a power of 2 already */
-               do {
-                       val &= ~LOWEST_BIT_SET(val);
-               } while (val != LOWEST_BIT_SET(val));
-               /* ...and round up */
-               val <<= 1;
-       }
-       return val;
-}
-
 #define LOGL(var,len,ptr)                                       \
 do {                                                            \
         if (var)                                                \
index bf0fdd9..d88af2e 100644 (file)
 
 #ifndef __KERNEL__
 
-#define ONE_BILLION ((u_int64_t)1000000000)
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <sys/time.h>
+#include <time.h>
+
+#define ONE_BILLION ((uint64_t)1000000000)
 #define ONE_MILLION 1000000
 
 /*
index 91dbf08..709ffc9 100644 (file)
@@ -78,7 +78,7 @@ LNetEQAlloc(unsigned int count, lnet_eq_handler_t callback,
          * overflow, they don't skip entries, so the queue has the same
          * apparent capacity at all times */
 
-       count = cfs_power2_roundup(count);
+       count = roundup_pow_of_two(count);
 
        if (callback != LNET_EQ_HANDLER_NONE && count != 0) {
                CWARN("EQ callback is guaranteed to get every event, "
index 13a1738..1b43580 100644 (file)
@@ -35,6 +35,7 @@
 #include <errno.h>
 #include <getopt.h>
 #include <fcntl.h>
+#include <sys/ioctl.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
index a31e0b3..4d3617c 100644 (file)
@@ -40,6 +40,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <time.h>
 #include <sys/time.h>
 
index e8433a1..be38a6c 100644 (file)
@@ -42,6 +42,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <poll.h>
+#include <sys/ioctl.h>
 #include <time.h>
 
 #include <lustre/lustreapi.h>
index 202aa53..4a1c695 100644 (file)
  * Lustre is a trademark of Sun Microsystems, Inc.
  */
 
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
index 9c27267..27b46ed 100644 (file)
  * Author: Robert Read <rread@clusterfs.com>
  */
 
+#include <errno.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <string.h>
 #include <libcfs/util/parser.h>
 #include <lnet/lnetctl.h>
 #include "obdctl.h"
index a8d7db4..40cbf3c 100644 (file)
 #ifndef _GNU_SOURCE
 #define _GNU_SOURCE
 #endif
+#include <ctype.h>
+#include <fcntl.h>
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
+#include <string.h>
 #include <dirent.h>
 #include <errno.h>
 #include <getopt.h>
 #include <time.h>
 #include <unistd.h>
 #include <utime.h>
+#include <signal.h>
 #include <sys/time.h>
 #include <sys/xattr.h>
 #include <sys/syscall.h>
 #include <sys/types.h>
+
 #include <libcfs/util/string.h>
 #include <lustre/lustre_idl.h>
 #include <lustre/lustreapi.h>
index 2e5f9bd..988d9f4 100644 (file)
 #include <stdarg.h>
 #include <sys/stat.h>
 #include <sys/statfs.h>
-#include <sys/types.h>
 #include <sys/syscall.h>
+#include <sys/time.h>
+#include <sys/types.h>
 #include <sys/xattr.h>
+#include <time.h>
 #include <fnmatch.h>
 #include <libgen.h> /* for dirname() */
 #ifdef HAVE_LINUX_UNISTD_H
index 8033b03..3536496 100644 (file)
@@ -32,6 +32,7 @@
  * Author: Henri Doreau <henri.doreau@cea.fr>
  */
 
+#include <fcntl.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
index 4d2f1ff..9dc3ef8 100644 (file)
@@ -40,7 +40,9 @@
  * @{
  */
 
+#include <errno.h>
 #include <stdio.h>
+#include <string.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #ifdef HAVE_ENDIAN_H
index dff6de3..3e2495b 100644 (file)
@@ -46,6 +46,7 @@
 #ifndef _GNU_SOURCE
 #define _GNU_SOURCE
 #endif
+#include <errno.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <unistd.h>
index a664260..8ddd97f 100644 (file)
  * Author: Robert Read <rread@clusterfs.com>
  */
 
+#include <errno.h>
+#include <fcntl.h>
 #include <stdlib.h>
+#include <string.h>
 #include <sys/ioctl.h>
 #include <sys/stat.h>
 #include <unistd.h>
index 04f0bba..2baf9a7 100644 (file)
@@ -36,6 +36,7 @@
 #include <string.h>
 #include <errno.h>
 #include <getopt.h>
+#include <sys/ioctl.h>
 #include <time.h>
 
 #include "obdctl.h"
index 112a21c..404ae58 100644 (file)
 #include <getopt.h>
 #include <stdarg.h>
 #include <fcntl.h>
+#include <signal.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <errno.h>
index 013bb46..cac592c 100644 (file)
 #define _SPL_ZFS_H
 #define _SPL_SIGNAL_H
 #endif
+#include <ctype.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
 #include <lustre_disk.h>
 #include <lustre_param.h>
 
index 4b4908b..644e120 100644 (file)
  * Author: Nikita Danilov <nikita@clusterfs.com>
  */
 
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <unistd.h>
 
 #include <linux/types.h>
 
+#define ARRAY_SIZE(a) ((sizeof(a)) / (sizeof((a)[0])))
 #define __REQ_LAYOUT_USER__ (1)
 #define EXPORT_SYMBOL(s)
 
index 2481225..1a3dc98 100644 (file)
  * Lustre is a trademark of Sun Microsystems, Inc.
  */
 
+#include <errno.h>
 #include <stdio.h>
+#include <string.h>
+
 #include <lustre/lustre_idl.h>
 #include <lustre/lustre_lfsck_user.h>
 #include <lustre_disk.h>