David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. |
| 3 | * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. |
| 4 | * |
| 5 | * This copyrighted material is made available to anyone wishing to use, |
| 6 | * modify, copy, or redistribute it subject to the terms and conditions |
Steven Whitehouse | e9fc2aa | 2006-09-01 11:05:15 -0400 | [diff] [blame] | 7 | * of the GNU General Public License version 2. |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #ifndef LOCK_DLM_DOT_H |
| 11 | #define LOCK_DLM_DOT_H |
| 12 | |
| 13 | #include <linux/module.h> |
| 14 | #include <linux/slab.h> |
| 15 | #include <linux/spinlock.h> |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 16 | #include <linux/types.h> |
| 17 | #include <linux/string.h> |
| 18 | #include <linux/list.h> |
| 19 | #include <linux/socket.h> |
| 20 | #include <linux/delay.h> |
| 21 | #include <linux/kthread.h> |
| 22 | #include <linux/kobject.h> |
| 23 | #include <linux/fcntl.h> |
| 24 | #include <linux/wait.h> |
| 25 | #include <net/sock.h> |
| 26 | |
| 27 | #include <linux/dlm.h> |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 28 | #include <linux/dlm_plock.h> |
Fabio Massimo Di Nitto | 7d30859 | 2006-09-19 07:56:29 +0200 | [diff] [blame] | 29 | #include <linux/lm_interface.h> |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 30 | |
| 31 | /* |
| 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 |
| 34 | * as "lock_dlm". |
| 35 | */ |
| 36 | |
| 37 | #define GDLM_STRNAME_BYTES 24 |
| 38 | #define GDLM_LVB_SIZE 32 |
Steven Whitehouse | f01963f | 2007-04-02 10:03:24 +0100 | [diff] [blame] | 39 | #define GDLM_DROP_COUNT 0 |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 40 | #define GDLM_DROP_PERIOD 60 |
| 41 | #define GDLM_NAME_LEN 128 |
| 42 | |
| 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.) */ |
| 46 | |
| 47 | struct gdlm_strname { |
| 48 | unsigned char name[GDLM_STRNAME_BYTES]; |
| 49 | unsigned short namelen; |
| 50 | }; |
| 51 | |
| 52 | enum { |
| 53 | DFL_BLOCK_LOCKS = 0, |
| 54 | DFL_SPECTATOR = 1, |
| 55 | DFL_WITHDRAW = 2, |
| 56 | }; |
| 57 | |
| 58 | struct gdlm_ls { |
Steven Whitehouse | cd91549 | 2006-09-04 12:49:07 -0400 | [diff] [blame] | 59 | u32 id; |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 60 | int jid; |
| 61 | int first; |
| 62 | int first_done; |
| 63 | unsigned long flags; |
| 64 | struct kobject kobj; |
| 65 | char clustername[GDLM_NAME_LEN]; |
| 66 | char fsname[GDLM_NAME_LEN]; |
| 67 | int fsflags; |
| 68 | dlm_lockspace_t *dlm_lockspace; |
| 69 | lm_callback_t fscb; |
Steven Whitehouse | 1c089c3 | 2006-09-07 15:50:20 -0400 | [diff] [blame] | 70 | struct gfs2_sbd *sdp; |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 71 | int recover_jid; |
| 72 | int recover_jid_done; |
David Teigland | 6bd70ab | 2006-04-26 15:56:35 -0400 | [diff] [blame] | 73 | int recover_jid_status; |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 74 | spinlock_t async_lock; |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 75 | struct list_head delayed; |
| 76 | struct list_head submit; |
Steven Whitehouse | cd91549 | 2006-09-04 12:49:07 -0400 | [diff] [blame] | 77 | u32 all_locks_count; |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 78 | wait_queue_head_t wait_control; |
Steven Whitehouse | f3c9d38 | 2008-05-21 17:21:42 +0100 | [diff] [blame] | 79 | struct task_struct *thread; |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 80 | wait_queue_head_t thread_wait; |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 81 | }; |
| 82 | |
| 83 | enum { |
| 84 | LFL_NOBLOCK = 0, |
| 85 | LFL_NOCACHE = 1, |
| 86 | LFL_DLM_UNLOCK = 2, |
| 87 | LFL_DLM_CANCEL = 3, |
| 88 | LFL_SYNC_LVB = 4, |
| 89 | LFL_FORCE_PROMOTE = 5, |
| 90 | LFL_REREQUEST = 6, |
| 91 | LFL_ACTIVE = 7, |
| 92 | LFL_INLOCK = 8, |
| 93 | LFL_CANCEL = 9, |
| 94 | LFL_NOBAST = 10, |
| 95 | LFL_HEADQUE = 11, |
| 96 | LFL_UNLOCK_DELETE = 12, |
Steven Whitehouse | 41d7db0 | 2007-05-14 17:43:26 +0100 | [diff] [blame] | 97 | LFL_AST_WAIT = 13, |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 98 | }; |
| 99 | |
| 100 | struct gdlm_lock { |
| 101 | struct gdlm_ls *ls; |
| 102 | struct lm_lockname lockname; |
Steven Whitehouse | f35ac34 | 2007-03-18 17:04:15 +0000 | [diff] [blame] | 103 | struct gdlm_strname strname; |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 104 | char *lvb; |
| 105 | struct dlm_lksb lksb; |
| 106 | |
Steven Whitehouse | cd91549 | 2006-09-04 12:49:07 -0400 | [diff] [blame] | 107 | s16 cur; |
| 108 | s16 req; |
| 109 | s16 prev_req; |
Steven Whitehouse | 9b47c11 | 2006-09-08 10:17:58 -0400 | [diff] [blame] | 110 | u32 lkf; /* dlm flags DLM_LKF_ */ |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 111 | unsigned long flags; /* lock_dlm flags LFL_ */ |
| 112 | |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 113 | struct list_head delay_list; /* delayed */ |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 114 | struct gdlm_lock *hold_null; /* NL lock for hold_lvb */ |
| 115 | }; |
| 116 | |
| 117 | #define gdlm_assert(assertion, fmt, args...) \ |
| 118 | do { \ |
| 119 | if (unlikely(!(assertion))) { \ |
| 120 | printk(KERN_EMERG "lock_dlm: fatal assertion failed \"%s\"\n" \ |
| 121 | "lock_dlm: " fmt "\n", \ |
| 122 | #assertion, ##args); \ |
| 123 | BUG(); \ |
| 124 | } \ |
| 125 | } while (0) |
| 126 | |
| 127 | #define log_print(lev, fmt, arg...) printk(lev "lock_dlm: " fmt "\n" , ## arg) |
| 128 | #define log_info(fmt, arg...) log_print(KERN_INFO , fmt , ## arg) |
| 129 | #define log_error(fmt, arg...) log_print(KERN_ERR , fmt , ## arg) |
| 130 | #ifdef LOCK_DLM_LOG_DEBUG |
| 131 | #define log_debug(fmt, arg...) log_print(KERN_DEBUG , fmt , ## arg) |
| 132 | #else |
| 133 | #define log_debug(fmt, arg...) |
| 134 | #endif |
| 135 | |
| 136 | /* sysfs.c */ |
| 137 | |
| 138 | int gdlm_sysfs_init(void); |
| 139 | void gdlm_sysfs_exit(void); |
| 140 | int gdlm_kobject_setup(struct gdlm_ls *, struct kobject *); |
| 141 | void gdlm_kobject_release(struct gdlm_ls *); |
| 142 | |
| 143 | /* thread.c */ |
| 144 | |
| 145 | int gdlm_init_threads(struct gdlm_ls *); |
| 146 | void gdlm_release_threads(struct gdlm_ls *); |
| 147 | |
| 148 | /* lock.c */ |
| 149 | |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 150 | void gdlm_submit_delayed(struct gdlm_ls *); |
David Teigland | 8d3b35a | 2006-02-23 10:00:56 +0000 | [diff] [blame] | 151 | unsigned int gdlm_do_lock(struct gdlm_lock *); |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 152 | |
Steven Whitehouse | 9b47c11 | 2006-09-08 10:17:58 -0400 | [diff] [blame] | 153 | int gdlm_get_lock(void *, struct lm_lockname *, void **); |
| 154 | void gdlm_put_lock(void *); |
| 155 | unsigned int gdlm_lock(void *, unsigned int, unsigned int, unsigned int); |
| 156 | unsigned int gdlm_unlock(void *, unsigned int); |
| 157 | void gdlm_cancel(void *); |
| 158 | int gdlm_hold_lvb(void *, char **); |
| 159 | void gdlm_unhold_lvb(void *, char *); |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 160 | |
Adrian Bunk | 60b779c | 2008-02-17 10:20:34 +0200 | [diff] [blame] | 161 | /* mount.c */ |
| 162 | |
| 163 | extern const struct lm_lockops gdlm_ops; |
| 164 | |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 165 | #endif |
| 166 | |