Whamcloud - gitweb
LU-7268 scrub: NOT assign LMA for EA inode
[fs/lustre-release.git] / lustre / osd-ldiskfs / osd_dynlocks.h
1 #ifndef _OSD_DYNLOCKS_H
2 #define _OSD_DYNLOCKS_H
3
4 #include <linux/list.h>
5 #include <linux/wait.h>
6
7 /*
8  * lock's namespace:
9  *   - list of locks
10  *   - lock to protect this list
11  */
12 struct dynlock {
13         unsigned                dl_magic;
14         struct list_head        dl_list;
15         spinlock_t              dl_list_lock;
16 };
17
18 enum dynlock_type {
19         DLT_WRITE,
20         DLT_READ
21 };
22
23 struct dynlock_handle {
24         unsigned                dh_magic;
25         struct list_head        dh_list;
26         unsigned long           dh_value;       /* lock value */
27         int                     dh_refcount;    /* number of users */
28         int                     dh_readers;
29         int                     dh_writers;
30         int                     dh_pid;         /* holder of the lock */
31         wait_queue_head_t       dh_wait;
32 };
33
34 void dynlock_init(struct dynlock *dl);
35 struct dynlock_handle *dynlock_lock(struct dynlock *dl, unsigned long value,
36                                     enum dynlock_type lt, gfp_t gfp);
37 void dynlock_unlock(struct dynlock *dl, struct dynlock_handle *lock);
38 int dynlock_is_locked(struct dynlock *dl, unsigned long value);
39
40 #endif