Whamcloud - gitweb
f419c9b5a776b01ea7dff6d842c0fa673ec2e588
[fs/lustre-release.git] / lnet / include / libcfs / linux / linux-lock.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (C) 2001 Cluster File Systems, Inc. <braam@clusterfs.com>
5  *
6  *   This file is part of Lustre, http://www.lustre.org.
7  *
8  *   Lustre is free software; you can redistribute it and/or
9  *   modify it under the terms of version 2 of the GNU General Public
10  *   License as published by the Free Software Foundation.
11  *
12  *   Lustre is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *
17  *   You should have received a copy of the GNU General Public License
18  *   along with Lustre; if not, write to the Free Software
19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  *
21  * Basic library routines.
22  *
23  */
24
25 #ifndef __LIBCFS_LINUX_CFS_LOCK_H__
26 #define __LIBCFS_LINUX_CFS_LOCK_H__
27
28 #ifndef __LIBCFS_LIBCFS_H__
29 #error Do not #include this file directly. #include <libcfs/libcfs.h> instead
30 #endif
31
32 #ifdef __KERNEL__
33 #include <linux/smp_lock.h>
34
35 /*
36  * IMPORTANT !!!!!!!!
37  *
38  * All locks' declaration are not guaranteed to be initialized,
39  * Althought some of they are initialized in Linux. All locks
40  * declared by CFS_DECL_* should be initialized explicitly.
41  */
42
43
44 /*
45  * spin_lock (use Linux kernel's primitives)
46  *
47  * - spin_lock_init(x)
48  * - spin_lock(x)
49  * - spin_unlock(x)
50  * - spin_trylock(x)
51  *
52  * - spin_lock_irqsave(x, f)
53  * - spin_unlock_irqrestore(x, f)
54  */
55
56 /*
57  * rw_semaphore (use Linux kernel's primitives)
58  *
59  * - init_rwsem(x)
60  * - down_read(x)
61  * - up_read(x)
62  * - down_write(x)
63  * - up_write(x)
64  */
65
66 /*
67  * rwlock_t (use Linux kernel's primitives)
68  *
69  * - rwlock_init(x)
70  * - read_lock(x)
71  * - read_unlock(x)
72  * - write_lock(x)
73  * - write_unlock(x)
74  */
75
76 /*
77  * mutex:
78  *
79  * - init_mutex(x)
80  * - init_mutex_locked(x)
81  * - mutex_up(x)
82  * - mutex_down(x)
83  */
84 #define init_mutex(x)                   init_MUTEX(x)
85 #define init_mutex_locked(x)            init_MUTEX_LOCKED(x)
86 #define mutex_up(x)                     up(x)
87 #define mutex_down(x)                   down(x)
88
89 /*
90  * completion (use Linux kernel's primitives)
91  *
92  * - init_complition(c)
93  * - complete(c)
94  * - wait_for_completion(c)
95  */
96
97 /* __KERNEL__ */
98 #else
99
100 #include "../user-lock.h"
101
102 /* __KERNEL__ */
103 #endif
104 #endif