1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /******************************************************************************
3 *******************************************************************************
5 ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
6 ** Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
9 *******************************************************************************
10 ******************************************************************************/
14 #include <uapi/linux/dlm.h>
18 int nodeid; /* 1 to MAX_INT */
19 int slot; /* 1 to MAX_INT */
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.
31 struct 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);
41 * Create/join a lockspace.
43 * name: lockspace name, null terminated, up to DLM_LOCKSPACE_LEN (not
44 * including terminating null).
46 * cluster: cluster name, null terminated, up to DLM_LOCKSPACE_LEN (not
47 * including terminating null). Optional. When cluster is null, it
48 * is not used. When set, dlm_new_lockspace() returns -EBADR if cluster
49 * is not equal to the dlm cluster name.
53 * The dlm should not use a resource directory, but statically assign
54 * resource mastery to nodes based on the name hash that is otherwise
55 * used to select the directory node. Must be the same on all nodes.
57 * The dlm should emit netlink messages if locks have been waiting
58 * for a configurable amount of time. (Unused.)
60 * The lockspace user is in the kernel (i.e. filesystem). Enables
61 * direct bast/cast callbacks.
63 * dlm_new_lockspace() should return -EEXIST if the lockspace exists.
65 * lvblen: length of lvb in bytes. Must be multiple of 8.
66 * dlm_new_lockspace() returns an error if this does not match
67 * what other nodes are using.
69 * ops: callbacks that indicate lockspace recovery points so the
70 * caller can coordinate its recovery and know lockspace members.
71 * This is only used by the initial dlm_new_lockspace() call.
74 * ops_arg: arg for ops callbacks.
76 * ops_result: tells caller if the ops callbacks (if provided) will
77 * be used or not. 0: will be used, -EXXX will not be used.
78 * -EOPNOTSUPP: the dlm does not have recovery_callbacks enabled.
80 * lockspace: handle for dlm functions
83 int dlm_new_lockspace(const char *name, const char *cluster,
84 uint32_t flags, int lvblen,
85 const struct dlm_lockspace_ops *ops, void *ops_arg,
86 int *ops_result, dlm_lockspace_t **lockspace);
89 * dlm_release_lockspace
94 int dlm_release_lockspace(dlm_lockspace_t *lockspace, int force);
99 * Make an asynchronous request to acquire or convert a lock on a named
102 * lockspace: context for the request
103 * mode: the requested mode of the lock (DLM_LOCK_)
104 * lksb: lock status block for input and async return values
105 * flags: input flags (DLM_LKF_)
106 * name: name of the resource to lock, can be binary
107 * namelen: the length in bytes of the resource name (MAX_RESNAME_LEN)
108 * parent: the lock ID of a parent lock or 0 if none
109 * lockast: function DLM executes when it completes processing the request
110 * astarg: argument passed to lockast and bast functions
111 * bast: function DLM executes when this lock later blocks another request
114 * 0 if request is successfully queued for processing
115 * -EINVAL if any input parameters are invalid
116 * -EAGAIN if request would block and is flagged DLM_LKF_NOQUEUE
117 * -ENOMEM if there is no memory to process request
118 * -ENOTCONN if there is a communication error
120 * If the call to dlm_lock returns an error then the operation has failed and
121 * the AST routine will not be called. If dlm_lock returns 0 it is still
122 * possible that the lock operation will fail. The AST routine will be called
123 * when the locking is complete and the status is returned in the lksb.
125 * If the AST routines or parameter are passed to a conversion operation then
126 * they will overwrite those values that were passed to a previous dlm_lock
129 * AST routines should not block (at least not for long), but may make
130 * any locking calls they please.
133 int dlm_lock(dlm_lockspace_t *lockspace,
135 struct dlm_lksb *lksb,
138 unsigned int namelen,
139 uint32_t parent_lkid,
140 void (*lockast) (void *astarg),
142 void (*bast) (void *astarg, int mode));
147 * Asynchronously release a lock on a resource. The AST routine is called
148 * when the resource is successfully unlocked.
150 * lockspace: context for the request
151 * lkid: the lock ID as returned in the lksb
152 * flags: input flags (DLM_LKF_)
153 * lksb: if NULL the lksb parameter passed to last lock request is used
154 * astarg: the arg used with the completion ast for the unlock
157 * 0 if request is successfully queued for processing
158 * -EINVAL if any input parameters are invalid
159 * -ENOTEMPTY if the lock still has sublocks
160 * -EBUSY if the lock is waiting for a remote lock operation
161 * -ENOTCONN if there is a communication error
164 int dlm_unlock(dlm_lockspace_t *lockspace,
167 struct dlm_lksb *lksb,
170 #endif /* __DLM_DOT_H__ */