File Index
Files and directories
Sign in
FILE

dlm.h

File preview with syntax highlighting.

linux-6.19.14/include/linux/dlm.h C
  1/* SPDX-License-Identifier: GPL-2.0-only */
  2/******************************************************************************
  3*******************************************************************************
  4**
  5**  Copyright (C) Sistina Software, Inc.  1997-2003  All rights reserved.
  6**  Copyright (C) 2004-2011 Red Hat, Inc.  All rights reserved.
  7**
  8**
  9*******************************************************************************
 10******************************************************************************/
 11#ifndef __DLM_DOT_H__
 12#define __DLM_DOT_H__
 13
 14#include <uapi/linux/dlm.h>
 15
 16
 17struct dlm_slot {
 18	int nodeid; /* 1 to MAX_INT */
 19	int slot;   /* 1 to MAX_INT */
 20};
 21
 22/*
 23 * recover_prep: called before the dlm begins lock recovery.
 24 *   Notfies lockspace user that locks from failed members will be granted.
 25 * recover_slot: called after recover_prep and before recover_done.
 26 *   Identifies a failed lockspace member.
 27 * recover_done: called after the dlm completes lock recovery.
 28 *   Identifies lockspace members and lockspace generation number.
 29 */
 30
 31struct dlm_lockspace_ops {
 32	void (*recover_prep) (void *ops_arg);
 33	void (*recover_slot) (void *ops_arg, struct dlm_slot *slot);
 34	void (*recover_done) (void *ops_arg, struct dlm_slot *slots,
 35			      int num_slots, int our_slot, uint32_t generation);
 36};
 37
 38/* only relevant for kernel lockspaces, will be removed in future */
 39#define DLM_LSFL_SOFTIRQ __DLM_LSFL_RESERVED0
 40
 41/*
 42 * dlm_new_lockspace
 43 *
 44 * Create/join a lockspace.
 45 *
 46 * name: lockspace name, null terminated, up to DLM_LOCKSPACE_LEN (not
 47 *   including terminating null).
 48 *
 49 * cluster: cluster name, null terminated, up to DLM_LOCKSPACE_LEN (not
 50 *   including terminating null).  Optional.  When cluster is null, it
 51 *   is not used.  When set, dlm_new_lockspace() returns -EBADR if cluster
 52 *   is not equal to the dlm cluster name.
 53 *
 54 * flags:
 55 * DLM_LSFL_NODIR
 56 *   The dlm should not use a resource directory, but statically assign
 57 *   resource mastery to nodes based on the name hash that is otherwise
 58 *   used to select the directory node.  Must be the same on all nodes.
 59 * DLM_LSFL_NEWEXCL
 60 *   dlm_new_lockspace() should return -EEXIST if the lockspace exists.
 61 * DLM_LSFL_SOFTIRQ
 62 *   dlm request callbacks (ast, bast) are softirq safe. Flag should be
 63 *   preferred by users. Will be default in some future. If set the
 64 *   strongest context for ast, bast callback is softirq as it avoids
 65 *   an additional context switch.
 66 *
 67 * lvblen: length of lvb in bytes.  Must be multiple of 8.
 68 *   dlm_new_lockspace() returns an error if this does not match
 69 *   what other nodes are using.
 70 *
 71 * ops: callbacks that indicate lockspace recovery points so the
 72 *   caller can coordinate its recovery and know lockspace members.
 73 *   This is only used by the initial dlm_new_lockspace() call.
 74 *   Optional.
 75 *
 76 * ops_arg: arg for ops callbacks.
 77 *
 78 * ops_result: tells caller if the ops callbacks (if provided) will
 79 *   be used or not.  0: will be used, -EXXX will not be used.
 80 *   -EOPNOTSUPP: the dlm does not have recovery_callbacks enabled.
 81 *
 82 * lockspace: handle for dlm functions
 83 */
 84
 85int dlm_new_lockspace(const char *name, const char *cluster,
 86		      uint32_t flags, int lvblen,
 87		      const struct dlm_lockspace_ops *ops, void *ops_arg,
 88		      int *ops_result, dlm_lockspace_t **lockspace);
 89
 90/*
 91 * dlm_release_lockspace() release_option values:
 92 *
 93 * DLM_RELEASE_NO_LOCKS returns -EBUSY if any locks (lkb's)
 94 *   exist in the local lockspace.
 95 *
 96 * DLM_RELEASE_UNUSED previous value that is no longer used.
 97 *
 98 * DLM_RELEASE_NORMAL releases the lockspace regardless of any
 99 *   locks managed in the local lockspace.
100 *
101 * DLM_RELEASE_NO_EVENT release the lockspace regardless of any
102 *   locks managed in the local lockspace, and does not submit
103 *   a leave event to the cluster manager, so other nodes will
104 *   not be notified that the node should be removed from the
105 *   list of lockspace members.
106 *
107 * DLM_RELEASE_RECOVER like DLM_RELEASE_NORMAL, but the remaining
108 *   nodes will handle the removal of the node as if the node
109 *   had failed, e.g. the recover_slot() callback would be used.
110 */
111#define DLM_RELEASE_NO_LOCKS		0
112#define DLM_RELEASE_UNUSED		1
113#define DLM_RELEASE_NORMAL		2
114#define DLM_RELEASE_NO_EVENT		3
115#define DLM_RELEASE_RECOVER		4
116#define __DLM_RELEASE_MAX		DLM_RELEASE_RECOVER
117
118/*
119 * dlm_release_lockspace
120 *
121 * Stop a lockspace.
122 *
123 * release_option: see DLM_RELEASE values above.
124 */
125
126int dlm_release_lockspace(dlm_lockspace_t *lockspace,
127			  unsigned int release_option);
128
129/*
130 * dlm_lock
131 *
132 * Make an asynchronous request to acquire or convert a lock on a named
133 * resource.
134 *
135 * lockspace: context for the request
136 * mode: the requested mode of the lock (DLM_LOCK_)
137 * lksb: lock status block for input and async return values
138 * flags: input flags (DLM_LKF_)
139 * name: name of the resource to lock, can be binary
140 * namelen: the length in bytes of the resource name (MAX_RESNAME_LEN)
141 * parent: the lock ID of a parent lock or 0 if none
142 * lockast: function DLM executes when it completes processing the request
143 * astarg: argument passed to lockast and bast functions
144 * bast: function DLM executes when this lock later blocks another request
145 *
146 * Returns:
147 * 0 if request is successfully queued for processing
148 * -EINVAL if any input parameters are invalid
149 * -EAGAIN if request would block and is flagged DLM_LKF_NOQUEUE
150 * -ENOMEM if there is no memory to process request
151 * -ENOTCONN if there is a communication error
152 *
153 * If the call to dlm_lock returns an error then the operation has failed and
154 * the AST routine will not be called.  If dlm_lock returns 0 it is still
155 * possible that the lock operation will fail. The AST routine will be called
156 * when the locking is complete and the status is returned in the lksb.
157 *
158 * If the AST routines or parameter are passed to a conversion operation then
159 * they will overwrite those values that were passed to a previous dlm_lock
160 * call.
161 *
162 * AST routines should not block (at least not for long), but may make
163 * any locking calls they please. If DLM_LSFL_SOFTIRQ for kernel
164 * users of dlm_new_lockspace() is passed the ast and bast callbacks
165 * can be processed in softirq context. Also some of the callback
166 * contexts are in the same context as the DLM lock request API, users
167 * must not hold locks while calling dlm lock request API and trying
168 * to acquire this lock in the callback again, this will end in a
169 * lock recursion. For newer implementation the DLM_LSFL_SOFTIRQ
170 * should be used.
171 */
172
173int dlm_lock(dlm_lockspace_t *lockspace,
174	     int mode,
175	     struct dlm_lksb *lksb,
176	     uint32_t flags,
177	     const void *name,
178	     unsigned int namelen,
179	     uint32_t parent_lkid,
180	     void (*lockast) (void *astarg),
181	     void *astarg,
182	     void (*bast) (void *astarg, int mode));
183
184/*
185 * dlm_unlock
186 *
187 * Asynchronously release a lock on a resource.  The AST routine is called
188 * when the resource is successfully unlocked.
189 *
190 * lockspace: context for the request
191 * lkid: the lock ID as returned in the lksb
192 * flags: input flags (DLM_LKF_)
193 * lksb: if NULL the lksb parameter passed to last lock request is used
194 * astarg: the arg used with the completion ast for the unlock
195 *
196 * Returns:
197 * 0 if request is successfully queued for processing
198 * -EINVAL if any input parameters are invalid
199 * -ENOTEMPTY if the lock still has sublocks
200 * -EBUSY if the lock is waiting for a remote lock operation
201 * -ENOTCONN if there is a communication error
202 */
203
204int dlm_unlock(dlm_lockspace_t *lockspace,
205	       uint32_t lkid,
206	       uint32_t flags,
207	       struct dlm_lksb *lksb,
208	       void *astarg);
209
210#endif				/* __DLM_DOT_H__ */
~/ Read-only file preview.