VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   32 Branches   54 Tags
2522fe45a186e (Thomas Gleixner     2019-05-28 09:57:20 -0700   1) /* SPDX-License-Identifier: GPL-2.0-only */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000   2) /******************************************************************************
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000   3) *******************************************************************************
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000   4) **
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000   5) **  Copyright (C) Sistina Software, Inc.  1997-2003  All rights reserved.
60f98d1839376 (David Teigland      2011-11-02 14:30:58 -0500   6) **  Copyright (C) 2004-2011 Red Hat, Inc.  All rights reserved.
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000   7) **
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000   8) **
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000   9) *******************************************************************************
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  10) ******************************************************************************/
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  11) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  12) #ifndef __DLM_INTERNAL_DOT_H__
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  13) #define __DLM_INTERNAL_DOT_H__
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  14) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  15) /*
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  16)  * This is the main header file to be included in each DLM source file.
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  17)  */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  18) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  19) #include <linux/slab.h>
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  20) #include <linux/sched.h>
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  21) #include <linux/types.h>
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  22) #include <linux/ctype.h>
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  23) #include <linux/spinlock.h>
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  24) #include <linux/vmalloc.h>
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  25) #include <linux/list.h>
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  26) #include <linux/errno.h>
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  27) #include <linux/random.h>
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  28) #include <linux/delay.h>
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  29) #include <linux/socket.h>
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  30) #include <linux/kthread.h>
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  31) #include <linux/kobject.h>
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  32) #include <linux/kref.h>
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  33) #include <linux/kernel.h>
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  34) #include <linux/jhash.h>
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500  35) #include <linux/miscdevice.h>
901359256b266 (David Teigland      2006-01-20 08:47:07 +0000  36) #include <linux/mutex.h>
3d6aa675fff9e (David Teigland      2011-07-06 17:00:54 -0500  37) #include <linux/idr.h>
d6e24788d21c4 (David Teigland      2012-04-23 13:58:42 -0500  38) #include <linux/ratelimit.h>
7c0f6ba682b9c (Linus Torvalds      2016-12-24 11:46:01 -0800  39) #include <linux/uaccess.h>
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  40) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  41) #include <linux/dlm.h>
99fc64874aad1 (David Teigland      2007-01-09 09:44:01 -0600  42) #include "config.h"
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  43) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  44) /* Size of the temp buffer midcomms allocates on the stack.
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  45)    We try to make this large enough so most messages fit.
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  46)    FIXME: should sctp make this unnecessary? */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  47) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  48) #define DLM_INBUF_LEN		148
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  49) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  50) struct dlm_ls;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  51) struct dlm_lkb;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  52) struct dlm_rsb;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  53) struct dlm_member;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  54) struct dlm_rsbtable;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  55) struct dlm_recover;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  56) struct dlm_header;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  57) struct dlm_message;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  58) struct dlm_rcom;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  59) struct dlm_mhandle;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  60) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  61) #define log_print(fmt, args...) \
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  62) 	printk(KERN_ERR "dlm: "fmt"\n" , ##args)
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  63) #define log_error(ls, fmt, args...) \
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  64) 	printk(KERN_ERR "dlm: %s: " fmt "\n", (ls)->ls_name , ##args)
505ee5283c3d2 (Zhilong Liu         2016-06-19 23:52:46 -0500  65) 
075f01775f536 (David Teigland      2014-02-14 11:54:44 -0600  66) #define log_rinfo(ls, fmt, args...) \
505ee5283c3d2 (Zhilong Liu         2016-06-19 23:52:46 -0500  67) do { \
505ee5283c3d2 (Zhilong Liu         2016-06-19 23:52:46 -0500  68) 	if (dlm_config.ci_log_info) \
505ee5283c3d2 (Zhilong Liu         2016-06-19 23:52:46 -0500  69) 		printk(KERN_INFO "dlm: %s: " fmt "\n", \
505ee5283c3d2 (Zhilong Liu         2016-06-19 23:52:46 -0500  70) 			(ls)->ls_name, ##args); \
505ee5283c3d2 (Zhilong Liu         2016-06-19 23:52:46 -0500  71) 	else if (dlm_config.ci_log_debug) \
505ee5283c3d2 (Zhilong Liu         2016-06-19 23:52:46 -0500  72) 		printk(KERN_DEBUG "dlm: %s: " fmt "\n", \
505ee5283c3d2 (Zhilong Liu         2016-06-19 23:52:46 -0500  73) 		       (ls)->ls_name , ##args); \
505ee5283c3d2 (Zhilong Liu         2016-06-19 23:52:46 -0500  74) } while (0)
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  75) 
99fc64874aad1 (David Teigland      2007-01-09 09:44:01 -0600  76) #define log_debug(ls, fmt, args...) \
99fc64874aad1 (David Teigland      2007-01-09 09:44:01 -0600  77) do { \
99fc64874aad1 (David Teigland      2007-01-09 09:44:01 -0600  78) 	if (dlm_config.ci_log_debug) \
99fc64874aad1 (David Teigland      2007-01-09 09:44:01 -0600  79) 		printk(KERN_DEBUG "dlm: %s: " fmt "\n", \
99fc64874aad1 (David Teigland      2007-01-09 09:44:01 -0600  80) 		       (ls)->ls_name , ##args); \
99fc64874aad1 (David Teigland      2007-01-09 09:44:01 -0600  81) } while (0)
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  82) 
d6e24788d21c4 (David Teigland      2012-04-23 13:58:42 -0500  83) #define log_limit(ls, fmt, args...) \
d6e24788d21c4 (David Teigland      2012-04-23 13:58:42 -0500  84) do { \
d6e24788d21c4 (David Teigland      2012-04-23 13:58:42 -0500  85) 	if (dlm_config.ci_log_debug) \
d6e24788d21c4 (David Teigland      2012-04-23 13:58:42 -0500  86) 		printk_ratelimited(KERN_DEBUG "dlm: %s: " fmt "\n", \
d6e24788d21c4 (David Teigland      2012-04-23 13:58:42 -0500  87) 			(ls)->ls_name , ##args); \
d6e24788d21c4 (David Teigland      2012-04-23 13:58:42 -0500  88) } while (0)
d6e24788d21c4 (David Teigland      2012-04-23 13:58:42 -0500  89) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  90) #define DLM_ASSERT(x, do) \
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  91) { \
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  92)   if (!(x)) \
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  93)   { \
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  94)     printk(KERN_ERR "\nDLM:  Assertion failed on line %d of file %s\n" \
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  95)                "DLM:  assertion:  \"%s\"\n" \
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  96)                "DLM:  time = %lu\n", \
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  97)                __LINE__, __FILE__, #x, jiffies); \
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  98)     {do} \
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000  99)     printk("\n"); \
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 100)     panic("DLM:  Record message above and reboot.\n"); \
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 101)   } \
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 102) }
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 103) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 104) 
f11722834605a (David Teigland      2013-01-07 11:03:42 -0600 105) #define DLM_RTF_SHRINK		0x00000001
f11722834605a (David Teigland      2013-01-07 11:03:42 -0600 106) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 107) struct dlm_rsbtable {
9beb3bf5a92bb (Bob Peterson        2011-10-26 15:24:55 -0500 108) 	struct rb_root		keep;
9beb3bf5a92bb (Bob Peterson        2011-10-26 15:24:55 -0500 109) 	struct rb_root		toss;
c7be761a8163d (David Teigland      2009-01-07 16:50:41 -0600 110) 	spinlock_t		lock;
f11722834605a (David Teigland      2013-01-07 11:03:42 -0600 111) 	uint32_t		flags;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 112) };
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 113) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 114) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 115) /*
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 116)  * Lockspace member (per node in a ls)
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 117)  */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 118) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 119) struct dlm_member {
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 120) 	struct list_head	list;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 121) 	int			nodeid;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 122) 	int			weight;
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 123) 	int			slot;
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 124) 	int			slot_prev;
60f98d1839376 (David Teigland      2011-11-02 14:30:58 -0500 125) 	int			comm_seq;
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 126) 	uint32_t		generation;
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 127) };
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 128) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 129) /*
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 130)  * Save and manage recovery state for a lockspace.
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 131)  */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 132) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 133) struct dlm_recover {
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 134) 	struct list_head	list;
60f98d1839376 (David Teigland      2011-11-02 14:30:58 -0500 135) 	struct dlm_config_node	*nodes;
60f98d1839376 (David Teigland      2011-11-02 14:30:58 -0500 136) 	int			nodes_count;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 137) 	uint64_t		seq;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 138) };
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 139) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 140) /*
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 141)  * Pass input args to second stage locking function.
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 142)  */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 143) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 144) struct dlm_args {
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 145) 	uint32_t		flags;
e5dae548b0b53 (David Teigland      2008-02-06 00:35:45 -0600 146) 	void			(*astfn) (void *astparam);
e5dae548b0b53 (David Teigland      2008-02-06 00:35:45 -0600 147) 	void			*astparam;
e5dae548b0b53 (David Teigland      2008-02-06 00:35:45 -0600 148) 	void			(*bastfn) (void *astparam, int mode);
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 149) 	int			mode;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 150) 	struct dlm_lksb		*lksb;
d7db923ea4990 (David Teigland      2007-05-18 09:00:32 -0500 151) 	unsigned long		timeout;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 152) };
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 153) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 154) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 155) /*
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 156)  * Lock block
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 157)  *
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 158)  * A lock can be one of three types:
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 159)  *
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 160)  * local copy      lock is mastered locally
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 161)  *                 (lkb_nodeid is zero and DLM_LKF_MSTCPY is not set)
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 162)  * process copy    lock is mastered on a remote node
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 163)  *                 (lkb_nodeid is non-zero and DLM_LKF_MSTCPY is not set)
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 164)  * master copy     master node's copy of a lock owned by remote node
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 165)  *                 (lkb_nodeid is non-zero and DLM_LKF_MSTCPY is set)
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 166)  *
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 167)  * lkb_exflags: a copy of the most recent flags arg provided to dlm_lock or
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 168)  * dlm_unlock.  The dlm does not modify these or use any private flags in
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 169)  * this field; it only contains DLM_LKF_ flags from dlm.h.  These flags
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 170)  * are sent as-is to the remote master when the lock is remote.
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 171)  *
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 172)  * lkb_flags: internal dlm flags (DLM_IFL_ prefix) from dlm_internal.h.
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 173)  * Some internal flags are shared between the master and process nodes;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 174)  * these shared flags are kept in the lower two bytes.  One of these
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 175)  * flags set on the master copy will be propagated to the process copy
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 176)  * and v.v.  Other internal flags are private to the master or process
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 177)  * node (e.g. DLM_IFL_MSTCPY).  These are kept in the high two bytes.
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 178)  *
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 179)  * lkb_sbflags: status block flags.  These flags are copied directly into
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 180)  * the caller's lksb.sb_flags prior to the dlm_lock/dlm_unlock completion
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 181)  * ast.  All defined in dlm.h with DLM_SBF_ prefix.
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 182)  *
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 183)  * lkb_status: the lock status indicates which rsb queue the lock is
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 184)  * on, grant, convert, or wait.  DLM_LKSTS_ WAITING/GRANTED/CONVERT
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 185)  *
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 186)  * lkb_wait_type: the dlm message type (DLM_MSG_ prefix) for which a
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 187)  * reply is needed.  Only set when the lkb is on the lockspace waiters
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 188)  * list awaiting a reply from a remote node.
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 189)  *
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 190)  * lkb_nodeid: when the lkb is a local copy, nodeid is 0; when the lkb
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 191)  * is a master copy, nodeid specifies the remote lock holder, when the
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 192)  * lkb is a process copy, the nodeid specifies the lock master.
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 193)  */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 194) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 195) /* lkb_status */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 196) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 197) #define DLM_LKSTS_WAITING	1
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 198) #define DLM_LKSTS_GRANTED	2
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 199) #define DLM_LKSTS_CONVERT	3
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 200) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 201) /* lkb_flags */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 202) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 203) #define DLM_IFL_MSTCPY		0x00010000
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 204) #define DLM_IFL_RESEND		0x00020000
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 205) #define DLM_IFL_DEAD		0x00040000
ef0c2bb05f40f (David Teigland      2007-03-28 09:56:46 -0500 206) #define DLM_IFL_OVERLAP_UNLOCK  0x00080000
ef0c2bb05f40f (David Teigland      2007-03-28 09:56:46 -0500 207) #define DLM_IFL_OVERLAP_CANCEL  0x00100000
ef0c2bb05f40f (David Teigland      2007-03-28 09:56:46 -0500 208) #define DLM_IFL_ENDOFLIFE	0x00200000
3ae1acf93a215 (David Teigland      2007-05-18 08:59:31 -0500 209) #define DLM_IFL_WATCH_TIMEWARN	0x00400000
84d8cd69a8e7f (David Teigland      2007-05-29 08:44:23 -0500 210) #define DLM_IFL_TIMEOUT_CANCEL	0x00800000
8b4021fa436f7 (David Teigland      2007-05-29 08:46:00 -0500 211) #define DLM_IFL_DEADLOCK_CANCEL	0x01000000
2a7ce0edd661b (David Teigland      2011-04-04 15:19:59 -0500 212) #define DLM_IFL_STUB_MS		0x02000000 /* magic number for m_flags */
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 213) #define DLM_IFL_USER		0x00000001
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 214) #define DLM_IFL_ORPHAN		0x00000002
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 215) 
8304d6f24cc12 (David Teigland      2011-02-21 14:58:21 -0600 216) #define DLM_CALLBACKS_SIZE	6
8304d6f24cc12 (David Teigland      2011-02-21 14:58:21 -0600 217) 
8304d6f24cc12 (David Teigland      2011-02-21 14:58:21 -0600 218) #define DLM_CB_CAST		0x00000001
8304d6f24cc12 (David Teigland      2011-02-21 14:58:21 -0600 219) #define DLM_CB_BAST		0x00000002
8304d6f24cc12 (David Teigland      2011-02-21 14:58:21 -0600 220) #define DLM_CB_SKIP		0x00000004
8304d6f24cc12 (David Teigland      2011-02-21 14:58:21 -0600 221) 
8304d6f24cc12 (David Teigland      2011-02-21 14:58:21 -0600 222) struct dlm_callback {
8304d6f24cc12 (David Teigland      2011-02-21 14:58:21 -0600 223) 	uint64_t		seq;
8304d6f24cc12 (David Teigland      2011-02-21 14:58:21 -0600 224) 	uint32_t		flags;		/* DLM_CBF_ */
8304d6f24cc12 (David Teigland      2011-02-21 14:58:21 -0600 225) 	int			sb_status;	/* copy to lksb status */
8304d6f24cc12 (David Teigland      2011-02-21 14:58:21 -0600 226) 	uint8_t			sb_flags;	/* copy to lksb flags */
8304d6f24cc12 (David Teigland      2011-02-21 14:58:21 -0600 227) 	int8_t			mode; /* rq mode of bast, gr mode of cast */
8304d6f24cc12 (David Teigland      2011-02-21 14:58:21 -0600 228) };
8304d6f24cc12 (David Teigland      2011-02-21 14:58:21 -0600 229) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 230) struct dlm_lkb {
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 231) 	struct dlm_rsb		*lkb_resource;	/* the rsb */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 232) 	struct kref		lkb_ref;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 233) 	int			lkb_nodeid;	/* copied from rsb */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 234) 	int			lkb_ownpid;	/* pid of lock owner */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 235) 	uint32_t		lkb_id;		/* our lock ID */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 236) 	uint32_t		lkb_remid;	/* lock ID on remote partner */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 237) 	uint32_t		lkb_exflags;	/* external flags from caller */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 238) 	uint32_t		lkb_sbflags;	/* lksb flags */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 239) 	uint32_t		lkb_flags;	/* internal flags */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 240) 	uint32_t		lkb_lvbseq;	/* lvb sequence number */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 241) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 242) 	int8_t			lkb_status;     /* granted, waiting, convert */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 243) 	int8_t			lkb_rqmode;	/* requested lock mode */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 244) 	int8_t			lkb_grmode;	/* granted lock mode */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 245) 	int8_t			lkb_highbast;	/* highest mode bast sent for */
7fe2b3190b8b2 (David Teigland      2010-02-24 11:08:18 -0600 246) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 247) 	int8_t			lkb_wait_type;	/* type of reply waiting for */
ef0c2bb05f40f (David Teigland      2007-03-28 09:56:46 -0500 248) 	int8_t			lkb_wait_count;
c6ff669bac5c4 (David Teigland      2011-03-28 14:17:26 -0500 249) 	int			lkb_wait_nodeid; /* for debugging */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 250) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 251) 	struct list_head	lkb_statequeue;	/* rsb g/c/w list */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 252) 	struct list_head	lkb_rsb_lookup;	/* waiting for rsb lookup */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 253) 	struct list_head	lkb_wait_reply;	/* waiting for remote reply */
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 254) 	struct list_head	lkb_ownqueue;	/* list of locks for a process */
3ae1acf93a215 (David Teigland      2007-05-18 08:59:31 -0500 255) 	struct list_head	lkb_time_list;
eeda418d8c264 (David Teigland      2008-12-09 14:12:21 -0600 256) 	ktime_t			lkb_timestamp;
c6ff669bac5c4 (David Teigland      2011-03-28 14:17:26 -0500 257) 	ktime_t			lkb_wait_time;
3ae1acf93a215 (David Teigland      2007-05-18 08:59:31 -0500 258) 	unsigned long		lkb_timeout_cs;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 259) 
23e8e1aaacb10 (David Teigland      2011-04-05 13:16:24 -0500 260) 	struct mutex		lkb_cb_mutex;
23e8e1aaacb10 (David Teigland      2011-04-05 13:16:24 -0500 261) 	struct work_struct	lkb_cb_work;
23e8e1aaacb10 (David Teigland      2011-04-05 13:16:24 -0500 262) 	struct list_head	lkb_cb_list; /* for ls_cb_delay or proc->asts */
8304d6f24cc12 (David Teigland      2011-02-21 14:58:21 -0600 263) 	struct dlm_callback	lkb_callbacks[DLM_CALLBACKS_SIZE];
8304d6f24cc12 (David Teigland      2011-02-21 14:58:21 -0600 264) 	struct dlm_callback	lkb_last_cast;
8304d6f24cc12 (David Teigland      2011-02-21 14:58:21 -0600 265) 	struct dlm_callback	lkb_last_bast;
8304d6f24cc12 (David Teigland      2011-02-21 14:58:21 -0600 266) 	ktime_t			lkb_last_cast_time;	/* for debugging */
8304d6f24cc12 (David Teigland      2011-02-21 14:58:21 -0600 267) 	ktime_t			lkb_last_bast_time;	/* for debugging */
8304d6f24cc12 (David Teigland      2011-02-21 14:58:21 -0600 268) 
4875647a08e35 (David Teigland      2012-04-26 15:54:29 -0500 269) 	uint64_t		lkb_recover_seq; /* from ls_recover_seq */
4875647a08e35 (David Teigland      2012-04-26 15:54:29 -0500 270) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 271) 	char			*lkb_lvbptr;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 272) 	struct dlm_lksb		*lkb_lksb;      /* caller's status block */
e5dae548b0b53 (David Teigland      2008-02-06 00:35:45 -0600 273) 	void			(*lkb_astfn) (void *astparam);
e5dae548b0b53 (David Teigland      2008-02-06 00:35:45 -0600 274) 	void			(*lkb_bastfn) (void *astparam, int mode);
d292c0cc489fa (David Teigland      2008-02-06 23:27:04 -0600 275) 	union {
d292c0cc489fa (David Teigland      2008-02-06 23:27:04 -0600 276) 		void			*lkb_astparam;	/* caller's ast arg */
d292c0cc489fa (David Teigland      2008-02-06 23:27:04 -0600 277) 		struct dlm_user_args	*lkb_ua;
d292c0cc489fa (David Teigland      2008-02-06 23:27:04 -0600 278) 	};
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 279) };
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 280) 
c04fecb4d9f77 (David Teigland      2012-05-10 10:18:07 -0500 281) /*
c04fecb4d9f77 (David Teigland      2012-05-10 10:18:07 -0500 282)  * res_master_nodeid is "normal": 0 is unset/invalid, non-zero is the real
c04fecb4d9f77 (David Teigland      2012-05-10 10:18:07 -0500 283)  * nodeid, even when nodeid is our_nodeid.
c04fecb4d9f77 (David Teigland      2012-05-10 10:18:07 -0500 284)  *
c04fecb4d9f77 (David Teigland      2012-05-10 10:18:07 -0500 285)  * res_nodeid is "odd": -1 is unset/invalid, zero means our_nodeid,
c04fecb4d9f77 (David Teigland      2012-05-10 10:18:07 -0500 286)  * greater than zero when another nodeid.
c04fecb4d9f77 (David Teigland      2012-05-10 10:18:07 -0500 287)  *
c04fecb4d9f77 (David Teigland      2012-05-10 10:18:07 -0500 288)  * (TODO: remove res_nodeid and only use res_master_nodeid)
c04fecb4d9f77 (David Teigland      2012-05-10 10:18:07 -0500 289)  */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 290) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 291) struct dlm_rsb {
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 292) 	struct dlm_ls		*res_ls;	/* the lockspace */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 293) 	struct kref		res_ref;
901359256b266 (David Teigland      2006-01-20 08:47:07 +0000 294) 	struct mutex		res_mutex;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 295) 	unsigned long		res_flags;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 296) 	int			res_length;	/* length of rsb name */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 297) 	int			res_nodeid;
c04fecb4d9f77 (David Teigland      2012-05-10 10:18:07 -0500 298) 	int			res_master_nodeid;
c04fecb4d9f77 (David Teigland      2012-05-10 10:18:07 -0500 299) 	int			res_dir_nodeid;
1d7c484eeb167 (David Teigland      2012-05-15 16:07:49 -0500 300) 	int			res_id;		/* for ls_recover_idr */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 301) 	uint32_t                res_lvbseq;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 302) 	uint32_t		res_hash;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 303) 	uint32_t		res_bucket;	/* rsbtbl */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 304) 	unsigned long		res_toss_time;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 305) 	uint32_t		res_first_lkid;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 306) 	struct list_head	res_lookup;	/* lkbs waiting on first */
9beb3bf5a92bb (Bob Peterson        2011-10-26 15:24:55 -0500 307) 	union {
9beb3bf5a92bb (Bob Peterson        2011-10-26 15:24:55 -0500 308) 		struct list_head	res_hashchain;
9beb3bf5a92bb (Bob Peterson        2011-10-26 15:24:55 -0500 309) 		struct rb_node		res_hashnode;	/* rsbtbl */
9beb3bf5a92bb (Bob Peterson        2011-10-26 15:24:55 -0500 310) 	};
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 311) 	struct list_head	res_grantqueue;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 312) 	struct list_head	res_convertqueue;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 313) 	struct list_head	res_waitqueue;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 314) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 315) 	struct list_head	res_root_list;	    /* used for recovery */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 316) 	struct list_head	res_recover_list;   /* used for recovery */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 317) 	int			res_recover_locks_count;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 318) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 319) 	char			*res_lvbptr;
3881ac04ebf94 (David Teigland      2011-07-07 14:05:03 -0500 320) 	char			res_name[DLM_RESNAME_MAXLEN+1];
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 321) };
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 322) 
c04fecb4d9f77 (David Teigland      2012-05-10 10:18:07 -0500 323) /* dlm_master_lookup() flags */
c04fecb4d9f77 (David Teigland      2012-05-10 10:18:07 -0500 324) 
c04fecb4d9f77 (David Teigland      2012-05-10 10:18:07 -0500 325) #define DLM_LU_RECOVER_DIR	1
c04fecb4d9f77 (David Teigland      2012-05-10 10:18:07 -0500 326) #define DLM_LU_RECOVER_MASTER	2
c04fecb4d9f77 (David Teigland      2012-05-10 10:18:07 -0500 327) 
c04fecb4d9f77 (David Teigland      2012-05-10 10:18:07 -0500 328) /* dlm_master_lookup() results */
c04fecb4d9f77 (David Teigland      2012-05-10 10:18:07 -0500 329) 
c04fecb4d9f77 (David Teigland      2012-05-10 10:18:07 -0500 330) #define DLM_LU_MATCH		1
c04fecb4d9f77 (David Teigland      2012-05-10 10:18:07 -0500 331) #define DLM_LU_ADD		2
c04fecb4d9f77 (David Teigland      2012-05-10 10:18:07 -0500 332) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 333) /* find_rsb() flags */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 334) 
c04fecb4d9f77 (David Teigland      2012-05-10 10:18:07 -0500 335) #define R_REQUEST		0x00000001
c04fecb4d9f77 (David Teigland      2012-05-10 10:18:07 -0500 336) #define R_RECEIVE_REQUEST	0x00000002
c04fecb4d9f77 (David Teigland      2012-05-10 10:18:07 -0500 337) #define R_RECEIVE_RECOVER	0x00000004
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 338) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 339) /* rsb_flags */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 340) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 341) enum rsb_flags {
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 342) 	RSB_MASTER_UNCERTAIN,
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 343) 	RSB_VALNOTVALID,
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 344) 	RSB_VALNOTVALID_PREV,
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 345) 	RSB_NEW_MASTER,
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 346) 	RSB_NEW_MASTER2,
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 347) 	RSB_RECOVER_CONVERT,
4875647a08e35 (David Teigland      2012-04-26 15:54:29 -0500 348) 	RSB_RECOVER_GRANT,
da8c66638ae68 (David Teigland      2012-11-15 15:01:51 -0600 349) 	RSB_RECOVER_LVB_INVAL,
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 350) };
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 351) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 352) static inline void rsb_set_flag(struct dlm_rsb *r, enum rsb_flags flag)
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 353) {
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 354) 	__set_bit(flag, &r->res_flags);
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 355) }
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 356) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 357) static inline void rsb_clear_flag(struct dlm_rsb *r, enum rsb_flags flag)
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 358) {
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 359) 	__clear_bit(flag, &r->res_flags);
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 360) }
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 361) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 362) static inline int rsb_flag(struct dlm_rsb *r, enum rsb_flags flag)
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 363) {
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 364) 	return test_bit(flag, &r->res_flags);
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 365) }
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 366) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 367) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 368) /* dlm_header is first element of all structs sent between nodes */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 369) 
38aa8b0c59c35 (David Teigland      2006-12-13 10:37:16 -0600 370) #define DLM_HEADER_MAJOR	0x00030000
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 371) #define DLM_HEADER_MINOR	0x00000001
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 372) 
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 373) #define DLM_HEADER_SLOTS	0x00000001
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 374) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 375) #define DLM_MSG			1
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 376) #define DLM_RCOM		2
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 377) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 378) struct dlm_header {
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 379) 	uint32_t		h_version;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 380) 	uint32_t		h_lockspace;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 381) 	uint32_t		h_nodeid;	/* nodeid of sender */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 382) 	uint16_t		h_length;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 383) 	uint8_t			h_cmd;		/* DLM_MSG, DLM_RCOM */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 384) 	uint8_t			h_pad;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 385) };
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 386) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 387) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 388) #define DLM_MSG_REQUEST		1
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 389) #define DLM_MSG_CONVERT		2
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 390) #define DLM_MSG_UNLOCK		3
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 391) #define DLM_MSG_CANCEL		4
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 392) #define DLM_MSG_REQUEST_REPLY	5
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 393) #define DLM_MSG_CONVERT_REPLY	6
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 394) #define DLM_MSG_UNLOCK_REPLY	7
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 395) #define DLM_MSG_CANCEL_REPLY	8
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 396) #define DLM_MSG_GRANT		9
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 397) #define DLM_MSG_BAST		10
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 398) #define DLM_MSG_LOOKUP		11
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 399) #define DLM_MSG_REMOVE		12
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 400) #define DLM_MSG_LOOKUP_REPLY	13
8499137d4ef18 (David Teigland      2007-03-30 15:02:40 -0500 401) #define DLM_MSG_PURGE		14
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 402) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 403) struct dlm_message {
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 404) 	struct dlm_header	m_header;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 405) 	uint32_t		m_type;		/* DLM_MSG_ */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 406) 	uint32_t		m_nodeid;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 407) 	uint32_t		m_pid;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 408) 	uint32_t		m_lkid;		/* lkid on sender */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 409) 	uint32_t		m_remid;	/* lkid on receiver */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 410) 	uint32_t		m_parent_lkid;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 411) 	uint32_t		m_parent_remid;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 412) 	uint32_t		m_exflags;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 413) 	uint32_t		m_sbflags;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 414) 	uint32_t		m_flags;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 415) 	uint32_t		m_lvbseq;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 416) 	uint32_t		m_hash;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 417) 	int			m_status;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 418) 	int			m_grmode;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 419) 	int			m_rqmode;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 420) 	int			m_bastmode;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 421) 	int			m_asts;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 422) 	int			m_result;	/* 0 or -EXXX */
a4e439a6f628a (Gustavo A. R. Silva 2020-03-09 10:56:08 -0500 423) 	char			m_extra[];	/* name or lvb */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 424) };
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 425) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 426) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 427) #define DLM_RS_NODES		0x00000001
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 428) #define DLM_RS_NODES_ALL	0x00000002
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 429) #define DLM_RS_DIR		0x00000004
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 430) #define DLM_RS_DIR_ALL		0x00000008
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 431) #define DLM_RS_LOCKS		0x00000010
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 432) #define DLM_RS_LOCKS_ALL	0x00000020
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 433) #define DLM_RS_DONE		0x00000040
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 434) #define DLM_RS_DONE_ALL		0x00000080
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 435) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 436) #define DLM_RCOM_STATUS		1
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 437) #define DLM_RCOM_NAMES		2
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 438) #define DLM_RCOM_LOOKUP		3
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 439) #define DLM_RCOM_LOCK		4
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 440) #define DLM_RCOM_STATUS_REPLY	5
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 441) #define DLM_RCOM_NAMES_REPLY	6
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 442) #define DLM_RCOM_LOOKUP_REPLY	7
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 443) #define DLM_RCOM_LOCK_REPLY	8
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 444) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 445) struct dlm_rcom {
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 446) 	struct dlm_header	rc_header;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 447) 	uint32_t		rc_type;	/* DLM_RCOM_ */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 448) 	int			rc_result;	/* multi-purpose */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 449) 	uint64_t		rc_id;		/* match reply with request */
38aa8b0c59c35 (David Teigland      2006-12-13 10:37:16 -0600 450) 	uint64_t		rc_seq;		/* sender's ls_recover_seq */
38aa8b0c59c35 (David Teigland      2006-12-13 10:37:16 -0600 451) 	uint64_t		rc_seq_reply;	/* remote ls_recover_seq */
a4e439a6f628a (Gustavo A. R. Silva 2020-03-09 10:56:08 -0500 452) 	char			rc_buf[];
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 453) };
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 454) 
eef7d739c218c (Al Viro             2008-01-25 00:58:46 -0500 455) union dlm_packet {
eef7d739c218c (Al Viro             2008-01-25 00:58:46 -0500 456) 	struct dlm_header	header;		/* common to other two */
eef7d739c218c (Al Viro             2008-01-25 00:58:46 -0500 457) 	struct dlm_message	message;
eef7d739c218c (Al Viro             2008-01-25 00:58:46 -0500 458) 	struct dlm_rcom		rcom;
eef7d739c218c (Al Viro             2008-01-25 00:58:46 -0500 459) };
eef7d739c218c (Al Viro             2008-01-25 00:58:46 -0500 460) 
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 461) #define DLM_RSF_NEED_SLOTS	0x00000001
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 462) 
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 463) /* RCOM_STATUS data */
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 464) struct rcom_status {
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 465) 	__le32			rs_flags;
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 466) 	__le32			rs_unused1;
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 467) 	__le64			rs_unused2;
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 468) };
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 469) 
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 470) /* RCOM_STATUS_REPLY data */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 471) struct rcom_config {
93ff2971e99c9 (Al Viro             2008-01-25 02:34:00 -0500 472) 	__le32			rf_lvblen;
93ff2971e99c9 (Al Viro             2008-01-25 02:34:00 -0500 473) 	__le32			rf_lsflags;
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 474) 
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 475) 	/* DLM_HEADER_SLOTS adds: */
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 476) 	__le32			rf_flags;
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 477) 	__le16			rf_our_slot;
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 478) 	__le16			rf_num_slots;
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 479) 	__le32			rf_generation;
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 480) 	__le32			rf_unused1;
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 481) 	__le64			rf_unused2;
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 482) };
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 483) 
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 484) struct rcom_slot {
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 485) 	__le32			ro_nodeid;
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 486) 	__le16			ro_slot;
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 487) 	__le16			ro_unused1;
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 488) 	__le64			ro_unused2;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 489) };
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 490) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 491) struct rcom_lock {
163a1859ec6c4 (Al Viro             2008-01-25 02:08:26 -0500 492) 	__le32			rl_ownpid;
163a1859ec6c4 (Al Viro             2008-01-25 02:08:26 -0500 493) 	__le32			rl_lkid;
163a1859ec6c4 (Al Viro             2008-01-25 02:08:26 -0500 494) 	__le32			rl_remid;
163a1859ec6c4 (Al Viro             2008-01-25 02:08:26 -0500 495) 	__le32			rl_parent_lkid;
163a1859ec6c4 (Al Viro             2008-01-25 02:08:26 -0500 496) 	__le32			rl_parent_remid;
163a1859ec6c4 (Al Viro             2008-01-25 02:08:26 -0500 497) 	__le32			rl_exflags;
163a1859ec6c4 (Al Viro             2008-01-25 02:08:26 -0500 498) 	__le32			rl_flags;
163a1859ec6c4 (Al Viro             2008-01-25 02:08:26 -0500 499) 	__le32			rl_lvbseq;
163a1859ec6c4 (Al Viro             2008-01-25 02:08:26 -0500 500) 	__le32			rl_result;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 501) 	int8_t			rl_rqmode;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 502) 	int8_t			rl_grmode;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 503) 	int8_t			rl_status;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 504) 	int8_t			rl_asts;
163a1859ec6c4 (Al Viro             2008-01-25 02:08:26 -0500 505) 	__le16			rl_wait_type;
163a1859ec6c4 (Al Viro             2008-01-25 02:08:26 -0500 506) 	__le16			rl_namelen;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 507) 	char			rl_name[DLM_RESNAME_MAXLEN];
a4e439a6f628a (Gustavo A. R. Silva 2020-03-09 10:56:08 -0500 508) 	char			rl_lvb[];
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 509) };
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 510) 
05c32f47bfae7 (David Teigland      2012-06-14 12:17:32 -0500 511) /*
05c32f47bfae7 (David Teigland      2012-06-14 12:17:32 -0500 512)  * The max number of resources per rsbtbl bucket that shrink will attempt
05c32f47bfae7 (David Teigland      2012-06-14 12:17:32 -0500 513)  * to remove in each iteration.
05c32f47bfae7 (David Teigland      2012-06-14 12:17:32 -0500 514)  */
05c32f47bfae7 (David Teigland      2012-06-14 12:17:32 -0500 515) 
05c32f47bfae7 (David Teigland      2012-06-14 12:17:32 -0500 516) #define DLM_REMOVE_NAMES_MAX 8
05c32f47bfae7 (David Teigland      2012-06-14 12:17:32 -0500 517) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 518) struct dlm_ls {
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 519) 	struct list_head	ls_list;	/* list of lockspaces */
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 520) 	dlm_lockspace_t		*ls_local_handle;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 521) 	uint32_t		ls_global_id;	/* global unique lockspace ID */
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 522) 	uint32_t		ls_generation;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 523) 	uint32_t		ls_exflags;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 524) 	int			ls_lvblen;
0f8e0d9a31740 (David Teigland      2008-08-06 13:30:24 -0500 525) 	int			ls_count;	/* refcount of processes in
0f8e0d9a31740 (David Teigland      2008-08-06 13:30:24 -0500 526) 						   the dlm using this ls */
0f8e0d9a31740 (David Teigland      2008-08-06 13:30:24 -0500 527) 	int			ls_create_count; /* create/release refcount */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 528) 	unsigned long		ls_flags;	/* LSFL_ */
c1dcf65ffc579 (David Teigland      2008-08-18 14:03:25 -0500 529) 	unsigned long		ls_scan_time;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 530) 	struct kobject		ls_kobj;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 531) 
3d6aa675fff9e (David Teigland      2011-07-06 17:00:54 -0500 532) 	struct idr		ls_lkbidr;
3d6aa675fff9e (David Teigland      2011-07-06 17:00:54 -0500 533) 	spinlock_t		ls_lkbidr_spin;
3d6aa675fff9e (David Teigland      2011-07-06 17:00:54 -0500 534) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 535) 	struct dlm_rsbtable	*ls_rsbtbl;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 536) 	uint32_t		ls_rsbtbl_size;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 537) 
901359256b266 (David Teigland      2006-01-20 08:47:07 +0000 538) 	struct mutex		ls_waiters_mutex;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 539) 	struct list_head	ls_waiters;	/* lkbs needing a reply */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 540) 
ef0c2bb05f40f (David Teigland      2007-03-28 09:56:46 -0500 541) 	struct mutex		ls_orphans_mutex;
ef0c2bb05f40f (David Teigland      2007-03-28 09:56:46 -0500 542) 	struct list_head	ls_orphans;
ef0c2bb05f40f (David Teigland      2007-03-28 09:56:46 -0500 543) 
3ae1acf93a215 (David Teigland      2007-05-18 08:59:31 -0500 544) 	struct mutex		ls_timeout_mutex;
3ae1acf93a215 (David Teigland      2007-05-18 08:59:31 -0500 545) 	struct list_head	ls_timeout;
3ae1acf93a215 (David Teigland      2007-05-18 08:59:31 -0500 546) 
3881ac04ebf94 (David Teigland      2011-07-07 14:05:03 -0500 547) 	spinlock_t		ls_new_rsb_spin;
3881ac04ebf94 (David Teigland      2011-07-07 14:05:03 -0500 548) 	int			ls_new_rsb_count;
3881ac04ebf94 (David Teigland      2011-07-07 14:05:03 -0500 549) 	struct list_head	ls_new_rsb;	/* new rsb structs */
3881ac04ebf94 (David Teigland      2011-07-07 14:05:03 -0500 550) 
05c32f47bfae7 (David Teigland      2012-06-14 12:17:32 -0500 551) 	spinlock_t		ls_remove_spin;
05c32f47bfae7 (David Teigland      2012-06-14 12:17:32 -0500 552) 	char			ls_remove_name[DLM_RESNAME_MAXLEN+1];
05c32f47bfae7 (David Teigland      2012-06-14 12:17:32 -0500 553) 	char			*ls_remove_names[DLM_REMOVE_NAMES_MAX];
05c32f47bfae7 (David Teigland      2012-06-14 12:17:32 -0500 554) 	int			ls_remove_len;
05c32f47bfae7 (David Teigland      2012-06-14 12:17:32 -0500 555) 	int			ls_remove_lens[DLM_REMOVE_NAMES_MAX];
05c32f47bfae7 (David Teigland      2012-06-14 12:17:32 -0500 556) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 557) 	struct list_head	ls_nodes;	/* current nodes in ls */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 558) 	struct list_head	ls_nodes_gone;	/* dead node list, recovery */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 559) 	int			ls_num_nodes;	/* number of nodes in ls */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 560) 	int			ls_low_nodeid;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 561) 	int			ls_total_weight;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 562) 	int			*ls_node_array;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 563) 
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 564) 	int			ls_slot;
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 565) 	int			ls_num_slots;
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 566) 	int			ls_slots_size;
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 567) 	struct dlm_slot		*ls_slots;
757a427196354 (David Teigland      2011-10-20 13:26:28 -0500 568) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 569) 	struct dlm_rsb		ls_stub_rsb;	/* for returning errors */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 570) 	struct dlm_lkb		ls_stub_lkb;	/* for returning errors */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 571) 	struct dlm_message	ls_stub_ms;	/* for faking a reply */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 572) 
5de6319b18393 (David Teigland      2006-07-25 13:44:31 -0500 573) 	struct dentry		*ls_debug_rsb_dentry; /* debugfs */
5de6319b18393 (David Teigland      2006-07-25 13:44:31 -0500 574) 	struct dentry		*ls_debug_waiters_dentry; /* debugfs */
ac90a25525009 (David Teigland      2007-07-06 09:47:08 -0500 575) 	struct dentry		*ls_debug_locks_dentry; /* debugfs */
d022509d1c54b (David Teigland      2008-12-16 14:53:23 -0600 576) 	struct dentry		*ls_debug_all_dentry; /* debugfs */
c04fecb4d9f77 (David Teigland      2012-05-10 10:18:07 -0500 577) 	struct dentry		*ls_debug_toss_dentry; /* debugfs */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 578) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 579) 	wait_queue_head_t	ls_uevent_wait;	/* user part of join/leave */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 580) 	int			ls_uevent_result;
8b0e7b2cf35aa (David Teigland      2007-05-18 09:03:35 -0500 581) 	struct completion	ls_members_done;
8b0e7b2cf35aa (David Teigland      2007-05-18 09:03:35 -0500 582) 	int			ls_members_result;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 583) 
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 584) 	struct miscdevice       ls_device;
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 585) 
23e8e1aaacb10 (David Teigland      2011-04-05 13:16:24 -0500 586) 	struct workqueue_struct	*ls_callback_wq;
23e8e1aaacb10 (David Teigland      2011-04-05 13:16:24 -0500 587) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 588) 	/* recovery related */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 589) 
23e8e1aaacb10 (David Teigland      2011-04-05 13:16:24 -0500 590) 	struct mutex		ls_cb_mutex;
23e8e1aaacb10 (David Teigland      2011-04-05 13:16:24 -0500 591) 	struct list_head	ls_cb_delay; /* save for queue_work later */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 592) 	struct timer_list	ls_timer;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 593) 	struct task_struct	*ls_recoverd_task;
901359256b266 (David Teigland      2006-01-20 08:47:07 +0000 594) 	struct mutex		ls_recoverd_active;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 595) 	spinlock_t		ls_recover_lock;
3ae1acf93a215 (David Teigland      2007-05-18 08:59:31 -0500 596) 	unsigned long		ls_recover_begin; /* jiffies timestamp */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 597) 	uint32_t		ls_recover_status; /* DLM_RS_ */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 598) 	uint64_t		ls_recover_seq;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 599) 	struct dlm_recover	*ls_recover_args;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 600) 	struct rw_semaphore	ls_in_recovery;	/* block local requests */
c36258b5925e6 (David Teigland      2007-09-27 15:53:38 -0500 601) 	struct rw_semaphore	ls_recv_active;	/* block dlm_recv */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 602) 	struct list_head	ls_requestqueue;/* queue remote requests */
901359256b266 (David Teigland      2006-01-20 08:47:07 +0000 603) 	struct mutex		ls_requestqueue_mutex;
4007685c6e6b5 (Al Viro             2008-01-25 03:01:51 -0500 604) 	struct dlm_rcom		*ls_recover_buf;
faa0f2677287a (David Teigland      2006-08-08 17:08:42 -0500 605) 	int			ls_recover_nodeid; /* for debugging */
c04fecb4d9f77 (David Teigland      2012-05-10 10:18:07 -0500 606) 	unsigned int		ls_recover_dir_sent_res; /* for log info */
c04fecb4d9f77 (David Teigland      2012-05-10 10:18:07 -0500 607) 	unsigned int		ls_recover_dir_sent_msg; /* for log info */
4875647a08e35 (David Teigland      2012-04-26 15:54:29 -0500 608) 	unsigned int		ls_recover_locks_in; /* for log info */
4a99c3d9d6663 (David Teigland      2006-08-09 11:20:15 -0500 609) 	uint64_t		ls_rcom_seq;
98f176fb32f33 (David Teigland      2006-11-27 13:19:28 -0600 610) 	spinlock_t		ls_rcom_spin;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 611) 	struct list_head	ls_recover_list;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 612) 	spinlock_t		ls_recover_list_lock;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 613) 	int			ls_recover_list_count;
1d7c484eeb167 (David Teigland      2012-05-15 16:07:49 -0500 614) 	struct idr		ls_recover_idr;
1d7c484eeb167 (David Teigland      2012-05-15 16:07:49 -0500 615) 	spinlock_t		ls_recover_idr_lock;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 616) 	wait_queue_head_t	ls_wait_general;
475f230c6072f (David Teigland      2012-08-02 11:08:21 -0500 617) 	wait_queue_head_t	ls_recover_lock_wait;
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 618) 	struct mutex		ls_clear_proc_locks;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 619) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 620) 	struct list_head	ls_root_list;	/* root resources */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 621) 	struct rw_semaphore	ls_root_sem;	/* protect root_list */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 622) 
60f98d1839376 (David Teigland      2011-11-02 14:30:58 -0500 623) 	const struct dlm_lockspace_ops *ls_ops;
60f98d1839376 (David Teigland      2011-11-02 14:30:58 -0500 624) 	void			*ls_ops_arg;
60f98d1839376 (David Teigland      2011-11-02 14:30:58 -0500 625) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 626) 	int			ls_namelen;
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 627) 	char			ls_name[1];
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 628) };
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 629) 
475f230c6072f (David Teigland      2012-08-02 11:08:21 -0500 630) /*
475f230c6072f (David Teigland      2012-08-02 11:08:21 -0500 631)  * LSFL_RECOVER_STOP - dlm_ls_stop() sets this to tell dlm recovery routines
475f230c6072f (David Teigland      2012-08-02 11:08:21 -0500 632)  * that they should abort what they're doing so new recovery can be started.
475f230c6072f (David Teigland      2012-08-02 11:08:21 -0500 633)  *
475f230c6072f (David Teigland      2012-08-02 11:08:21 -0500 634)  * LSFL_RECOVER_DOWN - dlm_ls_stop() sets this to tell dlm_recoverd that it
475f230c6072f (David Teigland      2012-08-02 11:08:21 -0500 635)  * should do down_write() on the in_recovery rw_semaphore. (doing down_write
475f230c6072f (David Teigland      2012-08-02 11:08:21 -0500 636)  * within dlm_ls_stop causes complaints about the lock acquired/released
475f230c6072f (David Teigland      2012-08-02 11:08:21 -0500 637)  * in different contexts.)
475f230c6072f (David Teigland      2012-08-02 11:08:21 -0500 638)  *
475f230c6072f (David Teigland      2012-08-02 11:08:21 -0500 639)  * LSFL_RECOVER_LOCK - dlm_recoverd holds the in_recovery rw_semaphore.
475f230c6072f (David Teigland      2012-08-02 11:08:21 -0500 640)  * It sets this after it is done with down_write() on the in_recovery
475f230c6072f (David Teigland      2012-08-02 11:08:21 -0500 641)  * rw_semaphore and clears it after it has released the rw_semaphore.
475f230c6072f (David Teigland      2012-08-02 11:08:21 -0500 642)  *
475f230c6072f (David Teigland      2012-08-02 11:08:21 -0500 643)  * LSFL_RECOVER_WORK - dlm_ls_start() sets this to tell dlm_recoverd that it
475f230c6072f (David Teigland      2012-08-02 11:08:21 -0500 644)  * should begin recovery of the lockspace.
475f230c6072f (David Teigland      2012-08-02 11:08:21 -0500 645)  *
475f230c6072f (David Teigland      2012-08-02 11:08:21 -0500 646)  * LSFL_RUNNING - set when normal locking activity is enabled.
475f230c6072f (David Teigland      2012-08-02 11:08:21 -0500 647)  * dlm_ls_stop() clears this to tell dlm locking routines that they should
475f230c6072f (David Teigland      2012-08-02 11:08:21 -0500 648)  * quit what they are doing so recovery can run.  dlm_recoverd sets
475f230c6072f (David Teigland      2012-08-02 11:08:21 -0500 649)  * this after recovery is finished.
475f230c6072f (David Teigland      2012-08-02 11:08:21 -0500 650)  */
475f230c6072f (David Teigland      2012-08-02 11:08:21 -0500 651) 
475f230c6072f (David Teigland      2012-08-02 11:08:21 -0500 652) #define LSFL_RECOVER_STOP	0
475f230c6072f (David Teigland      2012-08-02 11:08:21 -0500 653) #define LSFL_RECOVER_DOWN	1
475f230c6072f (David Teigland      2012-08-02 11:08:21 -0500 654) #define LSFL_RECOVER_LOCK	2
475f230c6072f (David Teigland      2012-08-02 11:08:21 -0500 655) #define LSFL_RECOVER_WORK	3
475f230c6072f (David Teigland      2012-08-02 11:08:21 -0500 656) #define LSFL_RUNNING		4
475f230c6072f (David Teigland      2012-08-02 11:08:21 -0500 657) 
475f230c6072f (David Teigland      2012-08-02 11:08:21 -0500 658) #define LSFL_RCOM_READY		5
475f230c6072f (David Teigland      2012-08-02 11:08:21 -0500 659) #define LSFL_RCOM_WAIT		6
475f230c6072f (David Teigland      2012-08-02 11:08:21 -0500 660) #define LSFL_UEVENT_WAIT	7
475f230c6072f (David Teigland      2012-08-02 11:08:21 -0500 661) #define LSFL_TIMEWARN		8
475f230c6072f (David Teigland      2012-08-02 11:08:21 -0500 662) #define LSFL_CB_DELAY		9
475f230c6072f (David Teigland      2012-08-02 11:08:21 -0500 663) #define LSFL_NODIR		10
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 664) 
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 665) /* much of this is just saving user space pointers associated with the
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 666)    lock that we pass back to the user lib with an ast */
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 667) 
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 668) struct dlm_user_args {
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 669) 	struct dlm_user_proc	*proc; /* each process that opens the lockspace
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 670) 					  device has private data
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 671) 					  (dlm_user_proc) on the struct file,
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 672) 					  the process's locks point back to it*/
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 673) 	struct dlm_lksb		lksb;
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 674) 	struct dlm_lksb __user	*user_lksb;
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 675) 	void __user		*castparam;
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 676) 	void __user		*castaddr;
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 677) 	void __user		*bastparam;
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 678) 	void __user		*bastaddr;
d7db923ea4990 (David Teigland      2007-05-18 09:00:32 -0500 679) 	uint64_t		xid;
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 680) };
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 681) 
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 682) #define DLM_PROC_FLAGS_CLOSING 1
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 683) #define DLM_PROC_FLAGS_COMPAT  2
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 684) 
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 685) /* locks list is kept so we can remove all a process's locks when it
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 686)    exits (or orphan those that are persistent) */
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 687) 
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 688) struct dlm_user_proc {
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 689) 	dlm_lockspace_t		*lockspace;
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 690) 	unsigned long		flags; /* DLM_PROC_FLAGS */
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 691) 	struct list_head	asts;
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 692) 	spinlock_t		asts_spin;
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 693) 	struct list_head	locks;
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 694) 	spinlock_t		locks_spin;
a1bc86e6bddd3 (David Teigland      2007-01-15 10:34:52 -0600 695) 	struct list_head	unlocking;
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 696) 	wait_queue_head_t	wait;
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 697) };
597d0cae0f99f (David Teigland      2006-07-12 16:44:04 -0500 698) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 699) static inline int dlm_locking_stopped(struct dlm_ls *ls)
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 700) {
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 701) 	return !test_bit(LSFL_RUNNING, &ls->ls_flags);
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 702) }
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 703) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 704) static inline int dlm_recovery_stopped(struct dlm_ls *ls)
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 705) {
475f230c6072f (David Teigland      2012-08-02 11:08:21 -0500 706) 	return test_bit(LSFL_RECOVER_STOP, &ls->ls_flags);
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 707) }
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 708) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 709) static inline int dlm_no_directory(struct dlm_ls *ls)
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 710) {
4875647a08e35 (David Teigland      2012-04-26 15:54:29 -0500 711) 	return test_bit(LSFL_NODIR, &ls->ls_flags);
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 712) }
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 713) 
e028398da7615 (Adrian Bunk         2007-11-03 01:04:30 +0100 714) int dlm_netlink_init(void);
e028398da7615 (Adrian Bunk         2007-11-03 01:04:30 +0100 715) void dlm_netlink_exit(void);
e028398da7615 (Adrian Bunk         2007-11-03 01:04:30 +0100 716) void dlm_timeout_warn(struct dlm_lkb *lkb);
2402211a83892 (David Teigland      2008-03-14 15:09:15 -0500 717) int dlm_plock_init(void);
2402211a83892 (David Teigland      2008-03-14 15:09:15 -0500 718) void dlm_plock_exit(void);
e028398da7615 (Adrian Bunk         2007-11-03 01:04:30 +0100 719) 
e028398da7615 (Adrian Bunk         2007-11-03 01:04:30 +0100 720) #ifdef CONFIG_DLM_DEBUG
a48f9721e6db7 (Greg Kroah-Hartman  2019-06-12 17:25:36 +0200 721) void dlm_register_debugfs(void);
e028398da7615 (Adrian Bunk         2007-11-03 01:04:30 +0100 722) void dlm_unregister_debugfs(void);
a48f9721e6db7 (Greg Kroah-Hartman  2019-06-12 17:25:36 +0200 723) void dlm_create_debug_file(struct dlm_ls *ls);
e028398da7615 (Adrian Bunk         2007-11-03 01:04:30 +0100 724) void dlm_delete_debug_file(struct dlm_ls *ls);
e028398da7615 (Adrian Bunk         2007-11-03 01:04:30 +0100 725) #else
a48f9721e6db7 (Greg Kroah-Hartman  2019-06-12 17:25:36 +0200 726) static inline void dlm_register_debugfs(void) { }
e028398da7615 (Adrian Bunk         2007-11-03 01:04:30 +0100 727) static inline void dlm_unregister_debugfs(void) { }
a48f9721e6db7 (Greg Kroah-Hartman  2019-06-12 17:25:36 +0200 728) static inline void dlm_create_debug_file(struct dlm_ls *ls) { }
e028398da7615 (Adrian Bunk         2007-11-03 01:04:30 +0100 729) static inline void dlm_delete_debug_file(struct dlm_ls *ls) { }
e028398da7615 (Adrian Bunk         2007-11-03 01:04:30 +0100 730) #endif
e028398da7615 (Adrian Bunk         2007-11-03 01:04:30 +0100 731) 
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 732) #endif				/* __DLM_INTERNAL_DOT_H__ */
e7fd41792fc0e (David Teigland      2006-01-18 09:30:29 +0000 733)