Commit | Line | Data |
---|---|---|
2522fe45 | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
e7fd4179 DT |
2 | /****************************************************************************** |
3 | ******************************************************************************* | |
4 | ** | |
5 | ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. | |
60f98d18 | 6 | ** Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved. |
e7fd4179 | 7 | ** |
e7fd4179 DT |
8 | ** |
9 | ******************************************************************************* | |
10 | ******************************************************************************/ | |
e7fd4179 DT |
11 | #ifndef __DLM_DOT_H__ |
12 | #define __DLM_DOT_H__ | |
13 | ||
607ca46e | 14 | #include <uapi/linux/dlm.h> |
e7fd4179 | 15 | |
e7fd4179 | 16 | |
60f98d18 DT |
17 | struct 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 | ||
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); | |
36 | }; | |
37 | ||
e7fd4179 DT |
38 | /* |
39 | * dlm_new_lockspace | |
40 | * | |
60f98d18 DT |
41 | * Create/join a lockspace. |
42 | * | |
43 | * name: lockspace name, null terminated, up to DLM_LOCKSPACE_LEN (not | |
44 | * including terminating null). | |
45 | * | |
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. | |
50 | * | |
51 | * flags: | |
52 | * DLM_LSFL_NODIR | |
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. | |
60f98d18 DT |
56 | * DLM_LSFL_NEWEXCL |
57 | * dlm_new_lockspace() should return -EEXIST if the lockspace exists. | |
58 | * | |
59 | * lvblen: length of lvb in bytes. Must be multiple of 8. | |
60 | * dlm_new_lockspace() returns an error if this does not match | |
61 | * what other nodes are using. | |
62 | * | |
63 | * ops: callbacks that indicate lockspace recovery points so the | |
64 | * caller can coordinate its recovery and know lockspace members. | |
65 | * This is only used by the initial dlm_new_lockspace() call. | |
66 | * Optional. | |
67 | * | |
68 | * ops_arg: arg for ops callbacks. | |
69 | * | |
70 | * ops_result: tells caller if the ops callbacks (if provided) will | |
71 | * be used or not. 0: will be used, -EXXX will not be used. | |
72 | * -EOPNOTSUPP: the dlm does not have recovery_callbacks enabled. | |
73 | * | |
74 | * lockspace: handle for dlm functions | |
e7fd4179 DT |
75 | */ |
76 | ||
60f98d18 DT |
77 | int dlm_new_lockspace(const char *name, const char *cluster, |
78 | uint32_t flags, int lvblen, | |
79 | const struct dlm_lockspace_ops *ops, void *ops_arg, | |
80 | int *ops_result, dlm_lockspace_t **lockspace); | |
e7fd4179 DT |
81 | |
82 | /* | |
83 | * dlm_release_lockspace | |
84 | * | |
85 | * Stop a lockspace. | |
86 | */ | |
87 | ||
88 | int dlm_release_lockspace(dlm_lockspace_t *lockspace, int force); | |
89 | ||
90 | /* | |
91 | * dlm_lock | |
92 | * | |
b3834be5 | 93 | * Make an asynchronous request to acquire or convert a lock on a named |
e7fd4179 DT |
94 | * resource. |
95 | * | |
96 | * lockspace: context for the request | |
97 | * mode: the requested mode of the lock (DLM_LOCK_) | |
98 | * lksb: lock status block for input and async return values | |
99 | * flags: input flags (DLM_LKF_) | |
100 | * name: name of the resource to lock, can be binary | |
101 | * namelen: the length in bytes of the resource name (MAX_RESNAME_LEN) | |
102 | * parent: the lock ID of a parent lock or 0 if none | |
103 | * lockast: function DLM executes when it completes processing the request | |
104 | * astarg: argument passed to lockast and bast functions | |
105 | * bast: function DLM executes when this lock later blocks another request | |
106 | * | |
107 | * Returns: | |
108 | * 0 if request is successfully queued for processing | |
109 | * -EINVAL if any input parameters are invalid | |
110 | * -EAGAIN if request would block and is flagged DLM_LKF_NOQUEUE | |
111 | * -ENOMEM if there is no memory to process request | |
112 | * -ENOTCONN if there is a communication error | |
113 | * | |
114 | * If the call to dlm_lock returns an error then the operation has failed and | |
115 | * the AST routine will not be called. If dlm_lock returns 0 it is still | |
116 | * possible that the lock operation will fail. The AST routine will be called | |
117 | * when the locking is complete and the status is returned in the lksb. | |
118 | * | |
119 | * If the AST routines or parameter are passed to a conversion operation then | |
120 | * they will overwrite those values that were passed to a previous dlm_lock | |
121 | * call. | |
122 | * | |
123 | * AST routines should not block (at least not for long), but may make | |
124 | * any locking calls they please. | |
125 | */ | |
126 | ||
127 | int dlm_lock(dlm_lockspace_t *lockspace, | |
128 | int mode, | |
129 | struct dlm_lksb *lksb, | |
130 | uint32_t flags, | |
56171e0d | 131 | const void *name, |
e7fd4179 DT |
132 | unsigned int namelen, |
133 | uint32_t parent_lkid, | |
134 | void (*lockast) (void *astarg), | |
135 | void *astarg, | |
3bcd3687 | 136 | void (*bast) (void *astarg, int mode)); |
e7fd4179 DT |
137 | |
138 | /* | |
139 | * dlm_unlock | |
140 | * | |
141 | * Asynchronously release a lock on a resource. The AST routine is called | |
142 | * when the resource is successfully unlocked. | |
143 | * | |
144 | * lockspace: context for the request | |
145 | * lkid: the lock ID as returned in the lksb | |
146 | * flags: input flags (DLM_LKF_) | |
147 | * lksb: if NULL the lksb parameter passed to last lock request is used | |
148 | * astarg: the arg used with the completion ast for the unlock | |
149 | * | |
150 | * Returns: | |
151 | * 0 if request is successfully queued for processing | |
152 | * -EINVAL if any input parameters are invalid | |
153 | * -ENOTEMPTY if the lock still has sublocks | |
154 | * -EBUSY if the lock is waiting for a remote lock operation | |
155 | * -ENOTCONN if there is a communication error | |
156 | */ | |
157 | ||
158 | int dlm_unlock(dlm_lockspace_t *lockspace, | |
159 | uint32_t lkid, | |
160 | uint32_t flags, | |
161 | struct dlm_lksb *lksb, | |
162 | void *astarg); | |
163 | ||
e7fd4179 | 164 | #endif /* __DLM_DOT_H__ */ |