1 /******************************************************************************
2 *******************************************************************************
4 ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
5 ** Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
7 ** This copyrighted material is made available to anyone wishing to use,
8 ** modify, copy, or redistribute it subject to the terms and conditions
9 ** of the GNU General Public License v.2.
11 *******************************************************************************
12 ******************************************************************************/
16 #include <uapi/linux/dlm.h>
20 int nodeid; /* 1 to MAX_INT */
21 int slot; /* 1 to MAX_INT */
25 * recover_prep: called before the dlm begins lock recovery.
26 * Notfies lockspace user that locks from failed members will be granted.
27 * recover_slot: called after recover_prep and before recover_done.
28 * Identifies a failed lockspace member.
29 * recover_done: called after the dlm completes lock recovery.
30 * Identifies lockspace members and lockspace generation number.
33 struct dlm_lockspace_ops {
34 void (*recover_prep) (void *ops_arg);
35 void (*recover_slot) (void *ops_arg, struct dlm_slot *slot);
36 void (*recover_done) (void *ops_arg, struct dlm_slot *slots,
37 int num_slots, int our_slot, uint32_t generation);
43 * Create/join a lockspace.
45 * name: lockspace name, null terminated, up to DLM_LOCKSPACE_LEN (not
46 * including terminating null).
48 * cluster: cluster name, null terminated, up to DLM_LOCKSPACE_LEN (not
49 * including terminating null). Optional. When cluster is null, it
50 * is not used. When set, dlm_new_lockspace() returns -EBADR if cluster
51 * is not equal to the dlm cluster name.
55 * The dlm should not use a resource directory, but statically assign
56 * resource mastery to nodes based on the name hash that is otherwise
57 * used to select the directory node. Must be the same on all nodes.
59 * The dlm should emit netlink messages if locks have been waiting
60 * for a configurable amount of time. (Unused.)
62 * The lockspace user is in the kernel (i.e. filesystem). Enables
63 * direct bast/cast callbacks.
65 * dlm_new_lockspace() should return -EEXIST if the lockspace exists.
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.
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.
76 * ops_arg: arg for ops callbacks.
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.
82 * lockspace: handle for dlm functions
85 int 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);
91 * dlm_release_lockspace
96 int dlm_release_lockspace(dlm_lockspace_t *lockspace, int force);
101 * Make an asynchronous request to acquire or convert a lock on a named
104 * lockspace: context for the request
105 * mode: the requested mode of the lock (DLM_LOCK_)
106 * lksb: lock status block for input and async return values
107 * flags: input flags (DLM_LKF_)
108 * name: name of the resource to lock, can be binary
109 * namelen: the length in bytes of the resource name (MAX_RESNAME_LEN)
110 * parent: the lock ID of a parent lock or 0 if none
111 * lockast: function DLM executes when it completes processing the request
112 * astarg: argument passed to lockast and bast functions
113 * bast: function DLM executes when this lock later blocks another request
116 * 0 if request is successfully queued for processing
117 * -EINVAL if any input parameters are invalid
118 * -EAGAIN if request would block and is flagged DLM_LKF_NOQUEUE
119 * -ENOMEM if there is no memory to process request
120 * -ENOTCONN if there is a communication error
122 * If the call to dlm_lock returns an error then the operation has failed and
123 * the AST routine will not be called. If dlm_lock returns 0 it is still
124 * possible that the lock operation will fail. The AST routine will be called
125 * when the locking is complete and the status is returned in the lksb.
127 * If the AST routines or parameter are passed to a conversion operation then
128 * they will overwrite those values that were passed to a previous dlm_lock
131 * AST routines should not block (at least not for long), but may make
132 * any locking calls they please.
135 int dlm_lock(dlm_lockspace_t *lockspace,
137 struct dlm_lksb *lksb,
140 unsigned int namelen,
141 uint32_t parent_lkid,
142 void (*lockast) (void *astarg),
144 void (*bast) (void *astarg, int mode));
149 * Asynchronously release a lock on a resource. The AST routine is called
150 * when the resource is successfully unlocked.
152 * lockspace: context for the request
153 * lkid: the lock ID as returned in the lksb
154 * flags: input flags (DLM_LKF_)
155 * lksb: if NULL the lksb parameter passed to last lock request is used
156 * astarg: the arg used with the completion ast for the unlock
159 * 0 if request is successfully queued for processing
160 * -EINVAL if any input parameters are invalid
161 * -ENOTEMPTY if the lock still has sublocks
162 * -EBUSY if the lock is waiting for a remote lock operation
163 * -ENOTCONN if there is a communication error
166 int dlm_unlock(dlm_lockspace_t *lockspace,
169 struct dlm_lksb *lksb,
172 #endif /* __DLM_DOT_H__ */