12522fe45SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 2e7fd4179SDavid Teigland /****************************************************************************** 3e7fd4179SDavid Teigland ******************************************************************************* 4e7fd4179SDavid Teigland ** 5e7fd4179SDavid Teigland ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. 660f98d18SDavid Teigland ** Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved. 7e7fd4179SDavid Teigland ** 8e7fd4179SDavid Teigland ** 9e7fd4179SDavid Teigland ******************************************************************************* 10e7fd4179SDavid Teigland ******************************************************************************/ 11e7fd4179SDavid Teigland 12e7fd4179SDavid Teigland #ifndef __DLM_INTERNAL_DOT_H__ 13e7fd4179SDavid Teigland #define __DLM_INTERNAL_DOT_H__ 14e7fd4179SDavid Teigland 15e7fd4179SDavid Teigland /* 16e7fd4179SDavid Teigland * This is the main header file to be included in each DLM source file. 17e7fd4179SDavid Teigland */ 18e7fd4179SDavid Teigland 19e7fd4179SDavid Teigland #include <linux/slab.h> 20e7fd4179SDavid Teigland #include <linux/sched.h> 21e7fd4179SDavid Teigland #include <linux/types.h> 22e7fd4179SDavid Teigland #include <linux/ctype.h> 23e7fd4179SDavid Teigland #include <linux/spinlock.h> 24e7fd4179SDavid Teigland #include <linux/vmalloc.h> 25e7fd4179SDavid Teigland #include <linux/list.h> 26e7fd4179SDavid Teigland #include <linux/errno.h> 27e7fd4179SDavid Teigland #include <linux/random.h> 28e7fd4179SDavid Teigland #include <linux/delay.h> 29e7fd4179SDavid Teigland #include <linux/socket.h> 30e7fd4179SDavid Teigland #include <linux/kthread.h> 31e7fd4179SDavid Teigland #include <linux/kobject.h> 32e7fd4179SDavid Teigland #include <linux/kref.h> 33e7fd4179SDavid Teigland #include <linux/kernel.h> 34e7fd4179SDavid Teigland #include <linux/jhash.h> 35597d0caeSDavid Teigland #include <linux/miscdevice.h> 3690135925SDavid Teigland #include <linux/mutex.h> 373d6aa675SDavid Teigland #include <linux/idr.h> 38d6e24788SDavid Teigland #include <linux/ratelimit.h> 397c0f6ba6SLinus Torvalds #include <linux/uaccess.h> 40e7fd4179SDavid Teigland 41e7fd4179SDavid Teigland #include <linux/dlm.h> 4299fc6487SDavid Teigland #include "config.h" 43e7fd4179SDavid Teigland 44e7fd4179SDavid Teigland struct dlm_ls; 45e7fd4179SDavid Teigland struct dlm_lkb; 46e7fd4179SDavid Teigland struct dlm_rsb; 47e7fd4179SDavid Teigland struct dlm_member; 48e7fd4179SDavid Teigland struct dlm_rsbtable; 49e7fd4179SDavid Teigland struct dlm_recover; 50e7fd4179SDavid Teigland struct dlm_header; 51e7fd4179SDavid Teigland struct dlm_message; 52e7fd4179SDavid Teigland struct dlm_rcom; 53e7fd4179SDavid Teigland struct dlm_mhandle; 548f2dc78dSAlexander Aring struct dlm_msg; 55e7fd4179SDavid Teigland 56e7fd4179SDavid Teigland #define log_print(fmt, args...) \ 57e7fd4179SDavid Teigland printk(KERN_ERR "dlm: "fmt"\n" , ##args) 582df6b762SAlexander Aring #define log_print_ratelimited(fmt, args...) \ 592df6b762SAlexander Aring printk_ratelimited(KERN_ERR "dlm: "fmt"\n", ##args) 60e7fd4179SDavid Teigland #define log_error(ls, fmt, args...) \ 61e7fd4179SDavid Teigland printk(KERN_ERR "dlm: %s: " fmt "\n", (ls)->ls_name , ##args) 62505ee528SZhilong Liu 63075f0177SDavid Teigland #define log_rinfo(ls, fmt, args...) \ 64505ee528SZhilong Liu do { \ 65505ee528SZhilong Liu if (dlm_config.ci_log_info) \ 66505ee528SZhilong Liu printk(KERN_INFO "dlm: %s: " fmt "\n", \ 67505ee528SZhilong Liu (ls)->ls_name, ##args); \ 68505ee528SZhilong Liu else if (dlm_config.ci_log_debug) \ 69505ee528SZhilong Liu printk(KERN_DEBUG "dlm: %s: " fmt "\n", \ 70505ee528SZhilong Liu (ls)->ls_name , ##args); \ 71505ee528SZhilong Liu } while (0) 72e7fd4179SDavid Teigland 7399fc6487SDavid Teigland #define log_debug(ls, fmt, args...) \ 7499fc6487SDavid Teigland do { \ 7599fc6487SDavid Teigland if (dlm_config.ci_log_debug) \ 7699fc6487SDavid Teigland printk(KERN_DEBUG "dlm: %s: " fmt "\n", \ 7799fc6487SDavid Teigland (ls)->ls_name , ##args); \ 7899fc6487SDavid Teigland } while (0) 79e7fd4179SDavid Teigland 80d6e24788SDavid Teigland #define log_limit(ls, fmt, args...) \ 81d6e24788SDavid Teigland do { \ 82d6e24788SDavid Teigland if (dlm_config.ci_log_debug) \ 83d6e24788SDavid Teigland printk_ratelimited(KERN_DEBUG "dlm: %s: " fmt "\n", \ 84d6e24788SDavid Teigland (ls)->ls_name , ##args); \ 85d6e24788SDavid Teigland } while (0) 86d6e24788SDavid Teigland 87e7fd4179SDavid Teigland #define DLM_ASSERT(x, do) \ 88e7fd4179SDavid Teigland { \ 89e7fd4179SDavid Teigland if (!(x)) \ 90e7fd4179SDavid Teigland { \ 91e7fd4179SDavid Teigland printk(KERN_ERR "\nDLM: Assertion failed on line %d of file %s\n" \ 92e7fd4179SDavid Teigland "DLM: assertion: \"%s\"\n" \ 93e7fd4179SDavid Teigland "DLM: time = %lu\n", \ 94e7fd4179SDavid Teigland __LINE__, __FILE__, #x, jiffies); \ 95e7fd4179SDavid Teigland {do} \ 96e7fd4179SDavid Teigland printk("\n"); \ 97e7fd4179SDavid Teigland panic("DLM: Record message above and reboot.\n"); \ 98e7fd4179SDavid Teigland } \ 99e7fd4179SDavid Teigland } 100e7fd4179SDavid Teigland 101e7fd4179SDavid Teigland 102f1172283SDavid Teigland #define DLM_RTF_SHRINK 0x00000001 103f1172283SDavid Teigland 104e7fd4179SDavid Teigland struct dlm_rsbtable { 1059beb3bf5SBob Peterson struct rb_root keep; 1069beb3bf5SBob Peterson struct rb_root toss; 107c7be761aSDavid Teigland spinlock_t lock; 108f1172283SDavid Teigland uint32_t flags; 109e7fd4179SDavid Teigland }; 110e7fd4179SDavid Teigland 111e7fd4179SDavid Teigland 112e7fd4179SDavid Teigland /* 113e7fd4179SDavid Teigland * Lockspace member (per node in a ls) 114e7fd4179SDavid Teigland */ 115e7fd4179SDavid Teigland 116e7fd4179SDavid Teigland struct dlm_member { 117e7fd4179SDavid Teigland struct list_head list; 118e7fd4179SDavid Teigland int nodeid; 119e7fd4179SDavid Teigland int weight; 120757a4271SDavid Teigland int slot; 121757a4271SDavid Teigland int slot_prev; 12260f98d18SDavid Teigland int comm_seq; 123757a4271SDavid Teigland uint32_t generation; 124757a4271SDavid Teigland }; 125757a4271SDavid Teigland 126757a4271SDavid Teigland /* 127e7fd4179SDavid Teigland * Save and manage recovery state for a lockspace. 128e7fd4179SDavid Teigland */ 129e7fd4179SDavid Teigland 130e7fd4179SDavid Teigland struct dlm_recover { 131e7fd4179SDavid Teigland struct list_head list; 13260f98d18SDavid Teigland struct dlm_config_node *nodes; 13360f98d18SDavid Teigland int nodes_count; 134e7fd4179SDavid Teigland uint64_t seq; 135e7fd4179SDavid Teigland }; 136e7fd4179SDavid Teigland 137e7fd4179SDavid Teigland /* 138e7fd4179SDavid Teigland * Pass input args to second stage locking function. 139e7fd4179SDavid Teigland */ 140e7fd4179SDavid Teigland 141e7fd4179SDavid Teigland struct dlm_args { 142e7fd4179SDavid Teigland uint32_t flags; 143e5dae548SDavid Teigland void (*astfn) (void *astparam); 144e5dae548SDavid Teigland void *astparam; 145e5dae548SDavid Teigland void (*bastfn) (void *astparam, int mode); 146e7fd4179SDavid Teigland int mode; 147e7fd4179SDavid Teigland struct dlm_lksb *lksb; 1486b0afc0cSAlexander Aring #ifdef CONFIG_DLM_DEPRECATED_API 149d7db923eSDavid Teigland unsigned long timeout; 1506b0afc0cSAlexander Aring #endif 151e7fd4179SDavid Teigland }; 152e7fd4179SDavid Teigland 153e7fd4179SDavid Teigland 154e7fd4179SDavid Teigland /* 155e7fd4179SDavid Teigland * Lock block 156e7fd4179SDavid Teigland * 157e7fd4179SDavid Teigland * A lock can be one of three types: 158e7fd4179SDavid Teigland * 159e7fd4179SDavid Teigland * local copy lock is mastered locally 160e7fd4179SDavid Teigland * (lkb_nodeid is zero and DLM_LKF_MSTCPY is not set) 161e7fd4179SDavid Teigland * process copy lock is mastered on a remote node 162e7fd4179SDavid Teigland * (lkb_nodeid is non-zero and DLM_LKF_MSTCPY is not set) 163e7fd4179SDavid Teigland * master copy master node's copy of a lock owned by remote node 164e7fd4179SDavid Teigland * (lkb_nodeid is non-zero and DLM_LKF_MSTCPY is set) 165e7fd4179SDavid Teigland * 166e7fd4179SDavid Teigland * lkb_exflags: a copy of the most recent flags arg provided to dlm_lock or 167e7fd4179SDavid Teigland * dlm_unlock. The dlm does not modify these or use any private flags in 168e7fd4179SDavid Teigland * this field; it only contains DLM_LKF_ flags from dlm.h. These flags 169e7fd4179SDavid Teigland * are sent as-is to the remote master when the lock is remote. 170e7fd4179SDavid Teigland * 171e7fd4179SDavid Teigland * lkb_flags: internal dlm flags (DLM_IFL_ prefix) from dlm_internal.h. 172e7fd4179SDavid Teigland * Some internal flags are shared between the master and process nodes; 173e7fd4179SDavid Teigland * these shared flags are kept in the lower two bytes. One of these 174e7fd4179SDavid Teigland * flags set on the master copy will be propagated to the process copy 175e7fd4179SDavid Teigland * and v.v. Other internal flags are private to the master or process 176e7fd4179SDavid Teigland * node (e.g. DLM_IFL_MSTCPY). These are kept in the high two bytes. 177e7fd4179SDavid Teigland * 178e7fd4179SDavid Teigland * lkb_sbflags: status block flags. These flags are copied directly into 179e7fd4179SDavid Teigland * the caller's lksb.sb_flags prior to the dlm_lock/dlm_unlock completion 180e7fd4179SDavid Teigland * ast. All defined in dlm.h with DLM_SBF_ prefix. 181e7fd4179SDavid Teigland * 182e7fd4179SDavid Teigland * lkb_status: the lock status indicates which rsb queue the lock is 183e7fd4179SDavid Teigland * on, grant, convert, or wait. DLM_LKSTS_ WAITING/GRANTED/CONVERT 184e7fd4179SDavid Teigland * 185e7fd4179SDavid Teigland * lkb_wait_type: the dlm message type (DLM_MSG_ prefix) for which a 186e7fd4179SDavid Teigland * reply is needed. Only set when the lkb is on the lockspace waiters 187e7fd4179SDavid Teigland * list awaiting a reply from a remote node. 188e7fd4179SDavid Teigland * 189e7fd4179SDavid Teigland * lkb_nodeid: when the lkb is a local copy, nodeid is 0; when the lkb 190e7fd4179SDavid Teigland * is a master copy, nodeid specifies the remote lock holder, when the 191e7fd4179SDavid Teigland * lkb is a process copy, the nodeid specifies the lock master. 192e7fd4179SDavid Teigland */ 193e7fd4179SDavid Teigland 194e7fd4179SDavid Teigland /* lkb_status */ 195e7fd4179SDavid Teigland 196e7fd4179SDavid Teigland #define DLM_LKSTS_WAITING 1 197e7fd4179SDavid Teigland #define DLM_LKSTS_GRANTED 2 198e7fd4179SDavid Teigland #define DLM_LKSTS_CONVERT 3 199e7fd4179SDavid Teigland 200e7fd4179SDavid Teigland /* lkb_flags */ 201e7fd4179SDavid Teigland 202e7fd4179SDavid Teigland #define DLM_IFL_MSTCPY 0x00010000 203e7fd4179SDavid Teigland #define DLM_IFL_RESEND 0x00020000 204597d0caeSDavid Teigland #define DLM_IFL_DEAD 0x00040000 205ef0c2bb0SDavid Teigland #define DLM_IFL_OVERLAP_UNLOCK 0x00080000 206ef0c2bb0SDavid Teigland #define DLM_IFL_OVERLAP_CANCEL 0x00100000 207ef0c2bb0SDavid Teigland #define DLM_IFL_ENDOFLIFE 0x00200000 2086b0afc0cSAlexander Aring #ifdef CONFIG_DLM_DEPRECATED_API 2093ae1acf9SDavid Teigland #define DLM_IFL_WATCH_TIMEWARN 0x00400000 21084d8cd69SDavid Teigland #define DLM_IFL_TIMEOUT_CANCEL 0x00800000 2116b0afc0cSAlexander Aring #endif 2128b4021faSDavid Teigland #define DLM_IFL_DEADLOCK_CANCEL 0x01000000 2132a7ce0edSDavid Teigland #define DLM_IFL_STUB_MS 0x02000000 /* magic number for m_flags */ 214*61bed0baSAlexander Aring #define DLM_IFL_NEED_SCHED 0x04000000 215f10da927SAlexander Aring /* least significant 2 bytes are message changed, they are full transmitted 216f10da927SAlexander Aring * but at receive side only the 2 bytes LSB will be set. 217f10da927SAlexander Aring * 218f10da927SAlexander Aring * Even wireshark dlm dissector does only evaluate the lower bytes and note 219f10da927SAlexander Aring * that they may not be used on transceiver side, we assume the higher bytes 220f10da927SAlexander Aring * are for internal use or reserved so long they are not parsed on receiver 221f10da927SAlexander Aring * side. 222f10da927SAlexander Aring */ 223597d0caeSDavid Teigland #define DLM_IFL_USER 0x00000001 224597d0caeSDavid Teigland #define DLM_IFL_ORPHAN 0x00000002 225e7fd4179SDavid Teigland 2268304d6f2SDavid Teigland #define DLM_CB_CAST 0x00000001 2278304d6f2SDavid Teigland #define DLM_CB_BAST 0x00000002 2288304d6f2SDavid Teigland 2298304d6f2SDavid Teigland struct dlm_callback { 2308304d6f2SDavid Teigland uint32_t flags; /* DLM_CBF_ */ 2318304d6f2SDavid Teigland int sb_status; /* copy to lksb status */ 2328304d6f2SDavid Teigland uint8_t sb_flags; /* copy to lksb flags */ 2338304d6f2SDavid Teigland int8_t mode; /* rq mode of bast, gr mode of cast */ 234*61bed0baSAlexander Aring 235*61bed0baSAlexander Aring struct list_head list; 236*61bed0baSAlexander Aring struct kref ref; 2378304d6f2SDavid Teigland }; 2388304d6f2SDavid Teigland 239e7fd4179SDavid Teigland struct dlm_lkb { 240e7fd4179SDavid Teigland struct dlm_rsb *lkb_resource; /* the rsb */ 241e7fd4179SDavid Teigland struct kref lkb_ref; 242e7fd4179SDavid Teigland int lkb_nodeid; /* copied from rsb */ 243e7fd4179SDavid Teigland int lkb_ownpid; /* pid of lock owner */ 244e7fd4179SDavid Teigland uint32_t lkb_id; /* our lock ID */ 245e7fd4179SDavid Teigland uint32_t lkb_remid; /* lock ID on remote partner */ 246e7fd4179SDavid Teigland uint32_t lkb_exflags; /* external flags from caller */ 247e7fd4179SDavid Teigland uint32_t lkb_sbflags; /* lksb flags */ 248e7fd4179SDavid Teigland uint32_t lkb_flags; /* internal flags */ 249e7fd4179SDavid Teigland uint32_t lkb_lvbseq; /* lvb sequence number */ 250e7fd4179SDavid Teigland 251e7fd4179SDavid Teigland int8_t lkb_status; /* granted, waiting, convert */ 252e7fd4179SDavid Teigland int8_t lkb_rqmode; /* requested lock mode */ 253e7fd4179SDavid Teigland int8_t lkb_grmode; /* granted lock mode */ 254e7fd4179SDavid Teigland int8_t lkb_highbast; /* highest mode bast sent for */ 2557fe2b319SDavid Teigland 256e7fd4179SDavid Teigland int8_t lkb_wait_type; /* type of reply waiting for */ 257ef0c2bb0SDavid Teigland int8_t lkb_wait_count; 258c6ff669bSDavid Teigland int lkb_wait_nodeid; /* for debugging */ 259e7fd4179SDavid Teigland 260e7fd4179SDavid Teigland struct list_head lkb_statequeue; /* rsb g/c/w list */ 261e7fd4179SDavid Teigland struct list_head lkb_rsb_lookup; /* waiting for rsb lookup */ 262e7fd4179SDavid Teigland struct list_head lkb_wait_reply; /* waiting for remote reply */ 263597d0caeSDavid Teigland struct list_head lkb_ownqueue; /* list of locks for a process */ 264eeda418dSDavid Teigland ktime_t lkb_timestamp; 2656b0afc0cSAlexander Aring 2666b0afc0cSAlexander Aring #ifdef CONFIG_DLM_DEPRECATED_API 2676b0afc0cSAlexander Aring struct list_head lkb_time_list; 2683ae1acf9SDavid Teigland unsigned long lkb_timeout_cs; 2696b0afc0cSAlexander Aring #endif 270e7fd4179SDavid Teigland 27192e95733SAlexander Aring spinlock_t lkb_cb_lock; 27223e8e1aaSDavid Teigland struct work_struct lkb_cb_work; 27323e8e1aaSDavid Teigland struct list_head lkb_cb_list; /* for ls_cb_delay or proc->asts */ 274*61bed0baSAlexander Aring struct list_head lkb_callbacks; 275*61bed0baSAlexander Aring struct dlm_callback *lkb_last_cast; 276*61bed0baSAlexander Aring struct dlm_callback *lkb_last_cb; 277*61bed0baSAlexander Aring int lkb_last_bast_mode; 2788304d6f2SDavid Teigland ktime_t lkb_last_cast_time; /* for debugging */ 2798304d6f2SDavid Teigland ktime_t lkb_last_bast_time; /* for debugging */ 2808304d6f2SDavid Teigland 2814875647aSDavid Teigland uint64_t lkb_recover_seq; /* from ls_recover_seq */ 2824875647aSDavid Teigland 283e7fd4179SDavid Teigland char *lkb_lvbptr; 284e7fd4179SDavid Teigland struct dlm_lksb *lkb_lksb; /* caller's status block */ 285e5dae548SDavid Teigland void (*lkb_astfn) (void *astparam); 286e5dae548SDavid Teigland void (*lkb_bastfn) (void *astparam, int mode); 287d292c0ccSDavid Teigland union { 288e5dae548SDavid Teigland void *lkb_astparam; /* caller's ast arg */ 289d292c0ccSDavid Teigland struct dlm_user_args *lkb_ua; 290d292c0ccSDavid Teigland }; 291e7fd4179SDavid Teigland }; 292e7fd4179SDavid Teigland 293c04fecb4SDavid Teigland /* 294c04fecb4SDavid Teigland * res_master_nodeid is "normal": 0 is unset/invalid, non-zero is the real 295c04fecb4SDavid Teigland * nodeid, even when nodeid is our_nodeid. 296c04fecb4SDavid Teigland * 297c04fecb4SDavid Teigland * res_nodeid is "odd": -1 is unset/invalid, zero means our_nodeid, 298c04fecb4SDavid Teigland * greater than zero when another nodeid. 299c04fecb4SDavid Teigland * 300c04fecb4SDavid Teigland * (TODO: remove res_nodeid and only use res_master_nodeid) 301c04fecb4SDavid Teigland */ 302e7fd4179SDavid Teigland 303e7fd4179SDavid Teigland struct dlm_rsb { 304e7fd4179SDavid Teigland struct dlm_ls *res_ls; /* the lockspace */ 305e7fd4179SDavid Teigland struct kref res_ref; 30690135925SDavid Teigland struct mutex res_mutex; 307e7fd4179SDavid Teigland unsigned long res_flags; 308e7fd4179SDavid Teigland int res_length; /* length of rsb name */ 309e7fd4179SDavid Teigland int res_nodeid; 310c04fecb4SDavid Teigland int res_master_nodeid; 311c04fecb4SDavid Teigland int res_dir_nodeid; 3121d7c484eSDavid Teigland int res_id; /* for ls_recover_idr */ 313e7fd4179SDavid Teigland uint32_t res_lvbseq; 314e7fd4179SDavid Teigland uint32_t res_hash; 315e7fd4179SDavid Teigland uint32_t res_bucket; /* rsbtbl */ 316e7fd4179SDavid Teigland unsigned long res_toss_time; 317e7fd4179SDavid Teigland uint32_t res_first_lkid; 318e7fd4179SDavid Teigland struct list_head res_lookup; /* lkbs waiting on first */ 3199beb3bf5SBob Peterson union { 3209beb3bf5SBob Peterson struct list_head res_hashchain; 3219beb3bf5SBob Peterson struct rb_node res_hashnode; /* rsbtbl */ 3229beb3bf5SBob Peterson }; 323e7fd4179SDavid Teigland struct list_head res_grantqueue; 324e7fd4179SDavid Teigland struct list_head res_convertqueue; 325e7fd4179SDavid Teigland struct list_head res_waitqueue; 326e7fd4179SDavid Teigland 327e7fd4179SDavid Teigland struct list_head res_root_list; /* used for recovery */ 328e7fd4179SDavid Teigland struct list_head res_recover_list; /* used for recovery */ 329e7fd4179SDavid Teigland int res_recover_locks_count; 330e7fd4179SDavid Teigland 331e7fd4179SDavid Teigland char *res_lvbptr; 3323881ac04SDavid Teigland char res_name[DLM_RESNAME_MAXLEN+1]; 333e7fd4179SDavid Teigland }; 334e7fd4179SDavid Teigland 335c04fecb4SDavid Teigland /* dlm_master_lookup() flags */ 336c04fecb4SDavid Teigland 337c04fecb4SDavid Teigland #define DLM_LU_RECOVER_DIR 1 338c04fecb4SDavid Teigland #define DLM_LU_RECOVER_MASTER 2 339c04fecb4SDavid Teigland 340c04fecb4SDavid Teigland /* dlm_master_lookup() results */ 341c04fecb4SDavid Teigland 342c04fecb4SDavid Teigland #define DLM_LU_MATCH 1 343c04fecb4SDavid Teigland #define DLM_LU_ADD 2 344c04fecb4SDavid Teigland 345e7fd4179SDavid Teigland /* find_rsb() flags */ 346e7fd4179SDavid Teigland 347c04fecb4SDavid Teigland #define R_REQUEST 0x00000001 348c04fecb4SDavid Teigland #define R_RECEIVE_REQUEST 0x00000002 349c04fecb4SDavid Teigland #define R_RECEIVE_RECOVER 0x00000004 350e7fd4179SDavid Teigland 351e7fd4179SDavid Teigland /* rsb_flags */ 352e7fd4179SDavid Teigland 353e7fd4179SDavid Teigland enum rsb_flags { 354e7fd4179SDavid Teigland RSB_MASTER_UNCERTAIN, 355e7fd4179SDavid Teigland RSB_VALNOTVALID, 356e7fd4179SDavid Teigland RSB_VALNOTVALID_PREV, 357e7fd4179SDavid Teigland RSB_NEW_MASTER, 358e7fd4179SDavid Teigland RSB_NEW_MASTER2, 359e7fd4179SDavid Teigland RSB_RECOVER_CONVERT, 3604875647aSDavid Teigland RSB_RECOVER_GRANT, 361da8c6663SDavid Teigland RSB_RECOVER_LVB_INVAL, 362e7fd4179SDavid Teigland }; 363e7fd4179SDavid Teigland 364e7fd4179SDavid Teigland static inline void rsb_set_flag(struct dlm_rsb *r, enum rsb_flags flag) 365e7fd4179SDavid Teigland { 366e7fd4179SDavid Teigland __set_bit(flag, &r->res_flags); 367e7fd4179SDavid Teigland } 368e7fd4179SDavid Teigland 369e7fd4179SDavid Teigland static inline void rsb_clear_flag(struct dlm_rsb *r, enum rsb_flags flag) 370e7fd4179SDavid Teigland { 371e7fd4179SDavid Teigland __clear_bit(flag, &r->res_flags); 372e7fd4179SDavid Teigland } 373e7fd4179SDavid Teigland 374e7fd4179SDavid Teigland static inline int rsb_flag(struct dlm_rsb *r, enum rsb_flags flag) 375e7fd4179SDavid Teigland { 376e7fd4179SDavid Teigland return test_bit(flag, &r->res_flags); 377e7fd4179SDavid Teigland } 378e7fd4179SDavid Teigland 379e7fd4179SDavid Teigland 380e7fd4179SDavid Teigland /* dlm_header is first element of all structs sent between nodes */ 381e7fd4179SDavid Teigland 38238aa8b0cSDavid Teigland #define DLM_HEADER_MAJOR 0x00030000 383489d8e55SAlexander Aring #define DLM_HEADER_MINOR 0x00000002 384489d8e55SAlexander Aring 385489d8e55SAlexander Aring #define DLM_VERSION_3_1 0x00030001 386489d8e55SAlexander Aring #define DLM_VERSION_3_2 0x00030002 387757a4271SDavid Teigland 388757a4271SDavid Teigland #define DLM_HEADER_SLOTS 0x00000001 389e7fd4179SDavid Teigland 390e7fd4179SDavid Teigland #define DLM_MSG 1 391e7fd4179SDavid Teigland #define DLM_RCOM 2 392489d8e55SAlexander Aring #define DLM_OPTS 3 393489d8e55SAlexander Aring #define DLM_ACK 4 394489d8e55SAlexander Aring #define DLM_FIN 5 395e7fd4179SDavid Teigland 396e7fd4179SDavid Teigland struct dlm_header { 3973428785aSAlexander Aring __le32 h_version; 3988e2e4086SAlexander Aring union { 3998e2e4086SAlexander Aring /* for DLM_MSG and DLM_RCOM */ 4003428785aSAlexander Aring __le32 h_lockspace; 401489d8e55SAlexander Aring /* for DLM_ACK and DLM_OPTS */ 4023428785aSAlexander Aring __le32 h_seq; 4038e2e4086SAlexander Aring } u; 4043428785aSAlexander Aring __le32 h_nodeid; /* nodeid of sender */ 4053428785aSAlexander Aring __le16 h_length; 406e7fd4179SDavid Teigland uint8_t h_cmd; /* DLM_MSG, DLM_RCOM */ 407e7fd4179SDavid Teigland uint8_t h_pad; 408e7fd4179SDavid Teigland }; 409e7fd4179SDavid Teigland 410e7fd4179SDavid Teigland #define DLM_MSG_REQUEST 1 411e7fd4179SDavid Teigland #define DLM_MSG_CONVERT 2 412e7fd4179SDavid Teigland #define DLM_MSG_UNLOCK 3 413e7fd4179SDavid Teigland #define DLM_MSG_CANCEL 4 414e7fd4179SDavid Teigland #define DLM_MSG_REQUEST_REPLY 5 415e7fd4179SDavid Teigland #define DLM_MSG_CONVERT_REPLY 6 416e7fd4179SDavid Teigland #define DLM_MSG_UNLOCK_REPLY 7 417e7fd4179SDavid Teigland #define DLM_MSG_CANCEL_REPLY 8 418e7fd4179SDavid Teigland #define DLM_MSG_GRANT 9 419e7fd4179SDavid Teigland #define DLM_MSG_BAST 10 420e7fd4179SDavid Teigland #define DLM_MSG_LOOKUP 11 421e7fd4179SDavid Teigland #define DLM_MSG_REMOVE 12 422e7fd4179SDavid Teigland #define DLM_MSG_LOOKUP_REPLY 13 4238499137dSDavid Teigland #define DLM_MSG_PURGE 14 424e7fd4179SDavid Teigland 425e7fd4179SDavid Teigland struct dlm_message { 426e7fd4179SDavid Teigland struct dlm_header m_header; 42700e99ccdSAlexander Aring __le32 m_type; /* DLM_MSG_ */ 42800e99ccdSAlexander Aring __le32 m_nodeid; 42900e99ccdSAlexander Aring __le32 m_pid; 43000e99ccdSAlexander Aring __le32 m_lkid; /* lkid on sender */ 43100e99ccdSAlexander Aring __le32 m_remid; /* lkid on receiver */ 43200e99ccdSAlexander Aring __le32 m_parent_lkid; 43300e99ccdSAlexander Aring __le32 m_parent_remid; 43400e99ccdSAlexander Aring __le32 m_exflags; 43500e99ccdSAlexander Aring __le32 m_sbflags; 43600e99ccdSAlexander Aring __le32 m_flags; 43700e99ccdSAlexander Aring __le32 m_lvbseq; 43800e99ccdSAlexander Aring __le32 m_hash; 43900e99ccdSAlexander Aring __le32 m_status; 44000e99ccdSAlexander Aring __le32 m_grmode; 44100e99ccdSAlexander Aring __le32 m_rqmode; 44200e99ccdSAlexander Aring __le32 m_bastmode; 44300e99ccdSAlexander Aring __le32 m_asts; 44400e99ccdSAlexander Aring __le32 m_result; /* 0 or -EXXX */ 445a4e439a6SGustavo A. R. Silva char m_extra[]; /* name or lvb */ 446e7fd4179SDavid Teigland }; 447e7fd4179SDavid Teigland 448e7fd4179SDavid Teigland 449e7fd4179SDavid Teigland #define DLM_RS_NODES 0x00000001 450e7fd4179SDavid Teigland #define DLM_RS_NODES_ALL 0x00000002 451e7fd4179SDavid Teigland #define DLM_RS_DIR 0x00000004 452e7fd4179SDavid Teigland #define DLM_RS_DIR_ALL 0x00000008 453e7fd4179SDavid Teigland #define DLM_RS_LOCKS 0x00000010 454e7fd4179SDavid Teigland #define DLM_RS_LOCKS_ALL 0x00000020 455e7fd4179SDavid Teigland #define DLM_RS_DONE 0x00000040 456e7fd4179SDavid Teigland #define DLM_RS_DONE_ALL 0x00000080 457e7fd4179SDavid Teigland 458e7fd4179SDavid Teigland #define DLM_RCOM_STATUS 1 459e7fd4179SDavid Teigland #define DLM_RCOM_NAMES 2 460e7fd4179SDavid Teigland #define DLM_RCOM_LOOKUP 3 461e7fd4179SDavid Teigland #define DLM_RCOM_LOCK 4 462e7fd4179SDavid Teigland #define DLM_RCOM_STATUS_REPLY 5 463e7fd4179SDavid Teigland #define DLM_RCOM_NAMES_REPLY 6 464e7fd4179SDavid Teigland #define DLM_RCOM_LOOKUP_REPLY 7 465e7fd4179SDavid Teigland #define DLM_RCOM_LOCK_REPLY 8 466e7fd4179SDavid Teigland 467e7fd4179SDavid Teigland struct dlm_rcom { 468e7fd4179SDavid Teigland struct dlm_header rc_header; 4692f9dbedaSAlexander Aring __le32 rc_type; /* DLM_RCOM_ */ 4702f9dbedaSAlexander Aring __le32 rc_result; /* multi-purpose */ 4712f9dbedaSAlexander Aring __le64 rc_id; /* match reply with request */ 4722f9dbedaSAlexander Aring __le64 rc_seq; /* sender's ls_recover_seq */ 4732f9dbedaSAlexander Aring __le64 rc_seq_reply; /* remote ls_recover_seq */ 474a4e439a6SGustavo A. R. Silva char rc_buf[]; 475e7fd4179SDavid Teigland }; 476e7fd4179SDavid Teigland 477489d8e55SAlexander Aring struct dlm_opt_header { 478d9efd005SAlexander Aring __le16 t_type; 479d9efd005SAlexander Aring __le16 t_length; 480d9efd005SAlexander Aring __le32 t_pad; 481489d8e55SAlexander Aring /* need to be 8 byte aligned */ 482489d8e55SAlexander Aring char t_value[]; 483489d8e55SAlexander Aring }; 484489d8e55SAlexander Aring 485489d8e55SAlexander Aring /* encapsulation header */ 486489d8e55SAlexander Aring struct dlm_opts { 487489d8e55SAlexander Aring struct dlm_header o_header; 488489d8e55SAlexander Aring uint8_t o_nextcmd; 489489d8e55SAlexander Aring uint8_t o_pad; 490d9efd005SAlexander Aring __le16 o_optlen; 491d9efd005SAlexander Aring __le32 o_pad2; 492489d8e55SAlexander Aring char o_opts[]; 493489d8e55SAlexander Aring }; 494489d8e55SAlexander Aring 495eef7d739SAl Viro union dlm_packet { 496eef7d739SAl Viro struct dlm_header header; /* common to other two */ 497eef7d739SAl Viro struct dlm_message message; 498eef7d739SAl Viro struct dlm_rcom rcom; 499489d8e55SAlexander Aring struct dlm_opts opts; 500eef7d739SAl Viro }; 501eef7d739SAl Viro 502757a4271SDavid Teigland #define DLM_RSF_NEED_SLOTS 0x00000001 503757a4271SDavid Teigland 504757a4271SDavid Teigland /* RCOM_STATUS data */ 505757a4271SDavid Teigland struct rcom_status { 506757a4271SDavid Teigland __le32 rs_flags; 507757a4271SDavid Teigland __le32 rs_unused1; 508757a4271SDavid Teigland __le64 rs_unused2; 509757a4271SDavid Teigland }; 510757a4271SDavid Teigland 511757a4271SDavid Teigland /* RCOM_STATUS_REPLY data */ 512e7fd4179SDavid Teigland struct rcom_config { 51393ff2971SAl Viro __le32 rf_lvblen; 51493ff2971SAl Viro __le32 rf_lsflags; 515757a4271SDavid Teigland 516757a4271SDavid Teigland /* DLM_HEADER_SLOTS adds: */ 517757a4271SDavid Teigland __le32 rf_flags; 518757a4271SDavid Teigland __le16 rf_our_slot; 519757a4271SDavid Teigland __le16 rf_num_slots; 520757a4271SDavid Teigland __le32 rf_generation; 521757a4271SDavid Teigland __le32 rf_unused1; 522757a4271SDavid Teigland __le64 rf_unused2; 523757a4271SDavid Teigland }; 524757a4271SDavid Teigland 525757a4271SDavid Teigland struct rcom_slot { 526757a4271SDavid Teigland __le32 ro_nodeid; 527757a4271SDavid Teigland __le16 ro_slot; 528757a4271SDavid Teigland __le16 ro_unused1; 529757a4271SDavid Teigland __le64 ro_unused2; 530e7fd4179SDavid Teigland }; 531e7fd4179SDavid Teigland 532e7fd4179SDavid Teigland struct rcom_lock { 533163a1859SAl Viro __le32 rl_ownpid; 534163a1859SAl Viro __le32 rl_lkid; 535163a1859SAl Viro __le32 rl_remid; 536163a1859SAl Viro __le32 rl_parent_lkid; 537163a1859SAl Viro __le32 rl_parent_remid; 538163a1859SAl Viro __le32 rl_exflags; 539163a1859SAl Viro __le32 rl_flags; 540163a1859SAl Viro __le32 rl_lvbseq; 541163a1859SAl Viro __le32 rl_result; 542e7fd4179SDavid Teigland int8_t rl_rqmode; 543e7fd4179SDavid Teigland int8_t rl_grmode; 544e7fd4179SDavid Teigland int8_t rl_status; 545e7fd4179SDavid Teigland int8_t rl_asts; 546163a1859SAl Viro __le16 rl_wait_type; 547163a1859SAl Viro __le16 rl_namelen; 548e7fd4179SDavid Teigland char rl_name[DLM_RESNAME_MAXLEN]; 549a4e439a6SGustavo A. R. Silva char rl_lvb[]; 550e7fd4179SDavid Teigland }; 551e7fd4179SDavid Teigland 55205c32f47SDavid Teigland /* 55305c32f47SDavid Teigland * The max number of resources per rsbtbl bucket that shrink will attempt 55405c32f47SDavid Teigland * to remove in each iteration. 55505c32f47SDavid Teigland */ 55605c32f47SDavid Teigland 55705c32f47SDavid Teigland #define DLM_REMOVE_NAMES_MAX 8 55805c32f47SDavid Teigland 559e7fd4179SDavid Teigland struct dlm_ls { 560e7fd4179SDavid Teigland struct list_head ls_list; /* list of lockspaces */ 561597d0caeSDavid Teigland dlm_lockspace_t *ls_local_handle; 562e7fd4179SDavid Teigland uint32_t ls_global_id; /* global unique lockspace ID */ 563757a4271SDavid Teigland uint32_t ls_generation; 564e7fd4179SDavid Teigland uint32_t ls_exflags; 565e7fd4179SDavid Teigland int ls_lvblen; 5663cb5977cSAlexander Aring atomic_t ls_count; /* refcount of processes in 5670f8e0d9aSDavid Teigland the dlm using this ls */ 5683cb5977cSAlexander Aring wait_queue_head_t ls_count_wait; 5690f8e0d9aSDavid Teigland int ls_create_count; /* create/release refcount */ 570e7fd4179SDavid Teigland unsigned long ls_flags; /* LSFL_ */ 571c1dcf65fSDavid Teigland unsigned long ls_scan_time; 572e7fd4179SDavid Teigland struct kobject ls_kobj; 573e7fd4179SDavid Teigland 5743d6aa675SDavid Teigland struct idr ls_lkbidr; 5753d6aa675SDavid Teigland spinlock_t ls_lkbidr_spin; 5763d6aa675SDavid Teigland 577e7fd4179SDavid Teigland struct dlm_rsbtable *ls_rsbtbl; 578e7fd4179SDavid Teigland uint32_t ls_rsbtbl_size; 579e7fd4179SDavid Teigland 58090135925SDavid Teigland struct mutex ls_waiters_mutex; 581e7fd4179SDavid Teigland struct list_head ls_waiters; /* lkbs needing a reply */ 582e7fd4179SDavid Teigland 583ef0c2bb0SDavid Teigland struct mutex ls_orphans_mutex; 584ef0c2bb0SDavid Teigland struct list_head ls_orphans; 585ef0c2bb0SDavid Teigland 5866b0afc0cSAlexander Aring #ifdef CONFIG_DLM_DEPRECATED_API 5873ae1acf9SDavid Teigland struct mutex ls_timeout_mutex; 5883ae1acf9SDavid Teigland struct list_head ls_timeout; 5896b0afc0cSAlexander Aring #endif 5903ae1acf9SDavid Teigland 5913881ac04SDavid Teigland spinlock_t ls_new_rsb_spin; 5923881ac04SDavid Teigland int ls_new_rsb_count; 5933881ac04SDavid Teigland struct list_head ls_new_rsb; /* new rsb structs */ 5943881ac04SDavid Teigland 59505c32f47SDavid Teigland spinlock_t ls_remove_spin; 59621d9ac1aSAlexander Aring wait_queue_head_t ls_remove_wait; 59705c32f47SDavid Teigland char ls_remove_name[DLM_RESNAME_MAXLEN+1]; 59805c32f47SDavid Teigland char *ls_remove_names[DLM_REMOVE_NAMES_MAX]; 59905c32f47SDavid Teigland int ls_remove_len; 60005c32f47SDavid Teigland int ls_remove_lens[DLM_REMOVE_NAMES_MAX]; 60105c32f47SDavid Teigland 602e7fd4179SDavid Teigland struct list_head ls_nodes; /* current nodes in ls */ 603e7fd4179SDavid Teigland struct list_head ls_nodes_gone; /* dead node list, recovery */ 604e7fd4179SDavid Teigland int ls_num_nodes; /* number of nodes in ls */ 605e7fd4179SDavid Teigland int ls_low_nodeid; 606e7fd4179SDavid Teigland int ls_total_weight; 607e7fd4179SDavid Teigland int *ls_node_array; 608e7fd4179SDavid Teigland 609757a4271SDavid Teigland int ls_slot; 610757a4271SDavid Teigland int ls_num_slots; 611757a4271SDavid Teigland int ls_slots_size; 612757a4271SDavid Teigland struct dlm_slot *ls_slots; 613757a4271SDavid Teigland 614e7fd4179SDavid Teigland struct dlm_rsb ls_stub_rsb; /* for returning errors */ 615e7fd4179SDavid Teigland struct dlm_lkb ls_stub_lkb; /* for returning errors */ 616e7fd4179SDavid Teigland struct dlm_message ls_stub_ms; /* for faking a reply */ 617e7fd4179SDavid Teigland 6185de6319bSDavid Teigland struct dentry *ls_debug_rsb_dentry; /* debugfs */ 6195de6319bSDavid Teigland struct dentry *ls_debug_waiters_dentry; /* debugfs */ 620ac90a255SDavid Teigland struct dentry *ls_debug_locks_dentry; /* debugfs */ 621d022509dSDavid Teigland struct dentry *ls_debug_all_dentry; /* debugfs */ 622c04fecb4SDavid Teigland struct dentry *ls_debug_toss_dentry; /* debugfs */ 623e7fd4179SDavid Teigland 624e7fd4179SDavid Teigland wait_queue_head_t ls_uevent_wait; /* user part of join/leave */ 625e7fd4179SDavid Teigland int ls_uevent_result; 626682bb91bSAlexander Aring struct completion ls_recovery_done; 627682bb91bSAlexander Aring int ls_recovery_result; 628e7fd4179SDavid Teigland 629597d0caeSDavid Teigland struct miscdevice ls_device; 630597d0caeSDavid Teigland 63123e8e1aaSDavid Teigland struct workqueue_struct *ls_callback_wq; 63223e8e1aaSDavid Teigland 633e7fd4179SDavid Teigland /* recovery related */ 634e7fd4179SDavid Teigland 635a4c0352bSAlexander Aring spinlock_t ls_cb_lock; 63623e8e1aaSDavid Teigland struct list_head ls_cb_delay; /* save for queue_work later */ 637e7fd4179SDavid Teigland struct timer_list ls_timer; 638e7fd4179SDavid Teigland struct task_struct *ls_recoverd_task; 63990135925SDavid Teigland struct mutex ls_recoverd_active; 640e7fd4179SDavid Teigland spinlock_t ls_recover_lock; 6413ae1acf9SDavid Teigland unsigned long ls_recover_begin; /* jiffies timestamp */ 642e7fd4179SDavid Teigland uint32_t ls_recover_status; /* DLM_RS_ */ 643e7fd4179SDavid Teigland uint64_t ls_recover_seq; 644e7fd4179SDavid Teigland struct dlm_recover *ls_recover_args; 645e7fd4179SDavid Teigland struct rw_semaphore ls_in_recovery; /* block local requests */ 646c36258b5SDavid Teigland struct rw_semaphore ls_recv_active; /* block dlm_recv */ 647e7fd4179SDavid Teigland struct list_head ls_requestqueue;/* queue remote requests */ 648164d88abSAlexander Aring atomic_t ls_requestqueue_cnt; 649164d88abSAlexander Aring wait_queue_head_t ls_requestqueue_wait; 65090135925SDavid Teigland struct mutex ls_requestqueue_mutex; 6514007685cSAl Viro struct dlm_rcom *ls_recover_buf; 652faa0f267SDavid Teigland int ls_recover_nodeid; /* for debugging */ 653c04fecb4SDavid Teigland unsigned int ls_recover_dir_sent_res; /* for log info */ 654c04fecb4SDavid Teigland unsigned int ls_recover_dir_sent_msg; /* for log info */ 6554875647aSDavid Teigland unsigned int ls_recover_locks_in; /* for log info */ 6564a99c3d9SDavid Teigland uint64_t ls_rcom_seq; 65798f176fbSDavid Teigland spinlock_t ls_rcom_spin; 658e7fd4179SDavid Teigland struct list_head ls_recover_list; 659e7fd4179SDavid Teigland spinlock_t ls_recover_list_lock; 660e7fd4179SDavid Teigland int ls_recover_list_count; 6611d7c484eSDavid Teigland struct idr ls_recover_idr; 6621d7c484eSDavid Teigland spinlock_t ls_recover_idr_lock; 663e7fd4179SDavid Teigland wait_queue_head_t ls_wait_general; 664475f230cSDavid Teigland wait_queue_head_t ls_recover_lock_wait; 665296d9d1eSAlexander Aring spinlock_t ls_clear_proc_locks; 666e7fd4179SDavid Teigland 667e7fd4179SDavid Teigland struct list_head ls_root_list; /* root resources */ 668e7fd4179SDavid Teigland struct rw_semaphore ls_root_sem; /* protect root_list */ 669e7fd4179SDavid Teigland 67060f98d18SDavid Teigland const struct dlm_lockspace_ops *ls_ops; 67160f98d18SDavid Teigland void *ls_ops_arg; 67260f98d18SDavid Teigland 673e7fd4179SDavid Teigland int ls_namelen; 674d96d0f96SPaulo Miguel Almeida char ls_name[DLM_LOCKSPACE_LEN + 1]; 675e7fd4179SDavid Teigland }; 676e7fd4179SDavid Teigland 677475f230cSDavid Teigland /* 678475f230cSDavid Teigland * LSFL_RECOVER_STOP - dlm_ls_stop() sets this to tell dlm recovery routines 679475f230cSDavid Teigland * that they should abort what they're doing so new recovery can be started. 680475f230cSDavid Teigland * 681475f230cSDavid Teigland * LSFL_RECOVER_DOWN - dlm_ls_stop() sets this to tell dlm_recoverd that it 682475f230cSDavid Teigland * should do down_write() on the in_recovery rw_semaphore. (doing down_write 683475f230cSDavid Teigland * within dlm_ls_stop causes complaints about the lock acquired/released 684475f230cSDavid Teigland * in different contexts.) 685475f230cSDavid Teigland * 686475f230cSDavid Teigland * LSFL_RECOVER_LOCK - dlm_recoverd holds the in_recovery rw_semaphore. 687475f230cSDavid Teigland * It sets this after it is done with down_write() on the in_recovery 688475f230cSDavid Teigland * rw_semaphore and clears it after it has released the rw_semaphore. 689475f230cSDavid Teigland * 690475f230cSDavid Teigland * LSFL_RECOVER_WORK - dlm_ls_start() sets this to tell dlm_recoverd that it 691475f230cSDavid Teigland * should begin recovery of the lockspace. 692475f230cSDavid Teigland * 693475f230cSDavid Teigland * LSFL_RUNNING - set when normal locking activity is enabled. 694475f230cSDavid Teigland * dlm_ls_stop() clears this to tell dlm locking routines that they should 695475f230cSDavid Teigland * quit what they are doing so recovery can run. dlm_recoverd sets 696475f230cSDavid Teigland * this after recovery is finished. 697475f230cSDavid Teigland */ 698475f230cSDavid Teigland 699475f230cSDavid Teigland #define LSFL_RECOVER_STOP 0 700475f230cSDavid Teigland #define LSFL_RECOVER_DOWN 1 701475f230cSDavid Teigland #define LSFL_RECOVER_LOCK 2 702475f230cSDavid Teigland #define LSFL_RECOVER_WORK 3 703475f230cSDavid Teigland #define LSFL_RUNNING 4 704475f230cSDavid Teigland 705475f230cSDavid Teigland #define LSFL_RCOM_READY 5 706475f230cSDavid Teigland #define LSFL_RCOM_WAIT 6 707475f230cSDavid Teigland #define LSFL_UEVENT_WAIT 7 7086b0afc0cSAlexander Aring #ifdef CONFIG_DLM_DEPRECATED_API 709475f230cSDavid Teigland #define LSFL_TIMEWARN 8 7106b0afc0cSAlexander Aring #endif 711475f230cSDavid Teigland #define LSFL_CB_DELAY 9 712475f230cSDavid Teigland #define LSFL_NODIR 10 713e7fd4179SDavid Teigland 714597d0caeSDavid Teigland /* much of this is just saving user space pointers associated with the 715597d0caeSDavid Teigland lock that we pass back to the user lib with an ast */ 716597d0caeSDavid Teigland 717597d0caeSDavid Teigland struct dlm_user_args { 718597d0caeSDavid Teigland struct dlm_user_proc *proc; /* each process that opens the lockspace 719597d0caeSDavid Teigland device has private data 720597d0caeSDavid Teigland (dlm_user_proc) on the struct file, 721597d0caeSDavid Teigland the process's locks point back to it*/ 722597d0caeSDavid Teigland struct dlm_lksb lksb; 723597d0caeSDavid Teigland struct dlm_lksb __user *user_lksb; 724597d0caeSDavid Teigland void __user *castparam; 725597d0caeSDavid Teigland void __user *castaddr; 726597d0caeSDavid Teigland void __user *bastparam; 727597d0caeSDavid Teigland void __user *bastaddr; 728d7db923eSDavid Teigland uint64_t xid; 729597d0caeSDavid Teigland }; 730597d0caeSDavid Teigland 731597d0caeSDavid Teigland #define DLM_PROC_FLAGS_CLOSING 1 732597d0caeSDavid Teigland #define DLM_PROC_FLAGS_COMPAT 2 733597d0caeSDavid Teigland 734597d0caeSDavid Teigland /* locks list is kept so we can remove all a process's locks when it 735597d0caeSDavid Teigland exits (or orphan those that are persistent) */ 736597d0caeSDavid Teigland 737597d0caeSDavid Teigland struct dlm_user_proc { 738597d0caeSDavid Teigland dlm_lockspace_t *lockspace; 739597d0caeSDavid Teigland unsigned long flags; /* DLM_PROC_FLAGS */ 740597d0caeSDavid Teigland struct list_head asts; 741597d0caeSDavid Teigland spinlock_t asts_spin; 742597d0caeSDavid Teigland struct list_head locks; 743597d0caeSDavid Teigland spinlock_t locks_spin; 744a1bc86e6SDavid Teigland struct list_head unlocking; 745597d0caeSDavid Teigland wait_queue_head_t wait; 746597d0caeSDavid Teigland }; 747597d0caeSDavid Teigland 748e7fd4179SDavid Teigland static inline int dlm_locking_stopped(struct dlm_ls *ls) 749e7fd4179SDavid Teigland { 750e7fd4179SDavid Teigland return !test_bit(LSFL_RUNNING, &ls->ls_flags); 751e7fd4179SDavid Teigland } 752e7fd4179SDavid Teigland 753e7fd4179SDavid Teigland static inline int dlm_recovery_stopped(struct dlm_ls *ls) 754e7fd4179SDavid Teigland { 755475f230cSDavid Teigland return test_bit(LSFL_RECOVER_STOP, &ls->ls_flags); 756e7fd4179SDavid Teigland } 757e7fd4179SDavid Teigland 758e7fd4179SDavid Teigland static inline int dlm_no_directory(struct dlm_ls *ls) 759e7fd4179SDavid Teigland { 7604875647aSDavid Teigland return test_bit(LSFL_NODIR, &ls->ls_flags); 761e7fd4179SDavid Teigland } 762e7fd4179SDavid Teigland 7636b0afc0cSAlexander Aring #ifdef CONFIG_DLM_DEPRECATED_API 764e028398dSAdrian Bunk int dlm_netlink_init(void); 765e028398dSAdrian Bunk void dlm_netlink_exit(void); 766e028398dSAdrian Bunk void dlm_timeout_warn(struct dlm_lkb *lkb); 7676b0afc0cSAlexander Aring #else 7686b0afc0cSAlexander Aring static inline int dlm_netlink_init(void) { return 0; } 7696b0afc0cSAlexander Aring static inline void dlm_netlink_exit(void) { }; 7706b0afc0cSAlexander Aring static inline void dlm_timeout_warn(struct dlm_lkb *lkb) { }; 7716b0afc0cSAlexander Aring #endif 7722402211aSDavid Teigland int dlm_plock_init(void); 7732402211aSDavid Teigland void dlm_plock_exit(void); 774e028398dSAdrian Bunk 775e028398dSAdrian Bunk #ifdef CONFIG_DLM_DEBUG 776a48f9721SGreg Kroah-Hartman void dlm_register_debugfs(void); 777e028398dSAdrian Bunk void dlm_unregister_debugfs(void); 778a48f9721SGreg Kroah-Hartman void dlm_create_debug_file(struct dlm_ls *ls); 779e028398dSAdrian Bunk void dlm_delete_debug_file(struct dlm_ls *ls); 7805b2f981fSAlexander Aring void *dlm_create_debug_comms_file(int nodeid, void *data); 7815b2f981fSAlexander Aring void dlm_delete_debug_comms_file(void *ctx); 782e028398dSAdrian Bunk #else 783a48f9721SGreg Kroah-Hartman static inline void dlm_register_debugfs(void) { } 784e028398dSAdrian Bunk static inline void dlm_unregister_debugfs(void) { } 785a48f9721SGreg Kroah-Hartman static inline void dlm_create_debug_file(struct dlm_ls *ls) { } 786e028398dSAdrian Bunk static inline void dlm_delete_debug_file(struct dlm_ls *ls) { } 7875b2f981fSAlexander Aring static inline void *dlm_create_debug_comms_file(int nodeid, void *data) { return NULL; } 7885b2f981fSAlexander Aring static inline void dlm_delete_debug_comms_file(void *ctx) { } 789e028398dSAdrian Bunk #endif 790e028398dSAdrian Bunk 791e7fd4179SDavid Teigland #endif /* __DLM_INTERNAL_DOT_H__ */ 792e7fd4179SDavid Teigland 793