Whamcloud - gitweb
git://git.whamcloud.com
/
fs
/
lustre-release.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
LU-3306 mdt: Do not LBUG on double set of err_serious
[fs/lustre-release.git]
/
libcfs
/
libcfs
/
user-lock.c
diff --git
a/libcfs/libcfs/user-lock.c
b/libcfs/libcfs/user-lock.c
index
b01319f
..
214ca3a
100644
(file)
--- a/
libcfs/libcfs/user-lock.c
+++ b/
libcfs/libcfs/user-lock.c
@@
-1,6
+1,4
@@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
* GPL HEADER START
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* GPL HEADER START
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@
-26,8
+24,10
@@
* GPL HEADER END
*/
/*
* GPL HEADER END
*/
/*
- * Copyright
2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright
(c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
* Use is subject to license terms.
+ *
+ * Copyright (c) 2012, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
*/
/*
* This file is part of Lustre, http://www.lustre.org/
@@
-73,48
+73,42
@@
void spin_lock_init(spinlock_t *lock)
{
void spin_lock_init(spinlock_t *lock)
{
-
LASSERT(lock != NULL);
-
(void)lock;
+ LASSERT(lock != NULL);
+ (void)lock;
}
void spin_lock(spinlock_t *lock)
{
}
void spin_lock(spinlock_t *lock)
{
- (void)lock;
-}
-
-void spin_lock_nested(spinlock_t *lock, unsigned int subclass)
-{
- (void)lock;
- (void)subclass;
+ (void)lock;
}
void spin_unlock(spinlock_t *lock)
{
}
void spin_unlock(spinlock_t *lock)
{
-
(void)lock;
+ (void)lock;
}
int spin_trylock(spinlock_t *lock)
{
}
int spin_trylock(spinlock_t *lock)
{
-
(void)lock;
+ (void)lock;
return 1;
}
void spin_lock_bh_init(spinlock_t *lock)
{
return 1;
}
void spin_lock_bh_init(spinlock_t *lock)
{
-
LASSERT(lock != NULL);
-
(void)lock;
+ LASSERT(lock != NULL);
+ (void)lock;
}
void spin_lock_bh(spinlock_t *lock)
{
}
void spin_lock_bh(spinlock_t *lock)
{
-
LASSERT(lock != NULL);
-
(void)lock;
+ LASSERT(lock != NULL);
+ (void)lock;
}
void spin_unlock_bh(spinlock_t *lock)
{
}
void spin_unlock_bh(spinlock_t *lock)
{
-
LASSERT(lock != NULL);
-
(void)lock;
+ LASSERT(lock != NULL);
+ (void)lock;
}
/*
}
/*
@@
-127,21
+121,28
@@
void spin_unlock_bh(spinlock_t *lock)
void sema_init(struct semaphore *s, int val)
{
void sema_init(struct semaphore *s, int val)
{
-
LASSERT(s != NULL);
-
(void)s;
-
(void)val;
+ LASSERT(s != NULL);
+ (void)s;
+ (void)val;
}
void __down(struct semaphore *s)
{
}
void __down(struct semaphore *s)
{
- LASSERT(s != NULL);
- (void)s;
+ LASSERT(s != NULL);
+ (void)s;
+}
+
+int __down_interruptible(struct semaphore *s)
+{
+ LASSERT(s != NULL);
+ (void)s;
+ return 0;
}
void __up(struct semaphore *s)
{
}
void __up(struct semaphore *s)
{
-
LASSERT(s != NULL);
-
(void)s;
+ LASSERT(s != NULL);
+ (void)s;
}
}
@@
-152,31
+153,58
@@
void __up(struct semaphore *s)
* - complete(c)
* - wait_for_completion(c)
*/
* - complete(c)
* - wait_for_completion(c)
*/
+static wait_handler_t wait_handler;
+
+void init_completion_module(wait_handler_t handler)
+{
+ wait_handler = handler;
+}
+
+int call_wait_handler(int timeout)
+{
+ if (!wait_handler)
+ return -ENOSYS;
+ return wait_handler(timeout);
+}
+#ifndef HAVE_LIBPTHREAD
void init_completion(struct completion *c)
{
void init_completion(struct completion *c)
{
- LASSERT(c != NULL);
- c->done = 0;
- cfs_waitq_init(&c->wait);
+ LASSERT(c != NULL);
+ c->done = 0;
+ cfs_waitq_init(&c->wait);
+}
+
+void fini_completion(struct completion *c)
+{
}
void complete(struct completion *c)
{
}
void complete(struct completion *c)
{
-
LASSERT(c != NULL);
-
c->done = 1;
-
cfs_waitq_signal(&c->wait);
+ LASSERT(c != NULL);
+ c->done = 1;
+ cfs_waitq_signal(&c->wait);
}
void wait_for_completion(struct completion *c)
{
}
void wait_for_completion(struct completion *c)
{
- LASSERT(c != NULL);
+ LASSERT(c != NULL);
+ do {
+ if (call_wait_handler(1000) < 0)
+ break;
+ } while (c->done == 0);
}
int wait_for_completion_interruptible(struct completion *c)
{
}
int wait_for_completion_interruptible(struct completion *c)
{
- LASSERT(c != NULL);
- return 0;
+ LASSERT(c != NULL);
+ do {
+ if (call_wait_handler(1000) < 0)
+ break;
+ } while (c->done == 0);
+ return 0;
}
}
+#endif /* HAVE_LIBPTHREAD */
/*
* rw_semaphore:
/*
* rw_semaphore:
@@
-191,55
+219,61
@@
int wait_for_completion_interruptible(struct completion *c)
void init_rwsem(struct rw_semaphore *s)
{
void init_rwsem(struct rw_semaphore *s)
{
-
LASSERT(s != NULL);
-
(void)s;
+ LASSERT(s != NULL);
+ (void)s;
}
void down_read(struct rw_semaphore *s)
{
}
void down_read(struct rw_semaphore *s)
{
-
LASSERT(s != NULL);
-
(void)s;
+ LASSERT(s != NULL);
+ (void)s;
}
int down_read_trylock(struct rw_semaphore *s)
{
}
int down_read_trylock(struct rw_semaphore *s)
{
-
LASSERT(s != NULL);
-
(void)s;
+ LASSERT(s != NULL);
+ (void)s;
return 1;
}
void down_write(struct rw_semaphore *s)
{
return 1;
}
void down_write(struct rw_semaphore *s)
{
-
LASSERT(s != NULL);
-
(void)s;
+ LASSERT(s != NULL);
+ (void)s;
}
int down_write_trylock(struct rw_semaphore *s)
{
}
int down_write_trylock(struct rw_semaphore *s)
{
-
LASSERT(s != NULL);
-
(void)s;
+ LASSERT(s != NULL);
+ (void)s;
return 1;
}
void up_read(struct rw_semaphore *s)
{
return 1;
}
void up_read(struct rw_semaphore *s)
{
-
LASSERT(s != NULL);
-
(void)s;
+ LASSERT(s != NULL);
+ (void)s;
}
void up_write(struct rw_semaphore *s)
{
}
void up_write(struct rw_semaphore *s)
{
- LASSERT(s != NULL);
- (void)s;
+ LASSERT(s != NULL);
+ (void)s;
+}
+
+void fini_rwsem(struct rw_semaphore *s)
+{
+ LASSERT(s != NULL);
+ (void)s;
}
#ifdef HAVE_LIBPTHREAD
/*
}
#ifdef HAVE_LIBPTHREAD
/*
- *
C
ompletion
+ *
Multi-threaded user space c
ompletion
*/
*/
-void
cfs_init_completion(struct cfs_
completion *c)
+void
init_completion(struct
completion *c)
{
LASSERT(c != NULL);
c->c_done = 0;
{
LASSERT(c != NULL);
c->c_done = 0;
@@
-247,14
+281,14
@@
void cfs_init_completion(struct cfs_completion *c)
pthread_cond_init(&c->c_cond, NULL);
}
pthread_cond_init(&c->c_cond, NULL);
}
-void
cfs_fini_completion(struct cfs_
completion *c)
+void
fini_completion(struct
completion *c)
{
LASSERT(c != NULL);
pthread_mutex_destroy(&c->c_mut);
pthread_cond_destroy(&c->c_cond);
}
{
LASSERT(c != NULL);
pthread_mutex_destroy(&c->c_mut);
pthread_cond_destroy(&c->c_cond);
}
-void c
fs_complete(struct cfs_
completion *c)
+void c
omplete(struct
completion *c)
{
LASSERT(c != NULL);
pthread_mutex_lock(&c->c_mut);
{
LASSERT(c != NULL);
pthread_mutex_lock(&c->c_mut);
@@
-263,7
+297,7
@@
void cfs_complete(struct cfs_completion *c)
pthread_mutex_unlock(&c->c_mut);
}
pthread_mutex_unlock(&c->c_mut);
}
-void
cfs_wait_for_completion(struct cfs_
completion *c)
+void
wait_for_completion(struct
completion *c)
{
LASSERT(c != NULL);
pthread_mutex_lock(&c->c_mut);
{
LASSERT(c != NULL);
pthread_mutex_lock(&c->c_mut);
@@
-274,12
+308,12
@@
void cfs_wait_for_completion(struct cfs_completion *c)
}
/*
}
/*
- * atomic primitives
+ *
Multi-threaded user space
atomic primitives
*/
static pthread_mutex_t atomic_guard_lock = PTHREAD_MUTEX_INITIALIZER;
*/
static pthread_mutex_t atomic_guard_lock = PTHREAD_MUTEX_INITIALIZER;
-int
cfs_atomic_read(cfs
_atomic_t *a)
+int
mt_atomic_read(mt
_atomic_t *a)
{
int r;
{
int r;
@@
-289,14
+323,14
@@
int cfs_atomic_read(cfs_atomic_t *a)
return r;
}
return r;
}
-void
cfs_atomic_set(cfs
_atomic_t *a, int b)
+void
mt_atomic_set(mt
_atomic_t *a, int b)
{
pthread_mutex_lock(&atomic_guard_lock);
a->counter = b;
pthread_mutex_unlock(&atomic_guard_lock);
}
{
pthread_mutex_lock(&atomic_guard_lock);
a->counter = b;
pthread_mutex_unlock(&atomic_guard_lock);
}
-int
cfs_atomic_dec_and_test(cfs
_atomic_t *a)
+int
mt_atomic_dec_and_test(mt
_atomic_t *a)
{
int r;
{
int r;
@@
-306,20
+340,20
@@
int cfs_atomic_dec_and_test(cfs_atomic_t *a)
return (r == 0);
}
return (r == 0);
}
-void
cfs_atomic_inc(cfs
_atomic_t *a)
+void
mt_atomic_inc(mt
_atomic_t *a)
{
pthread_mutex_lock(&atomic_guard_lock);
++a->counter;
pthread_mutex_unlock(&atomic_guard_lock);
}
{
pthread_mutex_lock(&atomic_guard_lock);
++a->counter;
pthread_mutex_unlock(&atomic_guard_lock);
}
-void
cfs_atomic_dec(cfs
_atomic_t *a)
+void
mt_atomic_dec(mt
_atomic_t *a)
{
pthread_mutex_lock(&atomic_guard_lock);
--a->counter;
pthread_mutex_unlock(&atomic_guard_lock);
}
{
pthread_mutex_lock(&atomic_guard_lock);
--a->counter;
pthread_mutex_unlock(&atomic_guard_lock);
}
-void
cfs_atomic_add(int b, cfs
_atomic_t *a)
+void
mt_atomic_add(int b, mt
_atomic_t *a)
{
pthread_mutex_lock(&atomic_guard_lock);
{
pthread_mutex_lock(&atomic_guard_lock);
@@
-327,7
+361,7
@@
void cfs_atomic_add(int b, cfs_atomic_t *a)
pthread_mutex_unlock(&atomic_guard_lock);
}
pthread_mutex_unlock(&atomic_guard_lock);
}
-void
cfs_atomic_sub(int b, cfs
_atomic_t *a)
+void
mt_atomic_sub(int b, mt
_atomic_t *a)
{
pthread_mutex_lock(&atomic_guard_lock);
a->counter -= b;
{
pthread_mutex_lock(&atomic_guard_lock);
a->counter -= b;