From 001b8dbfacb747f1649a2eb047a5f118ce32fdc7 Mon Sep 17 00:00:00 2001 From: Alexey Lyashkov Date: Mon, 30 Sep 2013 13:38:10 +0300 Subject: [PATCH] LU-3963 cleanup: C89 and build cleanups use C99 initialization for a types, remove some platform depended code and use POSIX compatible instead. don't build a lhsmtool is none utils allowed. Signed-off-by: Alexey Lyashkov Change-Id: I6e2837953902520240e9ceb251c92329d328d715 Reviewed-on: http://review.whamcloud.com/7803 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Bob Glossman Reviewed-by: Oleg Drokin --- libcfs/include/libcfs/libcfs_private.h | 2 +- libcfs/include/libcfs/linux/Makefile.am | 2 +- libcfs/include/libcfs/linux/libcfs.h | 2 +- libcfs/include/libcfs/linux/portals_compat25.h | 4 -- libcfs/include/libcfs/posix/Makefile.am | 2 +- libcfs/include/libcfs/posix/libcfs.h | 10 ++-- libcfs/include/libcfs/posix/posix-types.h | 4 +- libcfs/include/libcfs/posix/posix-wordsize.h | 22 -------- libcfs/include/libcfs/user-bitops.h | 8 +-- libcfs/include/libcfs/user-prim.h | 5 -- libcfs/include/libcfs/winnt/portals_utils.h | 6 +-- libcfs/include/libcfs/winnt/winnt-lock.h | 4 +- libcfs/libcfs/hash.c | 4 +- libcfs/libcfs/posix/Makefile.am | 3 +- libcfs/libcfs/posix/posix-debug.c | 2 +- .../posix/posix-tracefile.h} | 33 ++++++------ libcfs/libcfs/tracefile.h | 5 +- libcfs/libcfs/user-bitops.c | 8 +-- libcfs/libcfs/user-tcpip.c | 6 --- libcfs/libcfs/winnt/winnt-proc.c | 4 +- libsysio/Makefile.am | 4 +- lnet/autoMakefile.am | 3 ++ lnet/utils/genlib.sh | 2 +- lustre/fld/fld_cache.c | 2 +- lustre/fld/fld_request.c | 2 +- lustre/include/cl_object.h | 5 +- lustre/include/darwin/lustre_handles.h | 2 +- lustre/include/darwin/lustre_user.h | 1 - lustre/include/liblustre.h | 5 +- lustre/include/lvfs.h | 7 +++ lustre/ldlm/ldlm_lib.c | 16 +++--- lustre/ldlm/ldlm_lock.c | 58 +++++++++++----------- lustre/ldlm/ldlm_request.c | 2 +- lustre/liblustre/Makefile.am | 2 +- lustre/liblustre/dir.c | 4 +- lustre/liblustre/genlib.sh | 4 +- lustre/lmv/lmv_fld.c | 2 +- lustre/lmv/lmv_intent.c | 2 +- lustre/lmv/lmv_obd.c | 2 +- lustre/lov/lov_ea.c | 2 +- lustre/lov/lov_obd.c | 2 +- lustre/mdc/mdc_locks.c | 5 +- lustre/mdc/mdc_request.c | 2 +- lustre/obdclass/cl_lock.c | 7 ++- lustre/obdclass/lprocfs_status.c | 2 +- lustre/ofd/ofd_dev.c | 2 +- lustre/tests/conf-sanity.sh | 2 +- lustre/utils/Makefile.am | 13 ++--- 48 files changed, 140 insertions(+), 158 deletions(-) rename libcfs/{include/libcfs/linux/linux-bitops.h => libcfs/posix/posix-tracefile.h} (57%) diff --git a/libcfs/include/libcfs/libcfs_private.h b/libcfs/include/libcfs/libcfs_private.h index ee5f1da..c8aaabc 100644 --- a/libcfs/include/libcfs/libcfs_private.h +++ b/libcfs/include/libcfs/libcfs_private.h @@ -534,7 +534,7 @@ int cfs_percpt_atomic_summary(atomic_t **refs); * value after conversion... * */ -#define CLASSERT(cond) do {switch(42) {case (cond): case 0: break;}} while (0) +#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); diff --git a/libcfs/include/libcfs/linux/Makefile.am b/libcfs/include/libcfs/linux/Makefile.am index 6e96ffe..409ac3c 100644 --- a/libcfs/include/libcfs/linux/Makefile.am +++ b/libcfs/include/libcfs/linux/Makefile.am @@ -1,3 +1,3 @@ EXTRA_DIST = kp30.h libcfs.h linux-fs.h linux-lock.h linux-mem.h \ linux-prim.h linux-time.h linux-tcpip.h linux-cpu.h \ - portals_compat25.h linux-bitops.h linux-crypto.h + portals_compat25.h linux-crypto.h diff --git a/libcfs/include/libcfs/linux/libcfs.h b/libcfs/include/libcfs/linux/libcfs.h index 13bcd3a..8c1d920 100644 --- a/libcfs/include/libcfs/linux/libcfs.h +++ b/libcfs/include/libcfs/linux/libcfs.h @@ -54,7 +54,6 @@ #include #include #include -#include #include #ifdef HAVE_ASM_TYPES_H @@ -64,6 +63,7 @@ #include #include /* THREAD_SIZE */ #include +#include #if !defined(__x86_64__) # ifdef __ia64__ diff --git a/libcfs/include/libcfs/linux/portals_compat25.h b/libcfs/include/libcfs/linux/portals_compat25.h index 52b6244..c946564 100644 --- a/libcfs/include/libcfs/linux/portals_compat25.h +++ b/libcfs/include/libcfs/linux/portals_compat25.h @@ -37,10 +37,6 @@ #ifndef __LIBCFS_LINUX_PORTALS_COMPAT_H__ #define __LIBCFS_LINUX_PORTALS_COMPAT_H__ -#ifndef __user -#define __user -#endif - #define LL_PROC_PROTO(name) \ name(struct ctl_table *table, int write, \ void __user *buffer, size_t *lenp, loff_t *ppos) diff --git a/libcfs/include/libcfs/posix/Makefile.am b/libcfs/include/libcfs/posix/Makefile.am index 957f156..def79ff 100644 --- a/libcfs/include/libcfs/posix/Makefile.am +++ b/libcfs/include/libcfs/posix/Makefile.am @@ -4,4 +4,4 @@ if UTILS libcfsposix_HEADERS = posix-types.h endif -EXTRA_DIST = libcfs.h posix-wordsize.h posix-types.h posix-crypto.h +EXTRA_DIST = libcfs.h posix-wordsize.h posix-types.h posix-crypto.h \ No newline at end of file diff --git a/libcfs/include/libcfs/posix/libcfs.h b/libcfs/include/libcfs/posix/libcfs.h index d96afcc..6a16be3 100644 --- a/libcfs/include/libcfs/posix/libcfs.h +++ b/libcfs/include/libcfs/posix/libcfs.h @@ -67,6 +67,7 @@ #include #include #include +#include #ifdef HAVE_NETDB_H #include @@ -188,11 +189,6 @@ typedef unsigned long long cfs_cycles_t; #define __swab64s(x) do { *(x) = __swab64(*(x)); } while (0) #endif -#if !defined(ALIGN) -#define __ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask)) -#define ALIGN(x, a) __ALIGN_MASK(x, (typeof(x))(a) - 1) -#endif - # ifndef THREAD_SIZE /* x86_64 linux has THREAD_SIZE in userspace */ # define THREAD_SIZE 8192 # else @@ -488,4 +484,8 @@ typedef ssize_t (*read_actor_t)(); # define DTTOIF(dirtype) ((dirtype) << IFSHIFT) # endif +#ifndef ERESTARTSYS +#define ERESTARTSYS ERESTART +#endif + #endif diff --git a/libcfs/include/libcfs/posix/posix-types.h b/libcfs/include/libcfs/posix/posix-types.h index 446db6e..510b17848 100644 --- a/libcfs/include/libcfs/posix/posix-types.h +++ b/libcfs/include/libcfs/posix/posix-types.h @@ -42,7 +42,9 @@ #ifndef _LUSTRE_POSIX_TYPES_H #define _LUSTRE_POSIX_TYPES_H -#include +#ifdef HAVE_LINUX_TYPES_H +# include +#endif #include /* for bool */ #ifndef HAVE_UMODE_T typedef unsigned short umode_t; diff --git a/libcfs/include/libcfs/posix/posix-wordsize.h b/libcfs/include/libcfs/posix/posix-wordsize.h index b826d36..b7ef6e2 100644 --- a/libcfs/include/libcfs/posix/posix-wordsize.h +++ b/libcfs/include/libcfs/posix/posix-wordsize.h @@ -81,34 +81,12 @@ # define LP_POISON ((void *)(long)0x5a5a5a5a) #endif -#if (defined(__KERNEL__) && defined(HAVE_KERN__U64_LONG_LONG)) || \ - (!defined(__KERNEL__) && defined(HAVE_USER__U64_LONG_LONG)) -/* x86_64 defines __u64 as "long" in userspace, but "long long" in the kernel */ # define LPU64 "%llu" # define LPD64 "%lld" # define LPX64 "%#llx" # define LPX64i "%llx" # define LPO64 "%#llo" # define LPF64 "ll" -#elif (BITS_PER_LONG == 32) -# define LPU64 "%llu" -# define LPD64 "%lld" -# define LPX64 "%#llx" -# define LPX64i "%llx" -# define LPO64 "%#llo" -# define LPF64 "L" -#elif (BITS_PER_LONG == 64) -# define LPU64 "%lu" -# define LPD64 "%ld" -# define LPX64i "%lx" -# define LPX64 "%#lx" -# define LPO64 "%#lo" -# define LPF64 "l" -#endif - -#ifndef LPU64 -# error "No word size defined" -#endif /* * long_ptr_t & ulong_ptr_t, same to "long" for gcc diff --git a/libcfs/include/libcfs/user-bitops.h b/libcfs/include/libcfs/user-bitops.h index 1b16ca77..7b31bc9 100644 --- a/libcfs/include/libcfs/user-bitops.h +++ b/libcfs/include/libcfs/user-bitops.h @@ -76,7 +76,7 @@ static inline int test_bit(int nr, const unsigned long *addr) } /* using binary seach */ -static __inline__ unsigned long fls(long data) +static inline unsigned long __fls(long data) { int pos = 32; @@ -115,7 +115,7 @@ static __inline__ unsigned long fls(long data) return pos; } -static __inline__ unsigned long __cfs_ffs(long data) +static inline unsigned long __ffs(long data) { int pos = 0; @@ -147,8 +147,8 @@ static __inline__ unsigned long __cfs_ffs(long data) return pos; } -#define ffz(x) ffs(~(x)) -#define flz(x) fls(~(x)) +#define __ffz(x) __ffs(~(x)) +#define __flz(x) __fls(~(x)) unsigned long find_next_bit(unsigned long *addr, unsigned long size, unsigned long offset); diff --git a/libcfs/include/libcfs/user-prim.h b/libcfs/include/libcfs/user-prim.h index 6053eb4..ec121d6 100644 --- a/libcfs/include/libcfs/user-prim.h +++ b/libcfs/include/libcfs/user-prim.h @@ -55,8 +55,6 @@ # define EXPORT_SYMBOL(s) #endif -#ifndef __KERNEL__ - typedef struct proc_dir_entry cfs_proc_dir_entry_t; /* @@ -166,7 +164,6 @@ static inline int misc_deregister(struct miscdevice *foo) return 0; } -#define cfs_sigfillset(l) do {} while (0) #define cfs_recalc_sigpending(l) do {} while (0) #define DAEMON_FLAGS 0 @@ -264,8 +261,6 @@ static inline void libcfs_arch_cleanup(void) { /* !__WINNT__ */ #endif -/* !__KERNEL__ */ -#endif /* __LIBCFS_USER_PRIM_H__ */ #endif diff --git a/libcfs/include/libcfs/winnt/portals_utils.h b/libcfs/include/libcfs/winnt/portals_utils.h index 39ab41f..b8678d9 100644 --- a/libcfs/include/libcfs/winnt/portals_utils.h +++ b/libcfs/include/libcfs/winnt/portals_utils.h @@ -141,7 +141,7 @@ static inline int ffs(int x) return r; } -static inline unsigned long __cfs_ffs(unsigned long word) +static inline unsigned long __ffs(unsigned long word) { int num = 0; @@ -180,7 +180,7 @@ static inline unsigned long __cfs_ffs(unsigned long word) * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32. */ static inline -int fls(int x) +int __fls(int x) { int r = 32; @@ -217,7 +217,7 @@ static inline unsigned find_first_bit(const unsigned long *addr, while (x < size) { unsigned long val = *addr++; if (val) - return __cfs_ffs(val) + x; + return __ffs(val) + x; x += (sizeof(*addr)<<3); } return x; diff --git a/libcfs/include/libcfs/winnt/winnt-lock.h b/libcfs/include/libcfs/winnt/winnt-lock.h index fc39dd8..2251c5d 100644 --- a/libcfs/include/libcfs/winnt/winnt-lock.h +++ b/libcfs/include/libcfs/winnt/winnt-lock.h @@ -580,8 +580,8 @@ static inline int down_trylock(struct semaphore *s) * * - init_mutex(x) * - init_mutex_locked(x) - * - mutex_up(x) - * - mutex_down(x) + * - mutex_unlock(x) + * - mutex_lock(x) */ #define mutex semaphore diff --git a/libcfs/libcfs/hash.c b/libcfs/libcfs/hash.c index 0c4faf8..af0b3a9 100644 --- a/libcfs/libcfs/hash.c +++ b/libcfs/libcfs/hash.c @@ -2131,7 +2131,7 @@ int cfs_hash_debug_str(cfs_hash_t *hs, char *str, int size) #endif } total += bd.bd_bucket->hsb_count; - dist[min(fls(bd.bd_bucket->hsb_count/max(theta,1)),7)]++; + dist[min(__fls(bd.bd_bucket->hsb_count/max(theta,1)),7UL)]++; cfs_hash_bd_unlock(hs, &bd, 0); } @@ -2200,7 +2200,7 @@ int cfs_hash_debug_str_seq(cfs_hash_t *hs, struct seq_file *m) #endif } total += bd.bd_bucket->hsb_count; - dist[min(fls(bd.bd_bucket->hsb_count/max(theta,1)),7)]++; + dist[min(__fls(bd.bd_bucket->hsb_count/max(theta,1)),7UL)]++; cfs_hash_bd_unlock(hs, &bd, 0); } diff --git a/libcfs/libcfs/posix/Makefile.am b/libcfs/libcfs/posix/Makefile.am index 185710f..3cfdf7a 100644 --- a/libcfs/libcfs/posix/Makefile.am +++ b/libcfs/libcfs/posix/Makefile.am @@ -1,2 +1,3 @@ -EXTRA_DIST = posix-debug.c +EXTRA_DIST = posix-debug.c posix-tracefile.h + diff --git a/libcfs/libcfs/posix/posix-debug.c b/libcfs/libcfs/posix/posix-debug.c index 68b606e..3de41f6 100644 --- a/libcfs/libcfs/posix/posix-debug.c +++ b/libcfs/libcfs/posix/posix-debug.c @@ -210,7 +210,7 @@ libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata, gettimeofday(&tv, NULL); fprintf(debug_file_fd, CFS_TIME_T".%06lu:%u:%s:(%s:%d:%s()): %s", - tv.tv_sec, tv.tv_usec, source_pid, source_nid, + tv.tv_sec, (unsigned long)tv.tv_usec, source_pid, source_nid, msgdata->msg_file, msgdata->msg_line, msgdata->msg_fn, buf); return 0; diff --git a/libcfs/include/libcfs/linux/linux-bitops.h b/libcfs/libcfs/posix/posix-tracefile.h similarity index 57% rename from libcfs/include/libcfs/linux/linux-bitops.h rename to libcfs/libcfs/posix/posix-tracefile.h index 715c138..020c494 100644 --- a/libcfs/include/libcfs/linux/linux-bitops.h +++ b/libcfs/libcfs/posix/posix-tracefile.h @@ -15,26 +15,29 @@ * * 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. + * http://www.gnu.org/licenses/gpl-2.0.htm * * GPL HEADER END */ /* - * Copyright (c) 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. + * libcfs/libcfs/posix/posix-tracefile.h * - * libcfs/include/libcfs/linux/linux-bitops.h + * Userspace debugging-tracing */ -#include +#ifndef __LIBCFS_POSIX_TRACEFILE_H__ +#define __LIBCFS_POSIX_TRACEFILE_H__ + +/** + * three types of trace_data in linux + * posix need to max of available types to have + * type checking happy. + */ +typedef enum { + CFS_TCD_TYPE_PROC = 0, + CFS_TCD_TYPE_SOFTIRQ, + CFS_TCD_TYPE_IRQ, + CFS_TCD_TYPE_MAX +} cfs_trace_buf_type_t; +#endif diff --git a/libcfs/libcfs/tracefile.h b/libcfs/libcfs/tracefile.h index c7b4c42..3aa8989 100644 --- a/libcfs/libcfs/tracefile.h +++ b/libcfs/libcfs/tracefile.h @@ -39,6 +39,7 @@ #include +#ifdef __KERNEL__ #if defined(__linux__) #include "linux/linux-tracefile.h" #elif defined(__WINNT__) @@ -46,7 +47,9 @@ #else #error Unsupported operating system. #endif - +#else +#include "posix/posix-tracefile.h" +#endif /* trace file lock routines */ #define TRACEFILE_NAME_SIZE 1024 diff --git a/libcfs/libcfs/user-bitops.c b/libcfs/libcfs/user-bitops.c index 65f2da9..26228ee 100644 --- a/libcfs/libcfs/user-bitops.c +++ b/libcfs/libcfs/user-bitops.c @@ -55,7 +55,7 @@ unsigned long find_next_bit(unsigned long *addr, return size; if (first_bit != 0) { int tmp = (*word++) & (~0UL << first_bit); - bit = __cfs_ffs(tmp); + bit = __ffs(tmp); if (bit < BITS_PER_LONG) goto found; word++; @@ -63,7 +63,7 @@ unsigned long find_next_bit(unsigned long *addr, } while (word <= last) { if (*word != 0UL) { - bit = __cfs_ffs(*word); + bit = __ffs(*word); goto found; } word++; @@ -89,7 +89,7 @@ unsigned long find_next_zero_bit(unsigned long *addr, return size; if (first_bit != 0) { int tmp = (*word++) & (~0UL << first_bit); - bit = ffz(tmp); + bit = __ffz(tmp); if (bit < BITS_PER_LONG) goto found; word++; @@ -97,7 +97,7 @@ unsigned long find_next_zero_bit(unsigned long *addr, } while (word <= last) { if (*word != ~0UL) { - bit = ffz(*word); + bit = __ffz(*word); goto found; } word++; diff --git a/libcfs/libcfs/user-tcpip.c b/libcfs/libcfs/user-tcpip.c index 4477f13..4b7fdaa 100644 --- a/libcfs/libcfs/user-tcpip.c +++ b/libcfs/libcfs/user-tcpip.c @@ -521,14 +521,8 @@ libcfs_sock_set_nagle(cfs_socket_t *sock, int nagle) int rc; int option = nagle ? 0 : 1; -#if defined(__sun__) || defined(__sun) rc = setsockopt(sock->s_fd, IPPROTO_TCP, TCP_NODELAY, &option, sizeof(option)); -#else - rc = setsockopt(sock->s_fd, - SOL_TCP, TCP_NODELAY, &option, sizeof(option)); -#endif - if (rc != 0) { rc = -errno; CERROR ("Cannot set NODELAY socket option\n"); diff --git a/libcfs/libcfs/winnt/winnt-proc.c b/libcfs/libcfs/winnt/winnt-proc.c index 3d7e7bb..6364371 100644 --- a/libcfs/libcfs/winnt/winnt-proc.c +++ b/libcfs/libcfs/winnt/winnt-proc.c @@ -83,8 +83,8 @@ spinlock_t proc_fs_lock; struct mutex proc_fs_lock; #define INIT_PROCFS_LOCK() cfs_init_mutex(&proc_fs_lock) -#define LOCK_PROCFS() cfs_mutex_down(&proc_fs_lock) -#define UNLOCK_PROCFS() cfs_mutex_up(&proc_fs_lock) +#define LOCK_PROCFS() mutex_lock(&proc_fs_lock) +#define UNLOCK_PROCFS() mutex_unlock(&proc_fs_lock) #endif diff --git a/libsysio/Makefile.am b/libsysio/Makefile.am index dfa4f9e..1262105 100644 --- a/libsysio/Makefile.am +++ b/libsysio/Makefile.am @@ -82,8 +82,8 @@ really-clean: testsclean maintainer-clean cd $(TESTDIR); rm -rf Makefile Makefile.in .deps tests: $(lib_LIBRARIES) FORCE - cd $(TESTDIR); make + cd $(TESTDIR); ${MAKE} testsclean: FORCE - cd $(TESTDIR); make clean + cd $(TESTDIR); ${MAKE} clean clean: testsclean clean-am FORCE: diff --git a/lnet/autoMakefile.am b/lnet/autoMakefile.am index b3c05fa..77c2566 100644 --- a/lnet/autoMakefile.am +++ b/lnet/autoMakefile.am @@ -36,3 +36,6 @@ SUBDIRS = lnet klnds ulnds selftest doc utils include \ autoconf + +DIST_SUBDIRS = lnet klnds ulnds selftest doc utils include \ + autoconf diff --git a/lnet/utils/genlib.sh b/lnet/utils/genlib.sh index bad9833..02b22c6 100755 --- a/lnet/utils/genlib.sh +++ b/lnet/utils/genlib.sh @@ -14,7 +14,7 @@ rm -f liblst.so ALL_OBJS= build_obj_list() { - _objs=`$AR -t $1/$2` + _objs=`$AR -t $1/$2 | grep -v SYMDEF | grep -v SORTED` for _lib in $_objs; do ALL_OBJS=$ALL_OBJS"$1/$_lib "; done; diff --git a/lustre/fld/fld_cache.c b/lustre/fld/fld_cache.c index 2254cd3..8ca90f4 100644 --- a/lustre/fld/fld_cache.c +++ b/lustre/fld/fld_cache.c @@ -46,7 +46,7 @@ #ifdef __KERNEL__ # include # include -# include +# include #else /* __KERNEL__ */ # include # include diff --git a/lustre/fld/fld_request.c b/lustre/fld/fld_request.c index f7c33dc..2a2a927 100644 --- a/lustre/fld/fld_request.c +++ b/lustre/fld/fld_request.c @@ -45,7 +45,7 @@ #ifdef __KERNEL__ # include # include -# include +# include #else /* __KERNEL__ */ # include # include diff --git a/lustre/include/cl_object.h b/lustre/include/cl_object.h index d933936..286ecfa 100644 --- a/lustre/include/cl_object.h +++ b/lustre/include/cl_object.h @@ -97,7 +97,9 @@ /* * super-class definitions. */ +#include #include + #ifdef __KERNEL__ # include # include @@ -806,7 +808,8 @@ enum cl_lock_mode { CLM_PHANTOM, CLM_READ, CLM_WRITE, - CLM_GROUP + CLM_GROUP, + CLM_MAX, }; /** diff --git a/lustre/include/darwin/lustre_handles.h b/lustre/include/darwin/lustre_handles.h index 225929e..c416e61 100644 --- a/lustre/include/darwin/lustre_handles.h +++ b/lustre/include/darwin/lustre_handles.h @@ -33,7 +33,7 @@ */ #ifndef __DARWIN_LUSTRE_HANDLES_H_ -#define __DARWIN_LUSTR_HANDLES_H_ +#define __DARWIN_LUSTRE_HANDLES_H_ #ifndef __LUSTRE_HANDLES_H_ #error Do not #include this file directly. #include instead diff --git a/lustre/include/darwin/lustre_user.h b/lustre/include/darwin/lustre_user.h index c686809..5c219bf 100644 --- a/lustre/include/darwin/lustre_user.h +++ b/lustre/include/darwin/lustre_user.h @@ -41,7 +41,6 @@ #ifndef __KERNEL__ /* for llmount */ -# define _GNU_SOURCE # include # include # include diff --git a/lustre/include/liblustre.h b/lustre/include/liblustre.h index 77b1fb3..815b96b 100644 --- a/lustre/include/liblustre.h +++ b/lustre/include/liblustre.h @@ -134,10 +134,7 @@ extern int mgc_init(void); ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; }) #endif -/* registering symbols */ -#ifndef ERESTARTSYS -#define ERESTARTSYS ERESTART -#endif +#define simple_strtol strtol #ifdef HZ #undef HZ diff --git a/lustre/include/lvfs.h b/lustre/include/lvfs.h index 293abbd..a8ae589 100644 --- a/lustre/include/lvfs.h +++ b/lustre/include/lvfs.h @@ -40,6 +40,12 @@ #define __LVFS_H__ #include + +struct lvfs_callback_ops { + struct dentry *(*l_fid2dentry)(__u64 id_ino, __u32 gen, __u64 gr, + void *data); +}; + #if defined(__linux__) #include #elif defined(__APPLE__) @@ -53,4 +59,5 @@ /* ptlrpc_sec_ctx.c */ void push_ctxt(struct lvfs_run_ctxt *save, struct lvfs_run_ctxt *new_ctx); void pop_ctxt(struct lvfs_run_ctxt *saved, struct lvfs_run_ctxt *new_ctx); + #endif diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index 4c35cab..aac76e9 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -2507,14 +2507,14 @@ void target_send_reply(struct ptlrpc_request *req, int rc, int fail_id) EXPORT_SYMBOL(target_send_reply); ldlm_mode_t lck_compat_array[] = { - [LCK_EX] LCK_COMPAT_EX, - [LCK_PW] LCK_COMPAT_PW, - [LCK_PR] LCK_COMPAT_PR, - [LCK_CW] LCK_COMPAT_CW, - [LCK_CR] LCK_COMPAT_CR, - [LCK_NL] LCK_COMPAT_NL, - [LCK_GROUP] LCK_COMPAT_GROUP, - [LCK_COS] LCK_COMPAT_COS, + [LCK_EX] = LCK_COMPAT_EX, + [LCK_PW] = LCK_COMPAT_PW, + [LCK_PR] = LCK_COMPAT_PR, + [LCK_CW] = LCK_COMPAT_CW, + [LCK_CR] = LCK_COMPAT_CR, + [LCK_NL] = LCK_COMPAT_NL, + [LCK_GROUP] = LCK_COMPAT_GROUP, + [LCK_COS] = LCK_COMPAT_COS, }; /** diff --git a/lustre/ldlm/ldlm_lock.c b/lustre/ldlm/ldlm_lock.c index a0a6755..33ada0a 100644 --- a/lustre/ldlm/ldlm_lock.c +++ b/lustre/ldlm/ldlm_lock.c @@ -53,45 +53,45 @@ /* lock types */ char *ldlm_lockname[] = { - [0] "--", - [LCK_EX] "EX", - [LCK_PW] "PW", - [LCK_PR] "PR", - [LCK_CW] "CW", - [LCK_CR] "CR", - [LCK_NL] "NL", - [LCK_GROUP] "GROUP", - [LCK_COS] "COS" + [0] = "--", + [LCK_EX] = "EX", + [LCK_PW] = "PW", + [LCK_PR] = "PR", + [LCK_CW] = "CW", + [LCK_CR] = "CR", + [LCK_NL] = "NL", + [LCK_GROUP] = "GROUP", + [LCK_COS] = "COS" }; EXPORT_SYMBOL(ldlm_lockname); char *ldlm_typename[] = { - [LDLM_PLAIN] "PLN", - [LDLM_EXTENT] "EXT", - [LDLM_FLOCK] "FLK", - [LDLM_IBITS] "IBT", + [LDLM_PLAIN] = "PLN", + [LDLM_EXTENT] = "EXT", + [LDLM_FLOCK] = "FLK", + [LDLM_IBITS] = "IBT", }; EXPORT_SYMBOL(ldlm_typename); static ldlm_policy_wire_to_local_t ldlm_policy_wire18_to_local[] = { - [LDLM_PLAIN - LDLM_MIN_TYPE] ldlm_plain_policy_wire_to_local, - [LDLM_EXTENT - LDLM_MIN_TYPE] ldlm_extent_policy_wire_to_local, - [LDLM_FLOCK - LDLM_MIN_TYPE] ldlm_flock_policy_wire18_to_local, - [LDLM_IBITS - LDLM_MIN_TYPE] ldlm_ibits_policy_wire_to_local, + [LDLM_PLAIN - LDLM_MIN_TYPE] = ldlm_plain_policy_wire_to_local, + [LDLM_EXTENT - LDLM_MIN_TYPE] = ldlm_extent_policy_wire_to_local, + [LDLM_FLOCK - LDLM_MIN_TYPE] = ldlm_flock_policy_wire18_to_local, + [LDLM_IBITS - LDLM_MIN_TYPE] = ldlm_ibits_policy_wire_to_local, }; static ldlm_policy_wire_to_local_t ldlm_policy_wire21_to_local[] = { - [LDLM_PLAIN - LDLM_MIN_TYPE] ldlm_plain_policy_wire_to_local, - [LDLM_EXTENT - LDLM_MIN_TYPE] ldlm_extent_policy_wire_to_local, - [LDLM_FLOCK - LDLM_MIN_TYPE] ldlm_flock_policy_wire21_to_local, - [LDLM_IBITS - LDLM_MIN_TYPE] ldlm_ibits_policy_wire_to_local, + [LDLM_PLAIN - LDLM_MIN_TYPE] = ldlm_plain_policy_wire_to_local, + [LDLM_EXTENT - LDLM_MIN_TYPE] = ldlm_extent_policy_wire_to_local, + [LDLM_FLOCK - LDLM_MIN_TYPE] = ldlm_flock_policy_wire21_to_local, + [LDLM_IBITS - LDLM_MIN_TYPE] = ldlm_ibits_policy_wire_to_local, }; static ldlm_policy_local_to_wire_t ldlm_policy_local_to_wire[] = { - [LDLM_PLAIN - LDLM_MIN_TYPE] ldlm_plain_policy_local_to_wire, - [LDLM_EXTENT - LDLM_MIN_TYPE] ldlm_extent_policy_local_to_wire, - [LDLM_FLOCK - LDLM_MIN_TYPE] ldlm_flock_policy_local_to_wire, - [LDLM_IBITS - LDLM_MIN_TYPE] ldlm_ibits_policy_local_to_wire, + [LDLM_PLAIN - LDLM_MIN_TYPE] = ldlm_plain_policy_local_to_wire, + [LDLM_EXTENT - LDLM_MIN_TYPE] = ldlm_extent_policy_local_to_wire, + [LDLM_FLOCK - LDLM_MIN_TYPE] = ldlm_flock_policy_local_to_wire, + [LDLM_IBITS - LDLM_MIN_TYPE] = ldlm_ibits_policy_local_to_wire, }; /** @@ -160,12 +160,12 @@ extern struct kmem_cache *ldlm_lock_slab; #ifdef HAVE_SERVER_SUPPORT static ldlm_processing_policy ldlm_processing_policy_table[] = { - [LDLM_PLAIN] ldlm_process_plain_lock, - [LDLM_EXTENT] ldlm_process_extent_lock, + [LDLM_PLAIN] = ldlm_process_plain_lock, + [LDLM_EXTENT] = ldlm_process_extent_lock, # ifdef __KERNEL__ - [LDLM_FLOCK] ldlm_process_flock_lock, + [LDLM_FLOCK] = ldlm_process_flock_lock, # endif - [LDLM_IBITS] ldlm_process_inodebits_lock, + [LDLM_IBITS] = ldlm_process_inodebits_lock, }; ldlm_processing_policy ldlm_get_processing_policy(struct ldlm_resource *res) diff --git a/lustre/ldlm/ldlm_request.c b/lustre/ldlm/ldlm_request.c index 59723ae..972083b 100644 --- a/lustre/ldlm/ldlm_request.c +++ b/lustre/ldlm/ldlm_request.c @@ -2081,7 +2081,7 @@ void ldlm_namespace_foreach(struct ldlm_namespace *ns, ldlm_iterator_t iter, void *closure) { - struct iter_helper_data helper = { iter: iter, closure: closure }; + struct iter_helper_data helper = { .iter = iter, .closure = closure }; cfs_hash_for_each_nolock(ns->ns_rs_hash, ldlm_res_iter_helper, &helper); diff --git a/lustre/liblustre/Makefile.am b/lustre/liblustre/Makefile.am index e0d75b1..7164155 100644 --- a/lustre/liblustre/Makefile.am +++ b/lustre/liblustre/Makefile.am @@ -1,7 +1,7 @@ ## Liblustre excecutables & libraries Makefile SUBDIRS = . tests -AM_CPPFLAGS = $(HAVE_EFENCE) -I$(SYSIO)/include -D_LARGEFILE64_SOURCE=1 \ +AM_CPPFLAGS = $(HAVE_EFENCE) -I$(SYSIO)/include \ $(LLCPPFLAGS) -I$(top_srcdir)/lnet/ulnds AM_CFLAGS = $(LLCFLAGS) diff --git a/lustre/liblustre/dir.c b/lustre/liblustre/dir.c index 5282eae..706cc74 100644 --- a/lustre/liblustre/dir.c +++ b/lustre/liblustre/dir.c @@ -146,8 +146,8 @@ static void *(*memmover)(void *, const void *, size_t) = memmove; static int filldir(char *buf, int buflen, const char *name, int namelen, loff_t offset, ino_t ino, unsigned int d_type, int *filled) { - struct dirent64 *dirent = (struct dirent64 *)(buf + *filled); - struct dirent64 holder; + struct intnl_dirent *dirent = (struct intnl_dirent *)(buf + *filled); + struct intnl_dirent holder; int reclen = ROUND_UP64(NAME_OFFSET(dirent) + namelen + 1); /* diff --git a/lustre/liblustre/genlib.sh b/lustre/liblustre/genlib.sh index ce5445a..023d630 100755 --- a/lustre/liblustre/genlib.sh +++ b/lustre/liblustre/genlib.sh @@ -39,7 +39,7 @@ rm -f liblustre.so ALL_OBJS= build_obj_list() { - _objs=`$AR -t $1/$2` + _objs=`$AR -t $1/$2 | grep -v SYMDEF | grep -v SORTED` for _lib in $_objs; do ALL_OBJS=$ALL_OBJS"$1/$_lib "; done; @@ -51,7 +51,7 @@ build_obj_list() { sysio_tmp=$CWD/sysio_tmp_`date +%s` rm -rf $sysio_tmp build_sysio_obj_list() { - _objs=`$AR -t $1` + _objs=`$AR -t $1 | grep -v SYMDEF | grep -v SORTED` mkdir -p $sysio_tmp cd $sysio_tmp $AR -x $1 diff --git a/lustre/lmv/lmv_fld.c b/lustre/lmv/lmv_fld.c index fc7f4bd..1874f17 100644 --- a/lustre/lmv/lmv_fld.c +++ b/lustre/lmv/lmv_fld.c @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include #else #include diff --git a/lustre/lmv/lmv_intent.c b/lustre/lmv/lmv_intent.c index 74cf0a1..09ee3b2 100644 --- a/lustre/lmv/lmv_intent.c +++ b/lustre/lmv/lmv_intent.c @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index 298d0db..035bb18 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include #include #else diff --git a/lustre/lov/lov_ea.c b/lustre/lov/lov_ea.c index dc06237..767eb2d 100644 --- a/lustre/lov/lov_ea.c +++ b/lustre/lov/lov_ea.c @@ -41,7 +41,7 @@ #define DEBUG_SUBSYSTEM S_LOV #ifdef __KERNEL__ -#include +#include #include #else #include diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index d8b508e..3a5432f 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -2256,7 +2256,7 @@ static int lov_quotactl(struct obd_device *obd, struct obd_export *exp, if (!tgt->ltd_active || tgt->ltd_reap) { if (oqctl->qc_cmd == Q_GETOQUOTA && lov->lov_tgts[i]->ltd_activate) { - rc = -EREMOTEIO; + rc = -ENETDOWN; CERROR("ost %d is inactive\n", i); } else { CDEBUG(D_HA, "ost %d is inactive\n", i); diff --git a/lustre/mdc/mdc_locks.c b/lustre/mdc/mdc_locks.c index b6ca65b..4fe9b0f 100644 --- a/lustre/mdc/mdc_locks.c +++ b/lustre/mdc/mdc_locks.c @@ -1167,7 +1167,7 @@ int mdc_intent_lock(struct obd_export *exp, struct md_op_data *op_data, LASSERT(it); CDEBUG(D_DLMTRACE, "(name: %.*s,"DFID") in obj "DFID - ", intent: %s flags %#Lo\n", op_data->op_namelen, + ", intent: %s flags %#"LPF64"o\n", op_data->op_namelen, op_data->op_name, PFID(&op_data->op_fid2), PFID(&op_data->op_fid1), ldlm_it2str(it->it_op), it->it_flags); @@ -1276,7 +1276,8 @@ int mdc_intent_getattr_async(struct obd_export *exp, __u64 flags = LDLM_FL_HAS_INTENT; ENTRY; - CDEBUG(D_DLMTRACE,"name: %.*s in inode "DFID", intent: %s flags %#Lo\n", + CDEBUG(D_DLMTRACE, "name: %.*s in inode "DFID", intent: %s flags %#" + LPF64"o\n", op_data->op_namelen, op_data->op_name, PFID(&op_data->op_fid1), ldlm_it2str(it->it_op), it->it_flags); diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index cae3942..5446045 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -3103,7 +3103,7 @@ static int mdc_resource_inode_free(struct ldlm_resource *res) } struct ldlm_valblock_ops inode_lvbo = { - lvbo_free: mdc_resource_inode_free + .lvbo_free = mdc_resource_inode_free }; static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg) diff --git a/lustre/obdclass/cl_lock.c b/lustre/obdclass/cl_lock.c index 8ac48d5..c1eedc9 100644 --- a/lustre/obdclass/cl_lock.c +++ b/lustre/obdclass/cl_lock.c @@ -41,6 +41,7 @@ #define DEBUG_SUBSYSTEM S_CLASS +#include #include #include #include @@ -2128,10 +2129,8 @@ const char *cl_lock_mode_name(const enum cl_lock_mode mode) [CLM_WRITE] = "W", [CLM_GROUP] = "G" }; - if (0 <= mode && mode < ARRAY_SIZE(names)) - return names[mode]; - else - return "U"; + CLASSERT(CLM_MAX == ARRAY_SIZE(names)); + return names[mode]; } EXPORT_SYMBOL(cl_lock_mode_name); diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index 9956ada..9527bb2 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -3281,7 +3281,7 @@ void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value) unsigned int val = 0; if (likely(value != 0)) - val = min(fls(value - 1), OBD_HIST_MAX); + val = min_t(unsigned int, __fls(value - 1), OBD_HIST_MAX); lprocfs_oh_tally(oh, val); } diff --git a/lustre/ofd/ofd_dev.c b/lustre/ofd/ofd_dev.c index 4cafa48..a27e4b0 100644 --- a/lustre/ofd/ofd_dev.c +++ b/lustre/ofd/ofd_dev.c @@ -2192,7 +2192,7 @@ static int ofd_init0(const struct lu_env *env, struct ofd_device *m, obd->obd_name, osfs->os_bsize); GOTO(err_fini_stack, rc = -EPROTO); } - m->ofd_blockbits = fls(osfs->os_bsize) - 1; + m->ofd_blockbits = __fls(osfs->os_bsize) - 1; m->ofd_precreate_batch = OFD_PRECREATE_BATCH_DEFAULT; if (osfs->os_bsize * osfs->os_blocks < OFD_PRECREATE_SMALL_FS) diff --git a/lustre/tests/conf-sanity.sh b/lustre/tests/conf-sanity.sh index 3b2370e..a2ede68 100644 --- a/lustre/tests/conf-sanity.sh +++ b/lustre/tests/conf-sanity.sh @@ -2320,7 +2320,7 @@ test_36() { # 12743 # different one than the default value here. add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \ --fsname=${FSNAME2} --reformat $fs2ostdev $fs2ostvdev || exit 10 - add fs3ost $(mkfs_opts ost1 ${fs3ostdev}) --mgsnode=$MGSNID \ + add fs3ost $(mkfs_opts ost2 ${fs3ostdev}) --mgsnode=$MGSNID \ --fsname=${FSNAME2} --reformat $fs3ostdev $fs3ostvdev || exit 10 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS diff --git a/lustre/utils/Makefile.am b/lustre/utils/Makefile.am index 0084056..d587b3b 100644 --- a/lustre/utils/Makefile.am +++ b/lustre/utils/Makefile.am @@ -15,9 +15,10 @@ LIBPTLCTL := $(top_builddir)/lnet/utils/libptlctl.a \ sbin_scripts = lrun bin_scripts = llstat llobdstat plot-llstat llbackup +EXTRA_PROGRAMS = wirecheck + if UTILS noinst_PROGRAMS = obdio obdbarrier -EXTRA_PROGRAMS = wirecheck # mount only finds helpers in /sbin rootsbin_PROGRAMS = mount.lustre @@ -39,6 +40,7 @@ if LDISKFS_ENABLED lib_LIBRARIES += libiam.a endif noinst_LIBRARIES = liblustreapitmp.a +endif # UTILS lctl_SOURCES = lustre_lfsck.c obd.c lustre_cfg.c lctl.c obdctl.h lctl_LDADD := liblustreapi.a $(LIBPTLCTL) $(PTHREAD_LIBS) $(LIBREADLINE) @@ -166,17 +168,16 @@ l_getidentity_LDADD := $(LIBPTLCTL) l_getidentity_DEPENDENCIES := $(LIBPTLCTL) ltrack_stats_SOURCES = ltrack_stats.c -endif # UTILS + +lhsmtool_posix_SOURCES = lhsmtool_posix.c +lhsmtool_posix_LDADD := liblustreapi.a $(PTHREAD_LIBS) +lhsmtool_posix_DEPENDENCIES := liblustreapi.a wirecheck_SOURCES = wirecheck.c wirecheck_CPPFLAGS = -DCC="\"$(CC)\"" wiretest_SOURCES = wiretest.c -lhsmtool_posix_SOURCES = lhsmtool_posix.c -lhsmtool_posix_LDADD := liblustreapi.a $(PTHREAD_LIBS) -lhsmtool_posix_DEPENDENCIES := liblustreapi.a - EXTRA_DIST = $(sbin_scripts) $(bin_scripts) # NOTE: this should only be run on i386. -- 1.8.3.1