2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
3 * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved.
5 * This copyrighted material is made available to anyone wishing to use,
6 * modify, copy, or redistribute it subject to the terms and conditions
7 * of the GNU General Public License v.2.
10 #ifndef LOCK_DLM_DOT_H
11 #define LOCK_DLM_DOT_H
13 #include <linux/module.h>
14 #include <linux/slab.h>
15 #include <linux/spinlock.h>
16 #include <linux/module.h>
17 #include <linux/types.h>
18 #include <linux/string.h>
19 #include <linux/list.h>
20 #include <linux/socket.h>
21 #include <linux/delay.h>
22 #include <linux/kthread.h>
23 #include <linux/kobject.h>
24 #include <linux/fcntl.h>
25 #include <linux/wait.h>
28 #include <linux/dlm.h>
29 #include "../../lm_interface.h"
32 * Internally, we prefix things with gdlm_ and GDLM_ (for gfs-dlm) since a
33 * prefix of lock_dlm_ gets awkward. Externally, GFS refers to this module
37 #define GDLM_STRNAME_BYTES 24
38 #define GDLM_LVB_SIZE 32
39 #define GDLM_DROP_COUNT 50000
40 #define GDLM_DROP_PERIOD 60
41 #define GDLM_NAME_LEN 128
43 /* GFS uses 12 bytes to identify a resource (32 bit type + 64 bit number).
44 We sprintf these numbers into a 24 byte string of hex values to make them
45 human-readable (to make debugging simpler.) */
48 unsigned char name[GDLM_STRNAME_BYTES];
49 unsigned short namelen;
65 char clustername[GDLM_NAME_LEN];
66 char fsname[GDLM_NAME_LEN];
68 dlm_lockspace_t *dlm_lockspace;
73 spinlock_t async_lock;
74 struct list_head complete;
75 struct list_head blocking;
76 struct list_head delayed;
77 struct list_head submit;
78 struct list_head all_locks;
79 uint32_t all_locks_count;
80 wait_queue_head_t wait_control;
81 struct task_struct *thread1;
82 struct task_struct *thread2;
83 wait_queue_head_t thread_wait;
84 unsigned long drop_time;
86 int drop_locks_period;
95 LFL_FORCE_PROMOTE = 5,
102 LFL_UNLOCK_DELETE = 12,
107 struct lm_lockname lockname;
109 struct dlm_lksb lksb;
114 uint32_t lkf; /* dlm flags DLM_LKF_ */
115 unsigned long flags; /* lock_dlm flags LFL_ */
117 int bast_mode; /* protected by async_lock */
118 struct completion ast_wait;
120 struct list_head clist; /* complete */
121 struct list_head blist; /* blocking */
122 struct list_head delay_list; /* delayed */
123 struct list_head all_list; /* all locks for the fs */
124 struct gdlm_lock *hold_null; /* NL lock for hold_lvb */
127 #define gdlm_assert(assertion, fmt, args...) \
129 if (unlikely(!(assertion))) { \
130 printk(KERN_EMERG "lock_dlm: fatal assertion failed \"%s\"\n" \
131 "lock_dlm: " fmt "\n", \
132 #assertion, ##args); \
137 #define log_print(lev, fmt, arg...) printk(lev "lock_dlm: " fmt "\n" , ## arg)
138 #define log_info(fmt, arg...) log_print(KERN_INFO , fmt , ## arg)
139 #define log_error(fmt, arg...) log_print(KERN_ERR , fmt , ## arg)
140 #ifdef LOCK_DLM_LOG_DEBUG
141 #define log_debug(fmt, arg...) log_print(KERN_DEBUG , fmt , ## arg)
143 #define log_debug(fmt, arg...)
148 int gdlm_sysfs_init(void);
149 void gdlm_sysfs_exit(void);
150 int gdlm_kobject_setup(struct gdlm_ls *, struct kobject *);
151 void gdlm_kobject_release(struct gdlm_ls *);
155 int gdlm_init_threads(struct gdlm_ls *);
156 void gdlm_release_threads(struct gdlm_ls *);
160 int16_t gdlm_make_lmstate(int16_t);
161 void gdlm_queue_delayed(struct gdlm_lock *);
162 void gdlm_submit_delayed(struct gdlm_ls *);
163 int gdlm_release_all_locks(struct gdlm_ls *);
164 int gdlm_create_lp(struct gdlm_ls *, struct lm_lockname *, struct gdlm_lock **);
165 void gdlm_delete_lp(struct gdlm_lock *);
166 int gdlm_add_lvb(struct gdlm_lock *);
167 void gdlm_del_lvb(struct gdlm_lock *);
168 unsigned int gdlm_do_lock(struct gdlm_lock *);
169 unsigned int gdlm_do_unlock(struct gdlm_lock *);
171 int gdlm_get_lock(lm_lockspace_t *, struct lm_lockname *, lm_lock_t **);
172 void gdlm_put_lock(lm_lock_t *);
173 unsigned int gdlm_lock(lm_lock_t *, unsigned int, unsigned int, unsigned int);
174 unsigned int gdlm_unlock(lm_lock_t *, unsigned int);
175 void gdlm_cancel(lm_lock_t *);
176 int gdlm_hold_lvb(lm_lock_t *, char **);
177 void gdlm_unhold_lvb(lm_lock_t *, char *);
178 void gdlm_sync_lvb(lm_lock_t *, char *);
182 int gdlm_plock_init(void);
183 void gdlm_plock_exit(void);
184 int gdlm_plock(lm_lockspace_t *, struct lm_lockname *, struct file *, int,
186 int gdlm_plock_get(lm_lockspace_t *, struct lm_lockname *, struct file *,
188 int gdlm_punlock(lm_lockspace_t *, struct lm_lockname *, struct file *,