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