2019-05-28 16:57:20 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2006-01-18 09:30:29 +00:00
|
|
|
/******************************************************************************
|
|
|
|
*******************************************************************************
|
|
|
|
**
|
|
|
|
** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
|
2011-11-02 19:30:58 +00:00
|
|
|
** Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
|
2006-01-18 09:30:29 +00:00
|
|
|
**
|
|
|
|
**
|
|
|
|
*******************************************************************************
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __DLM_INTERNAL_DOT_H__
|
|
|
|
#define __DLM_INTERNAL_DOT_H__
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is the main header file to be included in each DLM source file.
|
|
|
|
*/
|
|
|
|
|
dlm: fix race between final callback and remove
This patch fixes the following issue:
node 1 is dir
node 2 is master
node 3 is other
1->2: unlock
2: put final lkb, rsb moved to toss
2->1: unlock_reply
1: queue lkb callback with EUNLOCK
2->1: remove
1: receive_remove ignored (rsb on keep because of queued lkb callback)
1: complete lkb callback, put_lkb, move rsb to toss
3->1: lookup
1->3: lookup_reply master=2
3->2: request
2->3: request_reply EBADR
In summary:
An unexpected lkb reference causes the rsb to remain on the wrong list.
The rsb being on the wrong list causes receive_remove to be ignored.
An ignored receive_remove causes inconsistent dir and master state.
This sequence requires an unusually long delay in delivering the unlock
callback, because the remove message from 2->1 usually happens after
some seconds. So, it's not known exactly how frequently this sequence
occurs in pratice. It's possible that the same end result could also
have another unknown cause.
The solution for this issue is to further separate callback state
from the lkb, so that an lkb reference (and from that, an rsb ref)
are not held while a callback remains queued. Then, within the
unlock_reply, the lkb will be freed and the rsb moved to the toss
list. So, the receive_remove will not be ignored.
Signed-off-by: Alexander Aring <aahringo@redhat.com>
Signed-off-by: David Teigland <teigland@redhat.com>
2024-03-28 15:48:41 +00:00
|
|
|
#include <uapi/linux/dlm_device.h>
|
2006-01-18 09:30:29 +00:00
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/ctype.h>
|
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <linux/vmalloc.h>
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/random.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/socket.h>
|
|
|
|
#include <linux/kthread.h>
|
|
|
|
#include <linux/kobject.h>
|
|
|
|
#include <linux/kref.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/jhash.h>
|
2006-07-12 21:44:04 +00:00
|
|
|
#include <linux/miscdevice.h>
|
2024-04-15 18:39:39 +00:00
|
|
|
#include <linux/rhashtable.h>
|
2006-01-20 08:47:07 +00:00
|
|
|
#include <linux/mutex.h>
|
2024-05-28 21:12:38 +00:00
|
|
|
#include <linux/xarray.h>
|
2012-04-23 18:58:42 +00:00
|
|
|
#include <linux/ratelimit.h>
|
2016-12-24 19:46:01 +00:00
|
|
|
#include <linux/uaccess.h>
|
2006-01-18 09:30:29 +00:00
|
|
|
|
|
|
|
#include <linux/dlm.h>
|
2007-01-09 15:44:01 +00:00
|
|
|
#include "config.h"
|
2006-01-18 09:30:29 +00:00
|
|
|
|
|
|
|
struct dlm_ls;
|
|
|
|
struct dlm_lkb;
|
|
|
|
struct dlm_rsb;
|
|
|
|
struct dlm_member;
|
|
|
|
struct dlm_rsbtable;
|
|
|
|
struct dlm_recover;
|
|
|
|
struct dlm_header;
|
|
|
|
struct dlm_message;
|
|
|
|
struct dlm_rcom;
|
|
|
|
struct dlm_mhandle;
|
2021-05-21 19:08:42 +00:00
|
|
|
struct dlm_msg;
|
2006-01-18 09:30:29 +00:00
|
|
|
|
|
|
|
#define log_print(fmt, args...) \
|
|
|
|
printk(KERN_ERR "dlm: "fmt"\n" , ##args)
|
2021-05-21 19:08:34 +00:00
|
|
|
#define log_print_ratelimited(fmt, args...) \
|
|
|
|
printk_ratelimited(KERN_ERR "dlm: "fmt"\n", ##args)
|
2006-01-18 09:30:29 +00:00
|
|
|
#define log_error(ls, fmt, args...) \
|
|
|
|
printk(KERN_ERR "dlm: %s: " fmt "\n", (ls)->ls_name , ##args)
|
2016-06-20 04:52:46 +00:00
|
|
|
|
2014-02-14 17:54:44 +00:00
|
|
|
#define log_rinfo(ls, fmt, args...) \
|
2016-06-20 04:52:46 +00:00
|
|
|
do { \
|
|
|
|
if (dlm_config.ci_log_info) \
|
|
|
|
printk(KERN_INFO "dlm: %s: " fmt "\n", \
|
|
|
|
(ls)->ls_name, ##args); \
|
|
|
|
else if (dlm_config.ci_log_debug) \
|
|
|
|
printk(KERN_DEBUG "dlm: %s: " fmt "\n", \
|
|
|
|
(ls)->ls_name , ##args); \
|
|
|
|
} while (0)
|
2006-01-18 09:30:29 +00:00
|
|
|
|
2007-01-09 15:44:01 +00:00
|
|
|
#define log_debug(ls, fmt, args...) \
|
|
|
|
do { \
|
|
|
|
if (dlm_config.ci_log_debug) \
|
|
|
|
printk(KERN_DEBUG "dlm: %s: " fmt "\n", \
|
|
|
|
(ls)->ls_name , ##args); \
|
|
|
|
} while (0)
|
2006-01-18 09:30:29 +00:00
|
|
|
|
2012-04-23 18:58:42 +00:00
|
|
|
#define log_limit(ls, fmt, args...) \
|
|
|
|
do { \
|
|
|
|
if (dlm_config.ci_log_debug) \
|
|
|
|
printk_ratelimited(KERN_DEBUG "dlm: %s: " fmt "\n", \
|
|
|
|
(ls)->ls_name , ##args); \
|
|
|
|
} while (0)
|
|
|
|
|
2006-01-18 09:30:29 +00:00
|
|
|
#define DLM_ASSERT(x, do) \
|
|
|
|
{ \
|
|
|
|
if (!(x)) \
|
|
|
|
{ \
|
|
|
|
printk(KERN_ERR "\nDLM: Assertion failed on line %d of file %s\n" \
|
|
|
|
"DLM: assertion: \"%s\"\n" \
|
|
|
|
"DLM: time = %lu\n", \
|
|
|
|
__LINE__, __FILE__, #x, jiffies); \
|
|
|
|
{do} \
|
|
|
|
printk("\n"); \
|
|
|
|
panic("DLM: Record message above and reboot.\n"); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Lockspace member (per node in a ls)
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct dlm_member {
|
|
|
|
struct list_head list;
|
|
|
|
int nodeid;
|
|
|
|
int weight;
|
2011-10-20 18:26:28 +00:00
|
|
|
int slot;
|
|
|
|
int slot_prev;
|
2011-11-02 19:30:58 +00:00
|
|
|
int comm_seq;
|
2011-10-20 18:26:28 +00:00
|
|
|
uint32_t generation;
|
|
|
|
};
|
|
|
|
|
2006-01-18 09:30:29 +00:00
|
|
|
/*
|
|
|
|
* Save and manage recovery state for a lockspace.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct dlm_recover {
|
|
|
|
struct list_head list;
|
2011-11-02 19:30:58 +00:00
|
|
|
struct dlm_config_node *nodes;
|
|
|
|
int nodes_count;
|
2006-01-18 09:30:29 +00:00
|
|
|
uint64_t seq;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Pass input args to second stage locking function.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct dlm_args {
|
|
|
|
uint32_t flags;
|
2008-02-06 06:35:45 +00:00
|
|
|
void (*astfn) (void *astparam);
|
|
|
|
void *astparam;
|
|
|
|
void (*bastfn) (void *astparam, int mode);
|
2006-01-18 09:30:29 +00:00
|
|
|
int mode;
|
|
|
|
struct dlm_lksb *lksb;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Lock block
|
|
|
|
*
|
|
|
|
* A lock can be one of three types:
|
|
|
|
*
|
|
|
|
* local copy lock is mastered locally
|
|
|
|
* (lkb_nodeid is zero and DLM_LKF_MSTCPY is not set)
|
|
|
|
* process copy lock is mastered on a remote node
|
|
|
|
* (lkb_nodeid is non-zero and DLM_LKF_MSTCPY is not set)
|
|
|
|
* master copy master node's copy of a lock owned by remote node
|
|
|
|
* (lkb_nodeid is non-zero and DLM_LKF_MSTCPY is set)
|
|
|
|
*
|
|
|
|
* lkb_exflags: a copy of the most recent flags arg provided to dlm_lock or
|
|
|
|
* dlm_unlock. The dlm does not modify these or use any private flags in
|
|
|
|
* this field; it only contains DLM_LKF_ flags from dlm.h. These flags
|
|
|
|
* are sent as-is to the remote master when the lock is remote.
|
|
|
|
*
|
|
|
|
* lkb_flags: internal dlm flags (DLM_IFL_ prefix) from dlm_internal.h.
|
|
|
|
* Some internal flags are shared between the master and process nodes;
|
|
|
|
* these shared flags are kept in the lower two bytes. One of these
|
|
|
|
* flags set on the master copy will be propagated to the process copy
|
|
|
|
* and v.v. Other internal flags are private to the master or process
|
|
|
|
* node (e.g. DLM_IFL_MSTCPY). These are kept in the high two bytes.
|
|
|
|
*
|
|
|
|
* lkb_sbflags: status block flags. These flags are copied directly into
|
|
|
|
* the caller's lksb.sb_flags prior to the dlm_lock/dlm_unlock completion
|
|
|
|
* ast. All defined in dlm.h with DLM_SBF_ prefix.
|
|
|
|
*
|
|
|
|
* lkb_status: the lock status indicates which rsb queue the lock is
|
|
|
|
* on, grant, convert, or wait. DLM_LKSTS_ WAITING/GRANTED/CONVERT
|
|
|
|
*
|
|
|
|
* lkb_wait_type: the dlm message type (DLM_MSG_ prefix) for which a
|
|
|
|
* reply is needed. Only set when the lkb is on the lockspace waiters
|
|
|
|
* list awaiting a reply from a remote node.
|
|
|
|
*
|
|
|
|
* lkb_nodeid: when the lkb is a local copy, nodeid is 0; when the lkb
|
|
|
|
* is a master copy, nodeid specifies the remote lock holder, when the
|
|
|
|
* lkb is a process copy, the nodeid specifies the lock master.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* lkb_status */
|
|
|
|
|
|
|
|
#define DLM_LKSTS_WAITING 1
|
|
|
|
#define DLM_LKSTS_GRANTED 2
|
|
|
|
#define DLM_LKSTS_CONVERT 3
|
|
|
|
|
2023-03-06 20:48:16 +00:00
|
|
|
/* lkb_iflags */
|
|
|
|
|
|
|
|
#define DLM_IFL_MSTCPY_BIT 16
|
|
|
|
#define __DLM_IFL_MIN_BIT DLM_IFL_MSTCPY_BIT
|
|
|
|
#define DLM_IFL_RESEND_BIT 17
|
|
|
|
#define DLM_IFL_DEAD_BIT 18
|
|
|
|
#define DLM_IFL_OVERLAP_UNLOCK_BIT 19
|
|
|
|
#define DLM_IFL_OVERLAP_CANCEL_BIT 20
|
|
|
|
#define DLM_IFL_ENDOFLIFE_BIT 21
|
|
|
|
#define DLM_IFL_DEADLOCK_CANCEL_BIT 24
|
dlm: fix race between final callback and remove
This patch fixes the following issue:
node 1 is dir
node 2 is master
node 3 is other
1->2: unlock
2: put final lkb, rsb moved to toss
2->1: unlock_reply
1: queue lkb callback with EUNLOCK
2->1: remove
1: receive_remove ignored (rsb on keep because of queued lkb callback)
1: complete lkb callback, put_lkb, move rsb to toss
3->1: lookup
1->3: lookup_reply master=2
3->2: request
2->3: request_reply EBADR
In summary:
An unexpected lkb reference causes the rsb to remain on the wrong list.
The rsb being on the wrong list causes receive_remove to be ignored.
An ignored receive_remove causes inconsistent dir and master state.
This sequence requires an unusually long delay in delivering the unlock
callback, because the remove message from 2->1 usually happens after
some seconds. So, it's not known exactly how frequently this sequence
occurs in pratice. It's possible that the same end result could also
have another unknown cause.
The solution for this issue is to further separate callback state
from the lkb, so that an lkb reference (and from that, an rsb ref)
are not held while a callback remains queued. Then, within the
unlock_reply, the lkb will be freed and the rsb moved to the toss
list. So, the receive_remove will not be ignored.
Signed-off-by: Alexander Aring <aahringo@redhat.com>
Signed-off-by: David Teigland <teigland@redhat.com>
2024-03-28 15:48:41 +00:00
|
|
|
#define __DLM_IFL_MAX_BIT DLM_IFL_DEADLOCK_CANCEL_BIT
|
2023-03-06 20:48:08 +00:00
|
|
|
|
2023-03-06 20:48:14 +00:00
|
|
|
/* lkb_dflags */
|
|
|
|
|
2023-03-06 20:48:15 +00:00
|
|
|
#define DLM_DFL_USER_BIT 0
|
|
|
|
#define __DLM_DFL_MIN_BIT DLM_DFL_USER_BIT
|
|
|
|
#define DLM_DFL_ORPHAN_BIT 1
|
|
|
|
#define __DLM_DFL_MAX_BIT DLM_DFL_ORPHAN_BIT
|
2006-01-18 09:30:29 +00:00
|
|
|
|
2011-02-21 20:58:21 +00:00
|
|
|
#define DLM_CB_CAST 0x00000001
|
|
|
|
#define DLM_CB_BAST 0x00000002
|
|
|
|
|
dlm: fix race between final callback and remove
This patch fixes the following issue:
node 1 is dir
node 2 is master
node 3 is other
1->2: unlock
2: put final lkb, rsb moved to toss
2->1: unlock_reply
1: queue lkb callback with EUNLOCK
2->1: remove
1: receive_remove ignored (rsb on keep because of queued lkb callback)
1: complete lkb callback, put_lkb, move rsb to toss
3->1: lookup
1->3: lookup_reply master=2
3->2: request
2->3: request_reply EBADR
In summary:
An unexpected lkb reference causes the rsb to remain on the wrong list.
The rsb being on the wrong list causes receive_remove to be ignored.
An ignored receive_remove causes inconsistent dir and master state.
This sequence requires an unusually long delay in delivering the unlock
callback, because the remove message from 2->1 usually happens after
some seconds. So, it's not known exactly how frequently this sequence
occurs in pratice. It's possible that the same end result could also
have another unknown cause.
The solution for this issue is to further separate callback state
from the lkb, so that an lkb reference (and from that, an rsb ref)
are not held while a callback remains queued. Then, within the
unlock_reply, the lkb will be freed and the rsb moved to the toss
list. So, the receive_remove will not be ignored.
Signed-off-by: Alexander Aring <aahringo@redhat.com>
Signed-off-by: David Teigland <teigland@redhat.com>
2024-03-28 15:48:41 +00:00
|
|
|
/* much of this is just saving user space pointers associated with the
|
|
|
|
* lock that we pass back to the user lib with an ast
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct dlm_user_args {
|
|
|
|
struct dlm_user_proc *proc; /* each process that opens the lockspace
|
|
|
|
* device has private data
|
|
|
|
* (dlm_user_proc) on the struct file,
|
|
|
|
* the process's locks point back to it
|
|
|
|
*/
|
|
|
|
struct dlm_lksb lksb;
|
|
|
|
struct dlm_lksb __user *user_lksb;
|
|
|
|
void __user *castparam;
|
|
|
|
void __user *castaddr;
|
|
|
|
void __user *bastparam;
|
|
|
|
void __user *bastaddr;
|
|
|
|
uint64_t xid;
|
|
|
|
};
|
|
|
|
|
2011-02-21 20:58:21 +00:00
|
|
|
struct dlm_callback {
|
|
|
|
uint32_t flags; /* DLM_CBF_ */
|
|
|
|
int sb_status; /* copy to lksb status */
|
|
|
|
uint8_t sb_flags; /* copy to lksb flags */
|
|
|
|
int8_t mode; /* rq mode of bast, gr mode of cast */
|
dlm: fix race between final callback and remove
This patch fixes the following issue:
node 1 is dir
node 2 is master
node 3 is other
1->2: unlock
2: put final lkb, rsb moved to toss
2->1: unlock_reply
1: queue lkb callback with EUNLOCK
2->1: remove
1: receive_remove ignored (rsb on keep because of queued lkb callback)
1: complete lkb callback, put_lkb, move rsb to toss
3->1: lookup
1->3: lookup_reply master=2
3->2: request
2->3: request_reply EBADR
In summary:
An unexpected lkb reference causes the rsb to remain on the wrong list.
The rsb being on the wrong list causes receive_remove to be ignored.
An ignored receive_remove causes inconsistent dir and master state.
This sequence requires an unusually long delay in delivering the unlock
callback, because the remove message from 2->1 usually happens after
some seconds. So, it's not known exactly how frequently this sequence
occurs in pratice. It's possible that the same end result could also
have another unknown cause.
The solution for this issue is to further separate callback state
from the lkb, so that an lkb reference (and from that, an rsb ref)
are not held while a callback remains queued. Then, within the
unlock_reply, the lkb will be freed and the rsb moved to the toss
list. So, the receive_remove will not be ignored.
Signed-off-by: Alexander Aring <aahringo@redhat.com>
Signed-off-by: David Teigland <teigland@redhat.com>
2024-03-28 15:48:41 +00:00
|
|
|
bool copy_lvb;
|
|
|
|
struct dlm_lksb *lkb_lksb;
|
|
|
|
unsigned char lvbptr[DLM_USER_LVB_LEN];
|
|
|
|
|
|
|
|
union {
|
|
|
|
void *astparam; /* caller's ast arg */
|
|
|
|
struct dlm_user_args ua;
|
|
|
|
};
|
|
|
|
struct work_struct work;
|
|
|
|
void (*bastfn)(void *astparam, int mode);
|
|
|
|
void (*astfn)(void *astparam);
|
|
|
|
char res_name[DLM_RESNAME_MAXLEN];
|
|
|
|
size_t res_length;
|
|
|
|
uint32_t ls_id;
|
|
|
|
uint32_t lkb_id;
|
2022-10-27 20:45:21 +00:00
|
|
|
|
|
|
|
struct list_head list;
|
2011-02-21 20:58:21 +00:00
|
|
|
};
|
|
|
|
|
2006-01-18 09:30:29 +00:00
|
|
|
struct dlm_lkb {
|
|
|
|
struct dlm_rsb *lkb_resource; /* the rsb */
|
|
|
|
struct kref lkb_ref;
|
|
|
|
int lkb_nodeid; /* copied from rsb */
|
|
|
|
int lkb_ownpid; /* pid of lock owner */
|
|
|
|
uint32_t lkb_id; /* our lock ID */
|
|
|
|
uint32_t lkb_remid; /* lock ID on remote partner */
|
|
|
|
uint32_t lkb_exflags; /* external flags from caller */
|
2023-03-06 20:48:18 +00:00
|
|
|
unsigned long lkb_sbflags; /* lksb flags */
|
2023-03-06 20:48:15 +00:00
|
|
|
unsigned long lkb_dflags; /* distributed flags */
|
2023-03-06 20:48:08 +00:00
|
|
|
unsigned long lkb_iflags; /* internal flags */
|
2006-01-18 09:30:29 +00:00
|
|
|
uint32_t lkb_lvbseq; /* lvb sequence number */
|
|
|
|
|
|
|
|
int8_t lkb_status; /* granted, waiting, convert */
|
|
|
|
int8_t lkb_rqmode; /* requested lock mode */
|
|
|
|
int8_t lkb_grmode; /* granted lock mode */
|
|
|
|
int8_t lkb_highbast; /* highest mode bast sent for */
|
2010-02-24 17:08:18 +00:00
|
|
|
|
2006-01-18 09:30:29 +00:00
|
|
|
int8_t lkb_wait_type; /* type of reply waiting for */
|
2024-03-15 19:11:45 +00:00
|
|
|
int8_t lkb_wait_count;
|
2011-03-28 19:17:26 +00:00
|
|
|
int lkb_wait_nodeid; /* for debugging */
|
2006-01-18 09:30:29 +00:00
|
|
|
|
|
|
|
struct list_head lkb_statequeue; /* rsb g/c/w list */
|
|
|
|
struct list_head lkb_rsb_lookup; /* waiting for rsb lookup */
|
|
|
|
struct list_head lkb_wait_reply; /* waiting for remote reply */
|
2006-07-12 21:44:04 +00:00
|
|
|
struct list_head lkb_ownqueue; /* list of locks for a process */
|
2008-12-09 20:12:21 +00:00
|
|
|
ktime_t lkb_timestamp;
|
2022-06-22 18:45:23 +00:00
|
|
|
|
2024-03-28 15:48:42 +00:00
|
|
|
int8_t lkb_last_cast_cb_mode;
|
|
|
|
int8_t lkb_last_bast_cb_mode;
|
|
|
|
int8_t lkb_last_cb_mode;
|
|
|
|
uint8_t lkb_last_cb_flags;
|
2011-02-21 20:58:21 +00:00
|
|
|
ktime_t lkb_last_cast_time; /* for debugging */
|
|
|
|
ktime_t lkb_last_bast_time; /* for debugging */
|
|
|
|
|
dlm: fixes for nodir mode
The "nodir" mode (statically assign master nodes instead
of using the resource directory) has always been highly
experimental, and never seriously used. This commit
fixes a number of problems, making nodir much more usable.
- Major change to recovery: recover all locks and restart
all in-progress operations after recovery. In some
cases it's not possible to know which in-progess locks
to recover, so recover all. (Most require recovery
in nodir mode anyway since rehashing changes most
master nodes.)
- Change the way nodir mode is enabled, from a command
line mount arg passed through gfs2, into a sysfs
file managed by dlm_controld, consistent with the
other config settings.
- Allow recovering MSTCPY locks on an rsb that has not
yet been turned into a master copy.
- Ignore RCOM_LOCK and RCOM_LOCK_REPLY recovery messages
from a previous, aborted recovery cycle. Base this
on the local recovery status not being in the state
where any nodes should be sending LOCK messages for the
current recovery cycle.
- Hold rsb lock around dlm_purge_mstcpy_locks() because it
may run concurrently with dlm_recover_master_copy().
- Maintain highbast on process-copy lkb's (in addition to
the master as is usual), because the lkb can switch
back and forth between being a master and being a
process copy as the master node changes in recovery.
- When recovering MSTCPY locks, flag rsb's that have
non-empty convert or waiting queues for granting
at the end of recovery. (Rename flag from LOCKS_PURGED
to RECOVER_GRANT and similar for the recovery function,
because it's not only resources with purged locks
that need grant a grant attempt.)
- Replace a couple of unnecessary assertion panics with
error messages.
Signed-off-by: David Teigland <teigland@redhat.com>
2012-04-26 20:54:29 +00:00
|
|
|
uint64_t lkb_recover_seq; /* from ls_recover_seq */
|
|
|
|
|
2006-01-18 09:30:29 +00:00
|
|
|
char *lkb_lvbptr;
|
|
|
|
struct dlm_lksb *lkb_lksb; /* caller's status block */
|
2008-02-06 06:35:45 +00:00
|
|
|
void (*lkb_astfn) (void *astparam);
|
|
|
|
void (*lkb_bastfn) (void *astparam, int mode);
|
2008-02-07 05:27:04 +00:00
|
|
|
union {
|
|
|
|
void *lkb_astparam; /* caller's ast arg */
|
|
|
|
struct dlm_user_args *lkb_ua;
|
|
|
|
};
|
2024-08-02 17:26:46 +00:00
|
|
|
struct rcu_head rcu;
|
2006-01-18 09:30:29 +00:00
|
|
|
};
|
|
|
|
|
2012-05-10 15:18:07 +00:00
|
|
|
/*
|
|
|
|
* res_master_nodeid is "normal": 0 is unset/invalid, non-zero is the real
|
|
|
|
* nodeid, even when nodeid is our_nodeid.
|
|
|
|
*
|
|
|
|
* res_nodeid is "odd": -1 is unset/invalid, zero means our_nodeid,
|
|
|
|
* greater than zero when another nodeid.
|
|
|
|
*
|
|
|
|
* (TODO: remove res_nodeid and only use res_master_nodeid)
|
|
|
|
*/
|
2006-01-18 09:30:29 +00:00
|
|
|
|
|
|
|
struct dlm_rsb {
|
|
|
|
struct dlm_ls *res_ls; /* the lockspace */
|
|
|
|
struct kref res_ref;
|
2024-04-02 19:18:05 +00:00
|
|
|
spinlock_t res_lock;
|
2006-01-18 09:30:29 +00:00
|
|
|
unsigned long res_flags;
|
|
|
|
int res_length; /* length of rsb name */
|
|
|
|
int res_nodeid;
|
2012-05-10 15:18:07 +00:00
|
|
|
int res_master_nodeid;
|
|
|
|
int res_dir_nodeid;
|
2024-05-28 21:12:39 +00:00
|
|
|
unsigned long res_id; /* for ls_recover_xa */
|
2006-01-18 09:30:29 +00:00
|
|
|
uint32_t res_lvbseq;
|
|
|
|
uint32_t res_hash;
|
|
|
|
unsigned long res_toss_time;
|
|
|
|
uint32_t res_first_lkid;
|
|
|
|
struct list_head res_lookup; /* lkbs waiting on first */
|
2024-05-28 21:12:36 +00:00
|
|
|
struct rhash_head res_node; /* rsbtbl */
|
2006-01-18 09:30:29 +00:00
|
|
|
struct list_head res_grantqueue;
|
|
|
|
struct list_head res_convertqueue;
|
|
|
|
struct list_head res_waitqueue;
|
|
|
|
|
2024-06-10 20:02:31 +00:00
|
|
|
struct list_head res_slow_list; /* ls_slow_* */
|
|
|
|
struct list_head res_scan_list;
|
2006-01-18 09:30:29 +00:00
|
|
|
struct list_head res_root_list; /* used for recovery */
|
2024-04-02 19:18:00 +00:00
|
|
|
struct list_head res_masters_list; /* used for recovery */
|
2006-01-18 09:30:29 +00:00
|
|
|
struct list_head res_recover_list; /* used for recovery */
|
|
|
|
int res_recover_locks_count;
|
2024-06-10 20:26:03 +00:00
|
|
|
struct rcu_head rcu;
|
2006-01-18 09:30:29 +00:00
|
|
|
|
|
|
|
char *res_lvbptr;
|
2011-07-07 19:05:03 +00:00
|
|
|
char res_name[DLM_RESNAME_MAXLEN+1];
|
2006-01-18 09:30:29 +00:00
|
|
|
};
|
|
|
|
|
2012-05-10 15:18:07 +00:00
|
|
|
/* dlm_master_lookup() flags */
|
|
|
|
|
|
|
|
#define DLM_LU_RECOVER_DIR 1
|
|
|
|
#define DLM_LU_RECOVER_MASTER 2
|
|
|
|
|
|
|
|
/* dlm_master_lookup() results */
|
|
|
|
|
|
|
|
#define DLM_LU_MATCH 1
|
|
|
|
#define DLM_LU_ADD 2
|
|
|
|
|
2006-01-18 09:30:29 +00:00
|
|
|
/* find_rsb() flags */
|
|
|
|
|
2012-05-10 15:18:07 +00:00
|
|
|
#define R_REQUEST 0x00000001
|
|
|
|
#define R_RECEIVE_REQUEST 0x00000002
|
|
|
|
#define R_RECEIVE_RECOVER 0x00000004
|
2006-01-18 09:30:29 +00:00
|
|
|
|
|
|
|
/* rsb_flags */
|
|
|
|
|
|
|
|
enum rsb_flags {
|
|
|
|
RSB_MASTER_UNCERTAIN,
|
|
|
|
RSB_VALNOTVALID,
|
|
|
|
RSB_VALNOTVALID_PREV,
|
|
|
|
RSB_NEW_MASTER,
|
|
|
|
RSB_NEW_MASTER2,
|
|
|
|
RSB_RECOVER_CONVERT,
|
dlm: fixes for nodir mode
The "nodir" mode (statically assign master nodes instead
of using the resource directory) has always been highly
experimental, and never seriously used. This commit
fixes a number of problems, making nodir much more usable.
- Major change to recovery: recover all locks and restart
all in-progress operations after recovery. In some
cases it's not possible to know which in-progess locks
to recover, so recover all. (Most require recovery
in nodir mode anyway since rehashing changes most
master nodes.)
- Change the way nodir mode is enabled, from a command
line mount arg passed through gfs2, into a sysfs
file managed by dlm_controld, consistent with the
other config settings.
- Allow recovering MSTCPY locks on an rsb that has not
yet been turned into a master copy.
- Ignore RCOM_LOCK and RCOM_LOCK_REPLY recovery messages
from a previous, aborted recovery cycle. Base this
on the local recovery status not being in the state
where any nodes should be sending LOCK messages for the
current recovery cycle.
- Hold rsb lock around dlm_purge_mstcpy_locks() because it
may run concurrently with dlm_recover_master_copy().
- Maintain highbast on process-copy lkb's (in addition to
the master as is usual), because the lkb can switch
back and forth between being a master and being a
process copy as the master node changes in recovery.
- When recovering MSTCPY locks, flag rsb's that have
non-empty convert or waiting queues for granting
at the end of recovery. (Rename flag from LOCKS_PURGED
to RECOVER_GRANT and similar for the recovery function,
because it's not only resources with purged locks
that need grant a grant attempt.)
- Replace a couple of unnecessary assertion panics with
error messages.
Signed-off-by: David Teigland <teigland@redhat.com>
2012-04-26 20:54:29 +00:00
|
|
|
RSB_RECOVER_GRANT,
|
2012-11-15 21:01:51 +00:00
|
|
|
RSB_RECOVER_LVB_INVAL,
|
2024-06-10 20:02:31 +00:00
|
|
|
RSB_INACTIVE,
|
2024-06-10 20:26:03 +00:00
|
|
|
RSB_HASHED, /* set while rsb is on ls_rsbtbl */
|
2006-01-18 09:30:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline void rsb_set_flag(struct dlm_rsb *r, enum rsb_flags flag)
|
|
|
|
{
|
|
|
|
__set_bit(flag, &r->res_flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void rsb_clear_flag(struct dlm_rsb *r, enum rsb_flags flag)
|
|
|
|
{
|
|
|
|
__clear_bit(flag, &r->res_flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int rsb_flag(struct dlm_rsb *r, enum rsb_flags flag)
|
|
|
|
{
|
|
|
|
return test_bit(flag, &r->res_flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* dlm_header is first element of all structs sent between nodes */
|
|
|
|
|
2006-12-13 16:37:16 +00:00
|
|
|
#define DLM_HEADER_MAJOR 0x00030000
|
2021-05-21 19:08:46 +00:00
|
|
|
#define DLM_HEADER_MINOR 0x00000002
|
|
|
|
|
|
|
|
#define DLM_VERSION_3_1 0x00030001
|
|
|
|
#define DLM_VERSION_3_2 0x00030002
|
2011-10-20 18:26:28 +00:00
|
|
|
|
|
|
|
#define DLM_HEADER_SLOTS 0x00000001
|
2006-01-18 09:30:29 +00:00
|
|
|
|
|
|
|
#define DLM_MSG 1
|
|
|
|
#define DLM_RCOM 2
|
2021-05-21 19:08:46 +00:00
|
|
|
#define DLM_OPTS 3
|
|
|
|
#define DLM_ACK 4
|
|
|
|
#define DLM_FIN 5
|
2006-01-18 09:30:29 +00:00
|
|
|
|
|
|
|
struct dlm_header {
|
2022-04-04 20:06:39 +00:00
|
|
|
__le32 h_version;
|
2021-05-21 19:08:45 +00:00
|
|
|
union {
|
|
|
|
/* for DLM_MSG and DLM_RCOM */
|
2022-04-04 20:06:39 +00:00
|
|
|
__le32 h_lockspace;
|
2021-05-21 19:08:46 +00:00
|
|
|
/* for DLM_ACK and DLM_OPTS */
|
2022-04-04 20:06:39 +00:00
|
|
|
__le32 h_seq;
|
2021-05-21 19:08:45 +00:00
|
|
|
} u;
|
2022-04-04 20:06:39 +00:00
|
|
|
__le32 h_nodeid; /* nodeid of sender */
|
|
|
|
__le16 h_length;
|
2006-01-18 09:30:29 +00:00
|
|
|
uint8_t h_cmd; /* DLM_MSG, DLM_RCOM */
|
|
|
|
uint8_t h_pad;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define DLM_MSG_REQUEST 1
|
|
|
|
#define DLM_MSG_CONVERT 2
|
|
|
|
#define DLM_MSG_UNLOCK 3
|
|
|
|
#define DLM_MSG_CANCEL 4
|
|
|
|
#define DLM_MSG_REQUEST_REPLY 5
|
|
|
|
#define DLM_MSG_CONVERT_REPLY 6
|
|
|
|
#define DLM_MSG_UNLOCK_REPLY 7
|
|
|
|
#define DLM_MSG_CANCEL_REPLY 8
|
|
|
|
#define DLM_MSG_GRANT 9
|
|
|
|
#define DLM_MSG_BAST 10
|
|
|
|
#define DLM_MSG_LOOKUP 11
|
|
|
|
#define DLM_MSG_REMOVE 12
|
|
|
|
#define DLM_MSG_LOOKUP_REPLY 13
|
2007-03-30 20:02:40 +00:00
|
|
|
#define DLM_MSG_PURGE 14
|
2006-01-18 09:30:29 +00:00
|
|
|
|
|
|
|
struct dlm_message {
|
|
|
|
struct dlm_header m_header;
|
2022-04-04 20:06:41 +00:00
|
|
|
__le32 m_type; /* DLM_MSG_ */
|
|
|
|
__le32 m_nodeid;
|
|
|
|
__le32 m_pid;
|
|
|
|
__le32 m_lkid; /* lkid on sender */
|
|
|
|
__le32 m_remid; /* lkid on receiver */
|
|
|
|
__le32 m_parent_lkid;
|
|
|
|
__le32 m_parent_remid;
|
|
|
|
__le32 m_exflags;
|
|
|
|
__le32 m_sbflags;
|
|
|
|
__le32 m_flags;
|
|
|
|
__le32 m_lvbseq;
|
|
|
|
__le32 m_hash;
|
|
|
|
__le32 m_status;
|
|
|
|
__le32 m_grmode;
|
|
|
|
__le32 m_rqmode;
|
|
|
|
__le32 m_bastmode;
|
|
|
|
__le32 m_asts;
|
|
|
|
__le32 m_result; /* 0 or -EXXX */
|
2020-03-09 15:56:08 +00:00
|
|
|
char m_extra[]; /* name or lvb */
|
2006-01-18 09:30:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#define DLM_RS_NODES 0x00000001
|
|
|
|
#define DLM_RS_NODES_ALL 0x00000002
|
|
|
|
#define DLM_RS_DIR 0x00000004
|
|
|
|
#define DLM_RS_DIR_ALL 0x00000008
|
|
|
|
#define DLM_RS_LOCKS 0x00000010
|
|
|
|
#define DLM_RS_LOCKS_ALL 0x00000020
|
|
|
|
#define DLM_RS_DONE 0x00000040
|
|
|
|
#define DLM_RS_DONE_ALL 0x00000080
|
|
|
|
|
|
|
|
#define DLM_RCOM_STATUS 1
|
|
|
|
#define DLM_RCOM_NAMES 2
|
|
|
|
#define DLM_RCOM_LOOKUP 3
|
|
|
|
#define DLM_RCOM_LOCK 4
|
|
|
|
#define DLM_RCOM_STATUS_REPLY 5
|
|
|
|
#define DLM_RCOM_NAMES_REPLY 6
|
|
|
|
#define DLM_RCOM_LOOKUP_REPLY 7
|
|
|
|
#define DLM_RCOM_LOCK_REPLY 8
|
|
|
|
|
|
|
|
struct dlm_rcom {
|
|
|
|
struct dlm_header rc_header;
|
2022-04-04 20:06:40 +00:00
|
|
|
__le32 rc_type; /* DLM_RCOM_ */
|
|
|
|
__le32 rc_result; /* multi-purpose */
|
|
|
|
__le64 rc_id; /* match reply with request */
|
|
|
|
__le64 rc_seq; /* sender's ls_recover_seq */
|
|
|
|
__le64 rc_seq_reply; /* remote ls_recover_seq */
|
2020-03-09 15:56:08 +00:00
|
|
|
char rc_buf[];
|
2006-01-18 09:30:29 +00:00
|
|
|
};
|
|
|
|
|
2021-05-21 19:08:46 +00:00
|
|
|
struct dlm_opt_header {
|
2022-04-04 20:06:38 +00:00
|
|
|
__le16 t_type;
|
|
|
|
__le16 t_length;
|
|
|
|
__le32 t_pad;
|
2021-05-21 19:08:46 +00:00
|
|
|
/* need to be 8 byte aligned */
|
|
|
|
char t_value[];
|
|
|
|
};
|
|
|
|
|
|
|
|
/* encapsulation header */
|
|
|
|
struct dlm_opts {
|
|
|
|
struct dlm_header o_header;
|
|
|
|
uint8_t o_nextcmd;
|
|
|
|
uint8_t o_pad;
|
2022-04-04 20:06:38 +00:00
|
|
|
__le16 o_optlen;
|
|
|
|
__le32 o_pad2;
|
2021-05-21 19:08:46 +00:00
|
|
|
char o_opts[];
|
|
|
|
};
|
|
|
|
|
2008-01-25 05:58:46 +00:00
|
|
|
union dlm_packet {
|
|
|
|
struct dlm_header header; /* common to other two */
|
|
|
|
struct dlm_message message;
|
|
|
|
struct dlm_rcom rcom;
|
2021-05-21 19:08:46 +00:00
|
|
|
struct dlm_opts opts;
|
2008-01-25 05:58:46 +00:00
|
|
|
};
|
|
|
|
|
2011-10-20 18:26:28 +00:00
|
|
|
#define DLM_RSF_NEED_SLOTS 0x00000001
|
|
|
|
|
|
|
|
/* RCOM_STATUS data */
|
|
|
|
struct rcom_status {
|
|
|
|
__le32 rs_flags;
|
|
|
|
__le32 rs_unused1;
|
|
|
|
__le64 rs_unused2;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* RCOM_STATUS_REPLY data */
|
2006-01-18 09:30:29 +00:00
|
|
|
struct rcom_config {
|
2008-01-25 07:34:00 +00:00
|
|
|
__le32 rf_lvblen;
|
|
|
|
__le32 rf_lsflags;
|
2011-10-20 18:26:28 +00:00
|
|
|
|
|
|
|
/* DLM_HEADER_SLOTS adds: */
|
|
|
|
__le32 rf_flags;
|
|
|
|
__le16 rf_our_slot;
|
|
|
|
__le16 rf_num_slots;
|
|
|
|
__le32 rf_generation;
|
|
|
|
__le32 rf_unused1;
|
|
|
|
__le64 rf_unused2;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct rcom_slot {
|
|
|
|
__le32 ro_nodeid;
|
|
|
|
__le16 ro_slot;
|
|
|
|
__le16 ro_unused1;
|
|
|
|
__le64 ro_unused2;
|
2006-01-18 09:30:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct rcom_lock {
|
2008-01-25 07:08:26 +00:00
|
|
|
__le32 rl_ownpid;
|
|
|
|
__le32 rl_lkid;
|
|
|
|
__le32 rl_remid;
|
|
|
|
__le32 rl_parent_lkid;
|
|
|
|
__le32 rl_parent_remid;
|
|
|
|
__le32 rl_exflags;
|
|
|
|
__le32 rl_flags;
|
|
|
|
__le32 rl_lvbseq;
|
|
|
|
__le32 rl_result;
|
2006-01-18 09:30:29 +00:00
|
|
|
int8_t rl_rqmode;
|
|
|
|
int8_t rl_grmode;
|
|
|
|
int8_t rl_status;
|
|
|
|
int8_t rl_asts;
|
2008-01-25 07:08:26 +00:00
|
|
|
__le16 rl_wait_type;
|
|
|
|
__le16 rl_namelen;
|
2006-01-18 09:30:29 +00:00
|
|
|
char rl_name[DLM_RESNAME_MAXLEN];
|
2020-03-09 15:56:08 +00:00
|
|
|
char rl_lvb[];
|
2006-01-18 09:30:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct dlm_ls {
|
|
|
|
struct list_head ls_list; /* list of lockspaces */
|
|
|
|
uint32_t ls_global_id; /* global unique lockspace ID */
|
2011-10-20 18:26:28 +00:00
|
|
|
uint32_t ls_generation;
|
2006-01-18 09:30:29 +00:00
|
|
|
uint32_t ls_exflags;
|
|
|
|
int ls_lvblen;
|
2021-11-02 19:17:18 +00:00
|
|
|
atomic_t ls_count; /* refcount of processes in
|
2008-08-06 18:30:24 +00:00
|
|
|
the dlm using this ls */
|
2021-11-02 19:17:18 +00:00
|
|
|
wait_queue_head_t ls_count_wait;
|
2008-08-06 18:30:24 +00:00
|
|
|
int ls_create_count; /* create/release refcount */
|
2006-01-18 09:30:29 +00:00
|
|
|
unsigned long ls_flags; /* LSFL_ */
|
|
|
|
struct kobject ls_kobj;
|
|
|
|
|
2024-05-28 21:12:38 +00:00
|
|
|
struct xarray ls_lkbxa;
|
|
|
|
rwlock_t ls_lkbxa_lock;
|
2011-07-06 22:00:54 +00:00
|
|
|
|
2024-06-10 20:02:31 +00:00
|
|
|
/* an rsb is on rsbtl for primary locking functions,
|
|
|
|
and on a slow list for recovery/dump iteration */
|
2024-04-15 18:39:39 +00:00
|
|
|
struct rhashtable ls_rsbtbl;
|
2024-06-10 20:02:31 +00:00
|
|
|
rwlock_t ls_rsbtbl_lock; /* for ls_rsbtbl and ls_slow */
|
|
|
|
struct list_head ls_slow_inactive; /* to iterate rsbtbl */
|
|
|
|
struct list_head ls_slow_active; /* to iterate rsbtbl */
|
|
|
|
|
|
|
|
struct timer_list ls_scan_timer; /* based on first scan_list rsb toss_time */
|
|
|
|
struct list_head ls_scan_list; /* rsbs ordered by res_toss_time */
|
|
|
|
spinlock_t ls_scan_lock;
|
2024-04-15 18:39:41 +00:00
|
|
|
|
2024-04-02 19:18:04 +00:00
|
|
|
spinlock_t ls_waiters_lock;
|
2006-01-18 09:30:29 +00:00
|
|
|
struct list_head ls_waiters; /* lkbs needing a reply */
|
|
|
|
|
2024-04-17 19:13:22 +00:00
|
|
|
spinlock_t ls_orphans_lock;
|
2007-03-28 14:56:46 +00:00
|
|
|
struct list_head ls_orphans;
|
|
|
|
|
2006-01-18 09:30:29 +00:00
|
|
|
struct list_head ls_nodes; /* current nodes in ls */
|
|
|
|
struct list_head ls_nodes_gone; /* dead node list, recovery */
|
|
|
|
int ls_num_nodes; /* number of nodes in ls */
|
|
|
|
int ls_low_nodeid;
|
|
|
|
int ls_total_weight;
|
|
|
|
int *ls_node_array;
|
|
|
|
|
2011-10-20 18:26:28 +00:00
|
|
|
int ls_slot;
|
|
|
|
int ls_num_slots;
|
|
|
|
int ls_slots_size;
|
|
|
|
struct dlm_slot *ls_slots;
|
|
|
|
|
2023-03-06 20:48:12 +00:00
|
|
|
struct dlm_rsb ls_local_rsb; /* for returning errors */
|
|
|
|
struct dlm_lkb ls_local_lkb; /* for returning errors */
|
|
|
|
struct dlm_message ls_local_ms; /* for faking a reply */
|
2006-01-18 09:30:29 +00:00
|
|
|
|
2006-07-25 18:44:31 +00:00
|
|
|
struct dentry *ls_debug_rsb_dentry; /* debugfs */
|
|
|
|
struct dentry *ls_debug_waiters_dentry; /* debugfs */
|
2007-07-06 14:47:08 +00:00
|
|
|
struct dentry *ls_debug_locks_dentry; /* debugfs */
|
2008-12-16 20:53:23 +00:00
|
|
|
struct dentry *ls_debug_all_dentry; /* debugfs */
|
2012-05-10 15:18:07 +00:00
|
|
|
struct dentry *ls_debug_toss_dentry; /* debugfs */
|
2023-08-01 18:09:40 +00:00
|
|
|
struct dentry *ls_debug_queued_asts_dentry; /* debugfs */
|
2006-01-18 09:30:29 +00:00
|
|
|
|
|
|
|
wait_queue_head_t ls_uevent_wait; /* user part of join/leave */
|
|
|
|
int ls_uevent_result;
|
2022-06-22 18:45:15 +00:00
|
|
|
struct completion ls_recovery_done;
|
|
|
|
int ls_recovery_result;
|
2006-01-18 09:30:29 +00:00
|
|
|
|
2006-07-12 21:44:04 +00:00
|
|
|
struct miscdevice ls_device;
|
|
|
|
|
2011-04-05 18:16:24 +00:00
|
|
|
struct workqueue_struct *ls_callback_wq;
|
|
|
|
|
2006-01-18 09:30:29 +00:00
|
|
|
/* recovery related */
|
|
|
|
|
2022-10-27 20:45:18 +00:00
|
|
|
spinlock_t ls_cb_lock;
|
2011-04-05 18:16:24 +00:00
|
|
|
struct list_head ls_cb_delay; /* save for queue_work later */
|
2006-01-18 09:30:29 +00:00
|
|
|
struct task_struct *ls_recoverd_task;
|
2006-01-20 08:47:07 +00:00
|
|
|
struct mutex ls_recoverd_active;
|
2006-01-18 09:30:29 +00:00
|
|
|
spinlock_t ls_recover_lock;
|
2007-05-18 13:59:31 +00:00
|
|
|
unsigned long ls_recover_begin; /* jiffies timestamp */
|
2006-01-18 09:30:29 +00:00
|
|
|
uint32_t ls_recover_status; /* DLM_RS_ */
|
|
|
|
uint64_t ls_recover_seq;
|
|
|
|
struct dlm_recover *ls_recover_args;
|
|
|
|
struct rw_semaphore ls_in_recovery; /* block local requests */
|
2024-04-02 19:18:07 +00:00
|
|
|
rwlock_t ls_recv_active; /* block dlm_recv */
|
2006-01-18 09:30:29 +00:00
|
|
|
struct list_head ls_requestqueue;/* queue remote requests */
|
2024-04-02 19:18:06 +00:00
|
|
|
rwlock_t ls_requestqueue_lock;
|
2008-01-25 08:01:51 +00:00
|
|
|
struct dlm_rcom *ls_recover_buf;
|
2006-08-08 22:08:42 +00:00
|
|
|
int ls_recover_nodeid; /* for debugging */
|
dlm: fixes for nodir mode
The "nodir" mode (statically assign master nodes instead
of using the resource directory) has always been highly
experimental, and never seriously used. This commit
fixes a number of problems, making nodir much more usable.
- Major change to recovery: recover all locks and restart
all in-progress operations after recovery. In some
cases it's not possible to know which in-progess locks
to recover, so recover all. (Most require recovery
in nodir mode anyway since rehashing changes most
master nodes.)
- Change the way nodir mode is enabled, from a command
line mount arg passed through gfs2, into a sysfs
file managed by dlm_controld, consistent with the
other config settings.
- Allow recovering MSTCPY locks on an rsb that has not
yet been turned into a master copy.
- Ignore RCOM_LOCK and RCOM_LOCK_REPLY recovery messages
from a previous, aborted recovery cycle. Base this
on the local recovery status not being in the state
where any nodes should be sending LOCK messages for the
current recovery cycle.
- Hold rsb lock around dlm_purge_mstcpy_locks() because it
may run concurrently with dlm_recover_master_copy().
- Maintain highbast on process-copy lkb's (in addition to
the master as is usual), because the lkb can switch
back and forth between being a master and being a
process copy as the master node changes in recovery.
- When recovering MSTCPY locks, flag rsb's that have
non-empty convert or waiting queues for granting
at the end of recovery. (Rename flag from LOCKS_PURGED
to RECOVER_GRANT and similar for the recovery function,
because it's not only resources with purged locks
that need grant a grant attempt.)
- Replace a couple of unnecessary assertion panics with
error messages.
Signed-off-by: David Teigland <teigland@redhat.com>
2012-04-26 20:54:29 +00:00
|
|
|
unsigned int ls_recover_locks_in; /* for log info */
|
2006-08-09 16:20:15 +00:00
|
|
|
uint64_t ls_rcom_seq;
|
2006-11-27 19:19:28 +00:00
|
|
|
spinlock_t ls_rcom_spin;
|
2006-01-18 09:30:29 +00:00
|
|
|
struct list_head ls_recover_list;
|
|
|
|
spinlock_t ls_recover_list_lock;
|
|
|
|
int ls_recover_list_count;
|
2024-05-28 21:12:39 +00:00
|
|
|
struct xarray ls_recover_xa;
|
|
|
|
spinlock_t ls_recover_xa_lock;
|
2006-01-18 09:30:29 +00:00
|
|
|
wait_queue_head_t ls_wait_general;
|
2012-08-02 16:08:21 +00:00
|
|
|
wait_queue_head_t ls_recover_lock_wait;
|
2022-08-15 19:43:23 +00:00
|
|
|
spinlock_t ls_clear_proc_locks;
|
2006-01-18 09:30:29 +00:00
|
|
|
|
2024-04-02 19:18:01 +00:00
|
|
|
struct list_head ls_masters_list; /* root resources */
|
|
|
|
rwlock_t ls_masters_lock; /* protect root_list */
|
2024-04-02 19:18:02 +00:00
|
|
|
struct list_head ls_dir_dump_list; /* root resources */
|
|
|
|
rwlock_t ls_dir_dump_lock; /* protect root_list */
|
2006-01-18 09:30:29 +00:00
|
|
|
|
2011-11-02 19:30:58 +00:00
|
|
|
const struct dlm_lockspace_ops *ls_ops;
|
|
|
|
void *ls_ops_arg;
|
|
|
|
|
2024-08-02 17:26:43 +00:00
|
|
|
struct work_struct ls_free_work;
|
|
|
|
|
2006-01-18 09:30:29 +00:00
|
|
|
int ls_namelen;
|
2022-10-11 20:23:14 +00:00
|
|
|
char ls_name[DLM_LOCKSPACE_LEN + 1];
|
2006-01-18 09:30:29 +00:00
|
|
|
};
|
|
|
|
|
2012-08-02 16:08:21 +00:00
|
|
|
/*
|
|
|
|
* LSFL_RECOVER_STOP - dlm_ls_stop() sets this to tell dlm recovery routines
|
|
|
|
* that they should abort what they're doing so new recovery can be started.
|
|
|
|
*
|
|
|
|
* LSFL_RECOVER_DOWN - dlm_ls_stop() sets this to tell dlm_recoverd that it
|
|
|
|
* should do down_write() on the in_recovery rw_semaphore. (doing down_write
|
|
|
|
* within dlm_ls_stop causes complaints about the lock acquired/released
|
|
|
|
* in different contexts.)
|
|
|
|
*
|
|
|
|
* LSFL_RECOVER_LOCK - dlm_recoverd holds the in_recovery rw_semaphore.
|
|
|
|
* It sets this after it is done with down_write() on the in_recovery
|
|
|
|
* rw_semaphore and clears it after it has released the rw_semaphore.
|
|
|
|
*
|
|
|
|
* LSFL_RECOVER_WORK - dlm_ls_start() sets this to tell dlm_recoverd that it
|
|
|
|
* should begin recovery of the lockspace.
|
|
|
|
*
|
|
|
|
* LSFL_RUNNING - set when normal locking activity is enabled.
|
|
|
|
* dlm_ls_stop() clears this to tell dlm locking routines that they should
|
|
|
|
* quit what they are doing so recovery can run. dlm_recoverd sets
|
|
|
|
* this after recovery is finished.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define LSFL_RECOVER_STOP 0
|
|
|
|
#define LSFL_RECOVER_DOWN 1
|
|
|
|
#define LSFL_RECOVER_LOCK 2
|
|
|
|
#define LSFL_RECOVER_WORK 3
|
|
|
|
#define LSFL_RUNNING 4
|
|
|
|
|
|
|
|
#define LSFL_RCOM_READY 5
|
|
|
|
#define LSFL_RCOM_WAIT 6
|
|
|
|
#define LSFL_UEVENT_WAIT 7
|
|
|
|
#define LSFL_CB_DELAY 9
|
|
|
|
#define LSFL_NODIR 10
|
2024-04-02 19:18:06 +00:00
|
|
|
#define LSFL_RECV_MSG_BLOCKED 11
|
2024-06-03 21:55:54 +00:00
|
|
|
#define LSFL_FS 12
|
2024-06-03 21:55:56 +00:00
|
|
|
#define LSFL_SOFTIRQ 13
|
2006-01-18 09:30:29 +00:00
|
|
|
|
2006-07-12 21:44:04 +00:00
|
|
|
#define DLM_PROC_FLAGS_CLOSING 1
|
|
|
|
#define DLM_PROC_FLAGS_COMPAT 2
|
|
|
|
|
|
|
|
/* locks list is kept so we can remove all a process's locks when it
|
|
|
|
exits (or orphan those that are persistent) */
|
|
|
|
|
|
|
|
struct dlm_user_proc {
|
|
|
|
dlm_lockspace_t *lockspace;
|
|
|
|
unsigned long flags; /* DLM_PROC_FLAGS */
|
|
|
|
struct list_head asts;
|
|
|
|
spinlock_t asts_spin;
|
|
|
|
struct list_head locks;
|
|
|
|
spinlock_t locks_spin;
|
2007-01-15 16:34:52 +00:00
|
|
|
struct list_head unlocking;
|
2006-07-12 21:44:04 +00:00
|
|
|
wait_queue_head_t wait;
|
|
|
|
};
|
|
|
|
|
2006-01-18 09:30:29 +00:00
|
|
|
static inline int dlm_locking_stopped(struct dlm_ls *ls)
|
|
|
|
{
|
|
|
|
return !test_bit(LSFL_RUNNING, &ls->ls_flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int dlm_recovery_stopped(struct dlm_ls *ls)
|
|
|
|
{
|
2012-08-02 16:08:21 +00:00
|
|
|
return test_bit(LSFL_RECOVER_STOP, &ls->ls_flags);
|
2006-01-18 09:30:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int dlm_no_directory(struct dlm_ls *ls)
|
|
|
|
{
|
dlm: fixes for nodir mode
The "nodir" mode (statically assign master nodes instead
of using the resource directory) has always been highly
experimental, and never seriously used. This commit
fixes a number of problems, making nodir much more usable.
- Major change to recovery: recover all locks and restart
all in-progress operations after recovery. In some
cases it's not possible to know which in-progess locks
to recover, so recover all. (Most require recovery
in nodir mode anyway since rehashing changes most
master nodes.)
- Change the way nodir mode is enabled, from a command
line mount arg passed through gfs2, into a sysfs
file managed by dlm_controld, consistent with the
other config settings.
- Allow recovering MSTCPY locks on an rsb that has not
yet been turned into a master copy.
- Ignore RCOM_LOCK and RCOM_LOCK_REPLY recovery messages
from a previous, aborted recovery cycle. Base this
on the local recovery status not being in the state
where any nodes should be sending LOCK messages for the
current recovery cycle.
- Hold rsb lock around dlm_purge_mstcpy_locks() because it
may run concurrently with dlm_recover_master_copy().
- Maintain highbast on process-copy lkb's (in addition to
the master as is usual), because the lkb can switch
back and forth between being a master and being a
process copy as the master node changes in recovery.
- When recovering MSTCPY locks, flag rsb's that have
non-empty convert or waiting queues for granting
at the end of recovery. (Rename flag from LOCKS_PURGED
to RECOVER_GRANT and similar for the recovery function,
because it's not only resources with purged locks
that need grant a grant attempt.)
- Replace a couple of unnecessary assertion panics with
error messages.
Signed-off-by: David Teigland <teigland@redhat.com>
2012-04-26 20:54:29 +00:00
|
|
|
return test_bit(LSFL_NODIR, &ls->ls_flags);
|
2006-01-18 09:30:29 +00:00
|
|
|
}
|
|
|
|
|
2023-03-06 20:48:15 +00:00
|
|
|
/* takes a snapshot from dlm atomic flags */
|
|
|
|
static inline uint32_t dlm_flags_val(const unsigned long *addr,
|
|
|
|
uint32_t min, uint32_t max)
|
|
|
|
{
|
|
|
|
uint32_t bit = min, val = 0;
|
|
|
|
|
|
|
|
for_each_set_bit_from(bit, addr, max + 1) {
|
|
|
|
val |= BIT(bit);
|
|
|
|
}
|
|
|
|
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2023-03-06 20:48:16 +00:00
|
|
|
static inline uint32_t dlm_iflags_val(const struct dlm_lkb *lkb)
|
|
|
|
{
|
|
|
|
return dlm_flags_val(&lkb->lkb_iflags, __DLM_IFL_MIN_BIT,
|
|
|
|
__DLM_IFL_MAX_BIT);
|
|
|
|
}
|
|
|
|
|
2023-03-06 20:48:15 +00:00
|
|
|
static inline uint32_t dlm_dflags_val(const struct dlm_lkb *lkb)
|
|
|
|
{
|
|
|
|
return dlm_flags_val(&lkb->lkb_dflags, __DLM_DFL_MIN_BIT,
|
|
|
|
__DLM_DFL_MAX_BIT);
|
|
|
|
}
|
|
|
|
|
2023-03-06 20:48:18 +00:00
|
|
|
/* coming from UAPI header
|
|
|
|
*
|
|
|
|
* TODO:
|
|
|
|
* Move this to UAPI header and let other values point to them and use BIT()
|
|
|
|
*/
|
|
|
|
#define DLM_SBF_DEMOTED_BIT 0
|
|
|
|
#define __DLM_SBF_MIN_BIT DLM_SBF_DEMOTED_BIT
|
|
|
|
#define DLM_SBF_VALNOTVALID_BIT 1
|
|
|
|
#define DLM_SBF_ALTMODE_BIT 2
|
|
|
|
#define __DLM_SBF_MAX_BIT DLM_SBF_ALTMODE_BIT
|
|
|
|
|
|
|
|
static inline uint32_t dlm_sbflags_val(const struct dlm_lkb *lkb)
|
|
|
|
{
|
|
|
|
/* be sure the next person updates this */
|
|
|
|
BUILD_BUG_ON(BIT(__DLM_SBF_MAX_BIT) != DLM_SBF_ALTMODE);
|
|
|
|
|
|
|
|
return dlm_flags_val(&lkb->lkb_sbflags, __DLM_SBF_MIN_BIT,
|
|
|
|
__DLM_SBF_MAX_BIT);
|
|
|
|
}
|
|
|
|
|
2023-03-06 20:48:15 +00:00
|
|
|
static inline void dlm_set_flags_val(unsigned long *addr, uint32_t val,
|
|
|
|
uint32_t min, uint32_t max)
|
|
|
|
{
|
|
|
|
uint32_t bit;
|
|
|
|
|
|
|
|
for (bit = min; bit < (max + 1); bit++) {
|
|
|
|
if (val & BIT(bit))
|
|
|
|
set_bit(bit, addr);
|
|
|
|
else
|
|
|
|
clear_bit(bit, addr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void dlm_set_dflags_val(struct dlm_lkb *lkb, uint32_t val)
|
|
|
|
{
|
|
|
|
dlm_set_flags_val(&lkb->lkb_dflags, val, __DLM_DFL_MIN_BIT,
|
|
|
|
__DLM_DFL_MAX_BIT);
|
|
|
|
}
|
|
|
|
|
2023-03-06 20:48:18 +00:00
|
|
|
static inline void dlm_set_sbflags_val(struct dlm_lkb *lkb, uint32_t val)
|
|
|
|
{
|
|
|
|
dlm_set_flags_val(&lkb->lkb_sbflags, val, __DLM_SBF_MIN_BIT,
|
|
|
|
__DLM_SBF_MAX_BIT);
|
|
|
|
}
|
|
|
|
|
2024-08-02 17:26:43 +00:00
|
|
|
extern struct workqueue_struct *dlm_wq;
|
|
|
|
|
2008-03-14 20:09:15 +00:00
|
|
|
int dlm_plock_init(void);
|
|
|
|
void dlm_plock_exit(void);
|
2007-11-03 00:04:30 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_DLM_DEBUG
|
2019-06-12 15:25:36 +00:00
|
|
|
void dlm_register_debugfs(void);
|
2007-11-03 00:04:30 +00:00
|
|
|
void dlm_unregister_debugfs(void);
|
2019-06-12 15:25:36 +00:00
|
|
|
void dlm_create_debug_file(struct dlm_ls *ls);
|
2007-11-03 00:04:30 +00:00
|
|
|
void dlm_delete_debug_file(struct dlm_ls *ls);
|
2021-05-21 19:08:47 +00:00
|
|
|
void *dlm_create_debug_comms_file(int nodeid, void *data);
|
|
|
|
void dlm_delete_debug_comms_file(void *ctx);
|
2007-11-03 00:04:30 +00:00
|
|
|
#else
|
2019-06-12 15:25:36 +00:00
|
|
|
static inline void dlm_register_debugfs(void) { }
|
2007-11-03 00:04:30 +00:00
|
|
|
static inline void dlm_unregister_debugfs(void) { }
|
2019-06-12 15:25:36 +00:00
|
|
|
static inline void dlm_create_debug_file(struct dlm_ls *ls) { }
|
2007-11-03 00:04:30 +00:00
|
|
|
static inline void dlm_delete_debug_file(struct dlm_ls *ls) { }
|
2021-05-21 19:08:47 +00:00
|
|
|
static inline void *dlm_create_debug_comms_file(int nodeid, void *data) { return NULL; }
|
|
|
|
static inline void dlm_delete_debug_comms_file(void *ctx) { }
|
2007-11-03 00:04:30 +00:00
|
|
|
#endif
|
|
|
|
|
2006-01-18 09:30:29 +00:00
|
|
|
#endif /* __DLM_INTERNAL_DOT_H__ */
|
|
|
|
|