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 * dlm_new_lockspace() should return -EEXIST if the lockspace exists.
62 * lvblen: length of lvb in bytes. Must be multiple of 8.
63 * dlm_new_lockspace() returns an error if this does not match
64 * what other nodes are using.
66 * ops: callbacks that indicate lockspace recovery points so the
67 * caller can coordinate its recovery and know lockspace members.
68 * This is only used by the initial dlm_new_lockspace() call.
71 * ops_arg: arg for ops callbacks.
73 * ops_result: tells caller if the ops callbacks (if provided) will
74 * be used or not. 0: will be used, -EXXX will not be used.
75 * -EOPNOTSUPP: the dlm does not have recovery_callbacks enabled.
77 * lockspace: handle for dlm functions
80 int dlm_new_lockspace(const char *name, const char *cluster,
81 uint32_t flags, int lvblen,
82 const struct dlm_lockspace_ops *ops, void *ops_arg,
83 int *ops_result, dlm_lockspace_t **lockspace);
86 * dlm_release_lockspace
91 int dlm_release_lockspace(dlm_lockspace_t *lockspace, int force);
96 * Make an asynchronous request to acquire or convert a lock on a named
99 * lockspace: context for the request
100 * mode: the requested mode of the lock (DLM_LOCK_)
101 * lksb: lock status block for input and async return values
102 * flags: input flags (DLM_LKF_)
103 * name: name of the resource to lock, can be binary
104 * namelen: the length in bytes of the resource name (MAX_RESNAME_LEN)
105 * parent: the lock ID of a parent lock or 0 if none
106 * lockast: function DLM executes when it completes processing the request
107 * astarg: argument passed to lockast and bast functions
108 * bast: function DLM executes when this lock later blocks another request
111 * 0 if request is successfully queued for processing
112 * -EINVAL if any input parameters are invalid
113 * -EAGAIN if request would block and is flagged DLM_LKF_NOQUEUE
114 * -ENOMEM if there is no memory to process request
115 * -ENOTCONN if there is a communication error
117 * If the call to dlm_lock returns an error then the operation has failed and
118 * the AST routine will not be called. If dlm_lock returns 0 it is still
119 * possible that the lock operation will fail. The AST routine will be called
120 * when the locking is complete and the status is returned in the lksb.
122 * If the AST routines or parameter are passed to a conversion operation then
123 * they will overwrite those values that were passed to a previous dlm_lock
126 * AST routines should not block (at least not for long), but may make
127 * any locking calls they please.
130 int dlm_lock(dlm_lockspace_t *lockspace,
132 struct dlm_lksb *lksb,
135 unsigned int namelen,
136 uint32_t parent_lkid,
137 void (*lockast) (void *astarg),
139 void (*bast) (void *astarg, int mode));
144 * Asynchronously release a lock on a resource. The AST routine is called
145 * when the resource is successfully unlocked.
147 * lockspace: context for the request
148 * lkid: the lock ID as returned in the lksb
149 * flags: input flags (DLM_LKF_)
150 * lksb: if NULL the lksb parameter passed to last lock request is used
151 * astarg: the arg used with the completion ast for the unlock
154 * 0 if request is successfully queued for processing
155 * -EINVAL if any input parameters are invalid
156 * -ENOTEMPTY if the lock still has sublocks
157 * -EBUSY if the lock is waiting for a remote lock operation
158 * -ENOTCONN if there is a communication error
161 int dlm_unlock(dlm_lockspace_t *lockspace,
164 struct dlm_lksb *lksb,
167 #endif /* __DLM_DOT_H__ */