Whamcloud - gitweb
LU-6245 libcfs: cleanup libcfs lock handling 93/13793/4
authorJames Simmons <uja.ornl@gmail.com>
Mon, 9 Mar 2015 20:53:41 +0000 (16:53 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 25 Mar 2015 23:59:08 +0000 (23:59 +0000)
Previously with libcfs being built for user land and kernel
space wrappers were created to transparently handle locking.
Now that user land support has been removed we delete all
those locking wrappers with this patch.

Signed-off-by: James Simmons <uja.ornl@gmail.com>
Change-Id: Icbd9b5c0918cb01202439416b220b6f327144a91
Reviewed-on: http://review.whamcloud.com/13793
Tested-by: Jenkins
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
15 files changed:
libcfs/include/libcfs/Makefile.am
libcfs/include/libcfs/libcfs.h
libcfs/include/libcfs/libcfs_private.h
libcfs/include/libcfs/linux/Makefile.am
libcfs/include/libcfs/linux/libcfs.h
libcfs/include/libcfs/linux/linux-lock.h [deleted file]
libcfs/include/libcfs/user-lock.h [deleted file]
libcfs/libcfs/fail.c
libcfs/libcfs/libcfs_lock.c
libcfs/libcfs/linux/linux-tracefile.c
libcfs/libcfs/module.c
libcfs/libcfs/tracefile.c
libcfs/libcfs/tracefile.h
lnet/lnet/acceptor.c
lustre/utils/lhsmtool_posix.c

index cdbf5e4..d4cf82e 100644 (file)
@@ -31,7 +31,6 @@ EXTRA_DIST = \
        types.h \
        user-bitops.h \
        user-crypto.h \
-       user-lock.h \
        user-mem.h \
        user-prim.h \
        user-time.h
index c82a3d9..5d36209 100644 (file)
@@ -65,7 +65,6 @@
 # include <libcfs/user-time.h>
 # include <libcfs/user-prim.h>
 # include <libcfs/user-mem.h>
-# include <libcfs/user-lock.h>
 # include <libcfs/user-bitops.h>
 #endif /* __KERNEL__ */
 
@@ -256,7 +255,9 @@ void cfs_get_random_bytes(void *buf, int size);
 #include <libcfs/libcfs_string.h>
 #include <libcfs/libcfs_kernelcomm.h>
 #include <libcfs/libcfs_workitem.h>
-#include <libcfs/libcfs_hash.h>
+#ifdef __KERNEL__
+# include <libcfs/libcfs_hash.h>
+#endif /* __KERNEL__ */
 #include <libcfs/libcfs_heap.h>
 #include <libcfs/libcfs_fail.h>
 
index 4114351..662630d 100644 (file)
@@ -471,26 +471,6 @@ struct cfs_percpt_lock {
 /* return number of private locks */
 #define cfs_percpt_lock_num(pcl)       cfs_cpt_number(pcl->pcl_cptab)
 
-#else /* !__KERNEL__ */
-
-# ifdef HAVE_LIBPTHREAD
-
-struct cfs_percpt_lock {
-       pthread_mutex_t         pcl_mutex;
-};
-
-# else /* !HAVE_LIBPTHREAD */
-
-struct cfs_percpt_lock {
-       int                     pcl_lock;
-};
-
-static const struct cfs_percpt_lock CFS_PERCPT_LOCK_MAGIC;
-
-# endif /* HAVE_LIBPTHREAD */
-# define cfs_percpt_lock_num(pcl)        1
-#endif /* __KERNEL__ */
-
 /*
  * create a cpu-partition lock based on CPU partition table \a cptab,
  * each private lock has extra \a psize bytes padding data
@@ -509,7 +489,7 @@ atomic_t **cfs_percpt_atomic_alloc(struct cfs_cpt_table *cptab, int val);
 void cfs_percpt_atomic_free(atomic_t **refs);
 /* return sum of all percpu refs */
 int cfs_percpt_atomic_summary(atomic_t **refs);
-
+#endif /* __KERNEL__ */
 
 /** Compile-time assertion.
 
index 240288c..d885f97 100644 (file)
@@ -1,2 +1,2 @@
-EXTRA_DIST = kp30.h libcfs.h linux-fs.h linux-lock.h linux-mem.h       \
+EXTRA_DIST = kp30.h libcfs.h linux-fs.h linux-mem.h    \
        linux-prim.h linux-time.h linux-cpu.h linux-crypto.h
index 6afd5db..b154471 100644 (file)
@@ -51,7 +51,6 @@
 #include <libcfs/linux/linux-time.h>
 #include <libcfs/linux/linux-mem.h>
 #include <libcfs/linux/linux-prim.h>
-#include <libcfs/linux/linux-lock.h>
 #include <libcfs/linux/linux-fs.h>
 #include <libcfs/linux/kp30.h>
 
diff --git a/libcfs/include/libcfs/linux/linux-lock.h b/libcfs/include/libcfs/linux/linux-lock.h
deleted file mode 100644 (file)
index 6f0b84d..0000000
+++ /dev/null
@@ -1,207 +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) 2008, 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/include/libcfs/linux/linux-lock.h
- *
- * Basic library routines.
- */
-
-#ifndef __LIBCFS_LINUX_CFS_LOCK_H__
-#define __LIBCFS_LINUX_CFS_LOCK_H__
-
-#ifndef __LIBCFS_LIBCFS_H__
-#error Do not #include this file directly. #include <libcfs/libcfs.h> instead
-#endif
-
-#ifndef __KERNEL__
-#error This include is only for kernel use.
-#endif
-
-#include <linux/mutex.h>
-
-/*
- * IMPORTANT !!!!!!!!
- *
- * All locks' declaration are not guaranteed to be initialized,
- * Althought some of they are initialized in Linux. All locks
- * declared by CFS_DECL_* should be initialized explicitly.
- */
-
-/*
- * spin_lock "implementation" (use Linux kernel's primitives)
- *
- * - spin_lock_init(x)
- * - spin_lock(x)
- * - spin_lock_bh(x)
- * - spin_lock_bh_init(x)
- * - spin_unlock(x)
- * - spin_unlock_bh(x)
- * - spin_trylock(x)
- * - assert_spin_locked(x)
- *
- * - spin_lock_irq(x)
- * - spin_lock_irqsave(x, f)
- * - spin_unlock_irqrestore(x, f)
- * - read_lock_irqsave(lock, f)
- * - write_lock_irqsave(lock, f)
- * - write_unlock_irqrestore(lock, f)
- */
-
-/*
- * spinlock "implementation"
- */
-
-
-
-
-/*
- * rw_semaphore "implementation" (use Linux kernel's primitives)
- *
- * - sema_init(x)
- * - init_rwsem(x)
- * - down_read(x)
- * - up_read(x)
- * - down_write(x)
- * - up_write(x)
- */
-
-
-#define fini_rwsem(s)          do {} while (0)
-
-
-/*
- * rwlock_t "implementation" (use Linux kernel's primitives)
- *
- * - rwlock_init(x)
- * - read_lock(x)
- * - read_unlock(x)
- * - write_lock(x)
- * - write_unlock(x)
- * - write_lock_bh(x)
- * - write_unlock_bh(x)
- *
- * - RW_LOCK_UNLOCKED
- */
-
-
-#ifndef DEFINE_RWLOCK
-#define DEFINE_RWLOCK(lock)    rwlock_t lock = __RW_LOCK_UNLOCKED(lock)
-#endif
-
-/*
- * completion "implementation" (use Linux kernel's primitives)
- *
- * - DECLARE_COMPLETION(work)
- * - INIT_COMPLETION(c)
- * - COMPLETION_INITIALIZER(work)
- * - init_completion(c)
- * - complete(c)
- * - wait_for_completion(c)
- * - wait_for_completion_interruptible(c)
- * - fini_completion(c)
- */
-#define fini_completion(c) do { } while (0)
-
-/*
- * semaphore "implementation" (use Linux kernel's primitives)
- * - DEFINE_SEMAPHORE(name)
- * - sema_init(sem, val)
- * - up(sem)
- * - down(sem)
- * - down_interruptible(sem)
- * - down_trylock(sem)
- */
-
-/*
- * mutex "implementation" (use Linux kernel's primitives)
- *
- * - DEFINE_MUTEX(name)
- * - mutex_init(x)
- * - mutex_lock(x)
- * - mutex_unlock(x)
- * - mutex_trylock(x)
- * - mutex_is_locked(x)
- * - mutex_destroy(x)
- */
-
-#ifndef lockdep_set_class
-
-/**************************************************************************
- *
- * Lockdep "implementation". Also see liblustre.h
- *
- **************************************************************************/
-
-struct lock_class_key {
-       ;
-};
-
-#define lockdep_set_class(lock, key) \
-       do { (void)sizeof(lock); (void)sizeof(key); } while (0)
-/* This has to be a macro, so that `subclass' can be undefined in kernels
- * that do not support lockdep. */
-
-
-static inline void lockdep_off(void)
-{
-}
-
-static inline void lockdep_on(void)
-{
-}
-#else
-
-#endif /* lockdep_set_class */
-
-#ifndef CONFIG_DEBUG_LOCK_ALLOC
-#ifndef mutex_lock_nested
-#define mutex_lock_nested(mutex, subclass) mutex_lock(mutex)
-#endif
-
-#ifndef spin_lock_nested
-#define spin_lock_nested(lock, subclass) spin_lock(lock)
-#endif
-
-#ifndef down_read_nested
-#define down_read_nested(lock, subclass) down_read(lock)
-#endif
-
-#ifndef down_write_nested
-#define down_write_nested(lock, subclass) down_write(lock)
-#endif
-#endif /* CONFIG_DEBUG_LOCK_ALLOC */
-
-
-#endif /* __LIBCFS_LINUX_CFS_LOCK_H__ */
diff --git a/libcfs/include/libcfs/user-lock.h b/libcfs/include/libcfs/user-lock.h
deleted file mode 100644 (file)
index 8b2a365..0000000
+++ /dev/null
@@ -1,420 +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) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2012, 2013, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/include/libcfs/user-lock.h
- *
- * Author: Nikita Danilov <nikita@clusterfs.com>
- */
-
-#ifndef __LIBCFS_USER_LOCK_H__
-#define __LIBCFS_USER_LOCK_H__
-
-#ifndef __LIBCFS_LIBCFS_H__
-#error Do not #include this file directly. #include <libcfs/libcfs.h> instead
-#endif
-
-/* Implementations of portable synchronization APIs for liblustre */
-
-/*
- * liblustre is single-threaded, so most "synchronization" APIs are trivial.
- *
- * XXX Liang: There are several branches share lnet with b_hd_newconfig,
- * if we define lock APIs at here, there will be conflict with liblustre
- * in other branches.
- */
-
-#ifndef __KERNEL__
-
-/*
- * The userspace implementations of linux/spinlock.h vary; we just
- * include our own for all of them
- */
-#define __LINUX_SPINLOCK_H
-
-/*
- * Optional debugging (magic stamping and checking ownership) can be added.
- */
-
-/*
- * spin_lock
- *
- * - spin_lock_init(x)
- * - spin_lock(x)
- * - spin_unlock(x)
- * - spin_trylock(x)
- * - spin_lock_bh_init(x)
- * - spin_lock_bh(x)
- * - spin_unlock_bh(x)
- *
- * - assert_spin_locked(x)
- * - spin_lock_irqsave(x, f)
- * - spin_unlock_irqrestore(x, f)
- *
- * No-op implementation.
- */
-struct spin_lock { int foo; };
-
-typedef struct spin_lock spinlock_t;
-
-#define DEFINE_SPINLOCK(lock)          spinlock_t lock = { }
-#define __SPIN_LOCK_UNLOCKED(x)                ((spinlock_t) {})
-
-void spin_lock_init(spinlock_t *lock);
-void spin_lock(spinlock_t *lock);
-void spin_unlock(spinlock_t *lock);
-int  spin_trylock(spinlock_t *lock);
-void spin_lock_bh_init(spinlock_t *lock);
-void spin_lock_bh(spinlock_t *lock);
-void spin_unlock_bh(spinlock_t *lock);
-
-static inline void spin_lock_irqsave(spinlock_t *l, unsigned long f) {}
-static inline void spin_unlock_irqrestore(spinlock_t *l, unsigned long f) {}
-
-#define assert_spin_locked(lock)       do { (void)(lock); } while (0)
-
-/*
- * Semaphore
- *
- * - sema_init(x, v)
- * - __down(x)
- * - __up(x)
- */
-struct semaphore {
-       int foo;
-};
-
-void sema_init(struct semaphore *s, int val);
-void __up(struct semaphore *s);
-void __down(struct semaphore *s);
-int __down_interruptible(struct semaphore *s);
-
-#define DEFINE_SEMAPHORE(name)      struct semaphore name = { 1 }
-
-#define up(s)                          __up(s)
-#define down(s)                        __down(s)
-#define down_interruptible(s)          __down_interruptible(s)
-
-static inline int down_trylock(struct semaphore *sem)
-{
-        return 0;
-}
-
-/*
- * Completion:
- *
- * - init_completion_module(c)
- * - call_wait_handler(t)
- * - init_completion(c)
- * - complete(c)
- * - wait_for_completion(c)
- * - wait_for_completion_interruptible(c)
- */
-#ifdef HAVE_LIBPTHREAD
-#include <pthread.h>
-
-/*
- * Multi-threaded user space completion APIs
- */
-
-struct completion {
-       int             c_done;
-       pthread_cond_t  c_cond;
-       pthread_mutex_t c_mut;
-};
-
-#else /* !HAVE_LIBPTHREAD */
-
-struct completion {
-       unsigned int    done;
-       wait_queue_head_t       wait;
-};
-#endif /* HAVE_LIBPTHREAD */
-
-typedef int (*wait_handler_t) (int timeout);
-void init_completion_module(wait_handler_t handler);
-int  call_wait_handler(int timeout);
-void init_completion(struct completion *c);
-void fini_completion(struct completion *c);
-void complete(struct completion *c);
-void wait_for_completion(struct completion *c);
-int wait_for_completion_interruptible(struct completion *c);
-
-#define COMPLETION_INITIALIZER(work) \
-       { 0, __WAIT_QUEUE_HEAD_INITIALIZER((work).wait) }
-
-
-#define INIT_COMPLETION(x)     ((x).done = 0)
-
-
-/*
- * rw_semaphore:
- *
- * - init_rwsem(x)
- * - down_read(x)
- * - down_read_trylock(x)
- * - down_write(struct rw_semaphore *s);
- * - down_write_trylock(struct rw_semaphore *s);
- * - up_read(x)
- * - up_write(x)
- * - fini_rwsem(x)
- */
-struct rw_semaphore {
-       int foo;
-};
-
-void init_rwsem(struct rw_semaphore *s);
-void down_read(struct rw_semaphore *s);
-int down_read_trylock(struct rw_semaphore *s);
-void down_write(struct rw_semaphore *s);
-void downgrade_write(struct rw_semaphore *s);
-int down_write_trylock(struct rw_semaphore *s);
-void up_read(struct rw_semaphore *s);
-void up_write(struct rw_semaphore *s);
-void fini_rwsem(struct rw_semaphore *s);
-#define DECLARE_RWSEM(name)  struct rw_semaphore name = { }
-
-/*
- * read-write lock : Need to be investigated more!!
- * XXX nikita: for now, let rwlock_t to be identical to rw_semaphore
- *
- * - rwlock_init(x)
- * - read_lock(x)
- * - read_unlock(x)
- * - write_lock(x)
- * - write_unlock(x)
- * - write_lock_irqsave(x)
- * - write_unlock_irqrestore(x)
- * - read_lock_irqsave(x)
- * - read_unlock_irqrestore(x)
- */
-#define rwlock_t               struct rw_semaphore
-#define DEFINE_RWLOCK(lock)    rwlock_t lock = { }
-
-#define rwlock_init(pl)                init_rwsem(pl)
-
-#define read_lock(l)           down_read(l)
-#define read_unlock(l)         up_read(l)
-#define write_lock(l)          down_write(l)
-#define write_unlock(l)                up_write(l)
-
-static inline void write_lock_irqsave(rwlock_t *l, unsigned long f)
-{
-       write_lock(l);
-}
-
-static inline void write_unlock_irqrestore(rwlock_t *l, unsigned long f)
-{
-       write_unlock(l);
-}
-
-static inline void read_lock_irqsave(rwlock_t *l, unsigned long f)
-{
-       read_lock(l);
-}
-
-static inline void read_unlock_irqrestore(rwlock_t *l, unsigned long f)
-{
-       read_unlock(l);
-}
-
-/*
- * Atomic for single-threaded user-space
- */
-typedef struct { volatile int counter; } atomic_t;
-
-#define ATOMIC_INIT(i) { (i) }
-
-#define atomic_read(a) ((a)->counter)
-#define atomic_set(a,b) do {(a)->counter = b; } while (0)
-#define atomic_dec_and_test(a) ((--((a)->counter)) == 0)
-#define atomic_dec_and_lock(a,b) ((--((a)->counter)) == 0)
-#define atomic_inc(a)  (((a)->counter)++)
-#define atomic_dec(a)  do { (a)->counter--; } while (0)
-#define atomic_add(b,a)  do {(a)->counter += b;} while (0)
-#define atomic_add_return(n,a) ((a)->counter += n)
-#define atomic_inc_return(a) atomic_add_return(1,a)
-#define atomic_sub(b,a)  do {(a)->counter -= b;} while (0)
-#define atomic_sub_return(n,a) ((a)->counter -= n)
-#define atomic_dec_return(a)  atomic_sub_return(1,a)
-#define atomic_add_unless(v, a, u) \
-        ((v)->counter != u ? (v)->counter += a : 0)
-#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
-#define atomic_cmpxchg(v, ov, nv) \
-       ((v)->counter == ov ? ((v)->counter = nv, ov) : (v)->counter)
-
-typedef struct { volatile long counter; } atomic_long_t;
-
-#define ATOMIC_LONG_INIT(i) { (i) }
-
-#define atomic_long_read(a) ((a)->counter)
-#define atomic_long_set(a, b) do {(a)->counter = b; } while (0)
-#define atomic_long_dec_and_test(a) ((--((a)->counter)) == 0)
-#define atomic_long_dec_and_lock(a, b) ((--((a)->counter)) == 0)
-#define atomic_long_inc(a)  (((a)->counter)++)
-#define atomic_long_dec(a)  do { (a)->counter--; } while (0)
-#define atomic_long_add(b, a)  do {(a)->counter += b; } while (0)
-#define atomic_long_add_return(n, a) ((a)->counter += n)
-#define atomic_long_inc_return(a) atomic_long_add_return(1, a)
-#define atomic_long_sub(b, a)  do {(a)->counter -= b; } while (0)
-#define atomic_long_sub_return(n, a) ((a)->counter -= n)
-#define atomic_long_dec_return(a)  atomic_long_sub_return(1, a)
-#define atomic_long_add_unless(v, a, u) \
-       ((v)->counter != u ? (v)->counter += a : 0)
-#define atomic_long_inc_not_zero(v) atomic_long_add_unless((v), 1, 0)
-#define atomic_long_cmpxchg(v, ov, nv) \
-       ((v)->counter == ov ? ((v)->counter = nv, ov) : (v)->counter)
-
-#ifdef HAVE_LIBPTHREAD
-#include <pthread.h>
-
-/*
- * Multi-threaded user space atomic APIs
- */
-
-typedef struct { volatile int counter; } mt_atomic_t;
-
-int mt_atomic_read(mt_atomic_t *a);
-void mt_atomic_set(mt_atomic_t *a, int b);
-int mt_atomic_dec_and_test(mt_atomic_t *a);
-void mt_atomic_inc(mt_atomic_t *a);
-void mt_atomic_dec(mt_atomic_t *a);
-void mt_atomic_add(int b, mt_atomic_t *a);
-void mt_atomic_sub(int b, mt_atomic_t *a);
-
-#endif /* HAVE_LIBPTHREAD */
-
-/**************************************************************************
- *
- * Mutex interface.
- *
- **************************************************************************/
-#define mutex semaphore
-
-#define DEFINE_MUTEX(m) DEFINE_SEMAPHORE(m)
-
-static inline void mutex_init(struct mutex *mutex)
-{
-       sema_init(mutex, 1);
-}
-
-static inline void mutex_lock(struct mutex *mutex)
-{
-       down(mutex);
-}
-
-static inline void mutex_unlock(struct mutex *mutex)
-{
-       up(mutex);
-}
-
-static inline int mutex_lock_interruptible(struct mutex *mutex)
-{
-       return down_interruptible(mutex);
-}
-
-/**
- * Try-lock this mutex.
- *
- * Note, return values are negation of what is expected from down_trylock() or
- * pthread_mutex_trylock().
- *
- * \retval 1 try-lock succeeded (lock acquired).
- * \retval 0 indicates lock contention.
- */
-static inline int mutex_trylock(struct mutex *mutex)
-{
-       return !down_trylock(mutex);
-}
-
-static inline void mutex_destroy(struct mutex *lock)
-{
-}
-
-/*
- * This is for use in assertions _only_, i.e., this function should always
- * return 1.
- *
- * \retval 1 mutex is locked.
- *
- * \retval 0 mutex is not locked. This should never happen.
- */
-static inline int mutex_is_locked(struct mutex *lock)
-{
-        return 1;
-}
-
-
-/**************************************************************************
- *
- * Lockdep "implementation". Also see lustre_compat25.h
- *
- **************************************************************************/
-
-struct lock_class_key {
-        int foo;
-};
-
-static inline void lockdep_set_class(void *lock, struct lock_class_key *key)
-{
-}
-
-static inline void lockdep_off(void)
-{
-}
-
-static inline void lockdep_on(void)
-{
-}
-
-#define mutex_lock_nested(mutex, subclass) mutex_lock(mutex)
-#define spin_lock_nested(lock, subclass) spin_lock(lock)
-#define down_read_nested(lock, subclass) down_read(lock)
-#define down_write_nested(lock, subclass) down_write(lock)
-
-
-/* !__KERNEL__ */
-#endif
-
-/* __LIBCFS_USER_LOCK_H__ */
-#endif
-/*
- * Local variables:
- * c-indentation-style: "K&R"
- * c-basic-offset: 8
- * tab-width: 8
- * fill-column: 80
- * scroll-step: 1
- * End:
- */
index af8784d..01bd133 100644 (file)
@@ -38,7 +38,7 @@
 unsigned long cfs_fail_loc = 0;
 unsigned int cfs_fail_val = 0;
 int cfs_fail_err;
-wait_queue_head_t cfs_race_waitq;
+DECLARE_WAIT_QUEUE_HEAD(cfs_race_waitq);
 int cfs_race_state;
 
 EXPORT_SYMBOL(cfs_fail_loc);
index f979f6f..747337f 100644 (file)
@@ -34,8 +34,6 @@
 
 #include <libcfs/libcfs.h>
 
-#ifdef __KERNEL__
-
 /** destroy cpu-partition lock, see libcfs_private.h for more detail */
 void
 cfs_percpt_lock_free(struct cfs_percpt_lock *pcl)
@@ -149,69 +147,6 @@ __releases(pcl->pcl_locks)
 }
 EXPORT_SYMBOL(cfs_percpt_unlock);
 
-#else /* !__KERNEL__ */
-# ifdef HAVE_LIBPTHREAD
-
-struct cfs_percpt_lock *
-cfs_percpt_lock_alloc(struct cfs_cpt_table *cptab)
-{
-       struct cfs_percpt_lock *pcl;
-
-       CFS_ALLOC_PTR(pcl);
-       if (pcl != NULL)
-               pthread_mutex_init(&pcl->pcl_mutex, NULL);
-
-       return pcl;
-}
-
-void
-cfs_percpt_lock_free(struct cfs_percpt_lock *pcl)
-{
-       pthread_mutex_destroy(&pcl->pcl_mutex);
-       CFS_FREE_PTR(pcl);
-}
-
-void
-cfs_percpt_lock(struct cfs_percpt_lock *pcl, int lock)
-{
-       pthread_mutex_lock(&(pcl)->pcl_mutex);
-}
-
-void
-cfs_percpt_unlock(struct cfs_percpt_lock *pcl, int lock)
-{
-       pthread_mutex_unlock(&(pcl)->pcl_mutex);
-}
-
-# else /* !HAVE_LIBPTHREAD */
-
-struct cfs_percpt_lock *
-cfs_percpt_lock_alloc(struct cfs_cpt_table *cptab)
-{
-       return ((struct cfs_percpt_lock *) &CFS_PERCPT_LOCK_MAGIC);
-}
-
-void
-cfs_percpt_lock_free(struct cfs_percpt_lock *pcl)
-{
-       LASSERT(pcl == (struct cfs_percpt_lock *) &CFS_PERCPT_LOCK_MAGIC);
-}
-
-void
-cfs_percpt_lock(struct cfs_percpt_lock *pcl, int index)
-{
-       LASSERT(pcl == (struct cfs_percpt_lock *) &CFS_PERCPT_LOCK_MAGIC);
-}
-
-void
-cfs_percpt_unlock(struct cfs_percpt_lock *pcl, int index)
-{
-       LASSERT(pcl == (struct cfs_percpt_lock *) &CFS_PERCPT_LOCK_MAGIC);
-}
-
-# endif /* HAVE_LIBPTHREAD */
-#endif /* __KERNEL__ */
-
 /** free cpu-partition refcount */
 void
 cfs_percpt_atomic_free(atomic_t **refs)
index 294a34e..778a56f 100644 (file)
@@ -49,7 +49,7 @@ static unsigned int pages_factor[CFS_TCD_TYPE_MAX] = {
 
 char *cfs_trace_console_buffers[NR_CPUS][CFS_TCD_TYPE_MAX];
 
-struct rw_semaphore cfs_tracefile_sem;
+static DECLARE_RWSEM(cfs_tracefile_sem);
 
 int cfs_tracefile_init_arch()
 {
@@ -57,8 +57,6 @@ int cfs_tracefile_init_arch()
        int    j;
        struct cfs_trace_cpu_data *tcd;
 
-       init_rwsem(&cfs_tracefile_sem);
-
        /* initialize trace_data */
        memset(cfs_trace_data, 0, sizeof(cfs_trace_data));
        for (i = 0; i < CFS_TCD_TYPE_MAX; i++) {
@@ -112,8 +110,6 @@ void cfs_tracefile_fini_arch()
                kfree(cfs_trace_data[i]);
                cfs_trace_data[i] = NULL;
        }
-
-       fini_rwsem(&cfs_tracefile_sem);
 }
 
 void cfs_tracefile_read_lock()
index 11d1eda..e284384 100644 (file)
@@ -42,7 +42,6 @@
 #include <lnet/lib-dlc.h>
 #include <lnet/lnet.h>
 #include <lnet/nidstr.h>
-#include "tracefile.h"
 
 static void
 kportal_memhog_free (struct libcfs_device_userstate *ldu)
@@ -187,8 +186,8 @@ static int libcfs_psdev_release(unsigned long flags, void *args)
        RETURN(0);
 }
 
-static struct rw_semaphore ioctl_list_sem;
-static struct list_head ioctl_list;
+static DECLARE_RWSEM(ioctl_list_sem);
+static LIST_HEAD(ioctl_list);
 
 int libcfs_register_ioctl(struct libcfs_ioctl_handler *hand)
 {
@@ -319,11 +318,6 @@ static int init_libcfs_module(void)
 
        libcfs_arch_init();
        libcfs_init_nidstrings();
-       init_rwsem(&cfs_tracefile_sem);
-       mutex_init(&cfs_trace_thread_mutex);
-       init_rwsem(&ioctl_list_sem);
-       INIT_LIST_HEAD(&ioctl_list);
-       init_waitqueue_head(&cfs_race_waitq);
 
        rc = libcfs_debug_init(5 * 1024 * 1024);
        if (rc < 0) {
@@ -416,9 +410,6 @@ static void exit_libcfs_module(void)
                printk(KERN_ERR "LustreError: libcfs_debug_cleanup: %d\n",
                       rc);
 
-       fini_rwsem(&ioctl_list_sem);
-       fini_rwsem(&cfs_tracefile_sem);
-
        libcfs_arch_cleanup();
 }
 
index 7698165..8170f34 100644 (file)
@@ -52,7 +52,7 @@ union cfs_trace_data_union (*cfs_trace_data[TCD_MAX_TYPES])[NR_CPUS] __cacheline
 char cfs_tracefile[TRACEFILE_NAME_SIZE];
 long long cfs_tracefile_size = CFS_TRACEFILE_SIZE;
 static struct tracefiled_ctl trace_tctl;
-struct mutex cfs_trace_thread_mutex;
+static DEFINE_MUTEX(cfs_trace_thread_mutex);
 static int thread_running = 0;
 
 static atomic_t cfs_tage_allocated = ATOMIC_INIT(0);
index d59734a..d189295 100644 (file)
@@ -97,9 +97,6 @@ extern void libcfs_unregister_panic_notifier(void);
 extern int  libcfs_panic_in_progress;
 extern int  cfs_trace_max_debug_mb(void);
 
-extern struct mutex cfs_trace_thread_mutex;
-extern struct rw_semaphore cfs_tracefile_sem;
-
 #define TCD_MAX_PAGES (5 << (20 - PAGE_CACHE_SHIFT))
 #define TCD_STOCK_PAGES (TCD_MAX_PAGES)
 #define CFS_TRACEFILE_SIZE (500 << 20)
index 0c735f4..6c0115c 100644 (file)
@@ -35,6 +35,7 @@
  */
 
 #define DEBUG_SUBSYSTEM S_LNET
+#include <linux/completion.h>
 #include <lnet/lib-lnet.h>
 
 static int   accept_port    = 988;
@@ -473,10 +474,8 @@ lnet_acceptor_start(void)
 
        init_completion(&lnet_acceptor_state.pta_signal);
        rc = accept2secure(accept_type, &secure);
-       if (rc <= 0) {
-               fini_completion(&lnet_acceptor_state.pta_signal);
+       if (rc <= 0)
                return rc;
-       }
 
        if (lnet_count_acceptor_nis() == 0)  /* not required */
                return 0;
@@ -486,7 +485,6 @@ lnet_acceptor_start(void)
        if (IS_ERR(task)) {
                rc2 = PTR_ERR(task);
                CERROR("Can't start acceptor thread: %ld\n", rc2);
-               fini_completion(&lnet_acceptor_state.pta_signal);
 
                return -ESRCH;
        }
@@ -501,7 +499,6 @@ lnet_acceptor_start(void)
        }
 
        LASSERT(lnet_acceptor_state.pta_sock == NULL);
-       fini_completion(&lnet_acceptor_state.pta_signal);
 
        return -ENETDOWN;
 }
@@ -517,6 +514,4 @@ lnet_acceptor_stop(void)
 
        /* block until acceptor signals exit */
        wait_for_completion(&lnet_acceptor_state.pta_signal);
-
-       fini_completion(&lnet_acceptor_state.pta_signal);
 }
index 0442d55..d1fc084 100644 (file)
@@ -43,6 +43,7 @@
 #include <dirent.h>
 #include <errno.h>
 #include <getopt.h>
+#include <pthread.h>
 #include <time.h>
 #include <utime.h>
 #include <sys/time.h>