]>
Commit | Line | Data |
---|---|---|
e7fd4179 DT |
1 | /****************************************************************************** |
2 | ******************************************************************************* | |
3 | ** | |
4 | ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. | |
3ae1acf9 | 5 | ** Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. |
e7fd4179 DT |
6 | ** |
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. | |
10 | ** | |
11 | ******************************************************************************* | |
12 | ******************************************************************************/ | |
13 | ||
14 | #ifndef __DLM_DOT_H__ | |
15 | #define __DLM_DOT_H__ | |
16 | ||
17 | /* | |
18 | * Interface to Distributed Lock Manager (DLM) | |
19 | * routines and structures to use DLM lockspaces | |
20 | */ | |
21 | ||
d69a3ad6 JB |
22 | /* Lock levels and flags are here */ |
23 | #include <linux/dlmconstants.h> | |
e7fd4179 | 24 | |
e7fd4179 DT |
25 | typedef void dlm_lockspace_t; |
26 | ||
e7fd4179 DT |
27 | /* |
28 | * Lock status block | |
29 | * | |
30 | * Use this structure to specify the contents of the lock value block. For a | |
31 | * conversion request, this structure is used to specify the lock ID of the | |
32 | * lock. DLM writes the status of the lock request and the lock ID assigned | |
33 | * to the request in the lock status block. | |
34 | * | |
35 | * sb_lkid: the returned lock ID. It is set on new (non-conversion) requests. | |
36 | * It is available when dlm_lock returns. | |
37 | * | |
38 | * sb_lvbptr: saves or returns the contents of the lock's LVB according to rules | |
39 | * shown for the DLM_LKF_VALBLK flag. | |
40 | * | |
41 | * sb_flags: DLM_SBF_DEMOTED is returned if in the process of promoting a lock, | |
42 | * it was first demoted to NL to avoid conversion deadlock. | |
43 | * DLM_SBF_VALNOTVALID is returned if the resource's LVB is marked invalid. | |
44 | * | |
45 | * sb_status: the returned status of the lock request set prior to AST | |
46 | * execution. Possible return values: | |
47 | * | |
48 | * 0 if lock request was successful | |
49 | * -EAGAIN if request would block and is flagged DLM_LKF_NOQUEUE | |
50 | * -ENOMEM if there is no memory to process request | |
51 | * -EINVAL if there are invalid parameters | |
52 | * -DLM_EUNLOCK if unlock request was successful | |
53 | * -DLM_ECANCEL if a cancel completed successfully | |
54 | */ | |
55 | ||
56 | #define DLM_SBF_DEMOTED 0x01 | |
57 | #define DLM_SBF_VALNOTVALID 0x02 | |
58 | #define DLM_SBF_ALTMODE 0x04 | |
59 | ||
60 | struct dlm_lksb { | |
61 | int sb_status; | |
62 | uint32_t sb_lkid; | |
63 | char sb_flags; | |
64 | char * sb_lvbptr; | |
65 | }; | |
66 | ||
3ae1acf9 DT |
67 | #define DLM_LSFL_NODIR 0x00000001 |
68 | #define DLM_LSFL_TIMEWARN 0x00000002 | |
44f487a5 | 69 | #define DLM_LSFL_FS 0x00000004 |
e7fd4179 DT |
70 | |
71 | #ifdef __KERNEL__ | |
72 | ||
e7fd4179 DT |
73 | /* |
74 | * dlm_new_lockspace | |
75 | * | |
76 | * Starts a lockspace with the given name. If the named lockspace exists in | |
77 | * the cluster, the calling node joins it. | |
78 | */ | |
79 | ||
80 | int dlm_new_lockspace(char *name, int namelen, dlm_lockspace_t **lockspace, | |
81 | uint32_t flags, int lvblen); | |
82 | ||
83 | /* | |
84 | * dlm_release_lockspace | |
85 | * | |
86 | * Stop a lockspace. | |
87 | */ | |
88 | ||
89 | int dlm_release_lockspace(dlm_lockspace_t *lockspace, int force); | |
90 | ||
91 | /* | |
92 | * dlm_lock | |
93 | * | |
94 | * Make an asyncronous request to acquire or convert a lock on a named | |
95 | * resource. | |
96 | * | |
97 | * lockspace: context for the request | |
98 | * mode: the requested mode of the lock (DLM_LOCK_) | |
99 | * lksb: lock status block for input and async return values | |
100 | * flags: input flags (DLM_LKF_) | |
101 | * name: name of the resource to lock, can be binary | |
102 | * namelen: the length in bytes of the resource name (MAX_RESNAME_LEN) | |
103 | * parent: the lock ID of a parent lock or 0 if none | |
104 | * lockast: function DLM executes when it completes processing the request | |
105 | * astarg: argument passed to lockast and bast functions | |
106 | * bast: function DLM executes when this lock later blocks another request | |
107 | * | |
108 | * Returns: | |
109 | * 0 if request is successfully queued for processing | |
110 | * -EINVAL if any input parameters are invalid | |
111 | * -EAGAIN if request would block and is flagged DLM_LKF_NOQUEUE | |
112 | * -ENOMEM if there is no memory to process request | |
113 | * -ENOTCONN if there is a communication error | |
114 | * | |
115 | * If the call to dlm_lock returns an error then the operation has failed and | |
116 | * the AST routine will not be called. If dlm_lock returns 0 it is still | |
117 | * possible that the lock operation will fail. The AST routine will be called | |
118 | * when the locking is complete and the status is returned in the lksb. | |
119 | * | |
120 | * If the AST routines or parameter are passed to a conversion operation then | |
121 | * they will overwrite those values that were passed to a previous dlm_lock | |
122 | * call. | |
123 | * | |
124 | * AST routines should not block (at least not for long), but may make | |
125 | * any locking calls they please. | |
126 | */ | |
127 | ||
128 | int dlm_lock(dlm_lockspace_t *lockspace, | |
129 | int mode, | |
130 | struct dlm_lksb *lksb, | |
131 | uint32_t flags, | |
132 | void *name, | |
133 | unsigned int namelen, | |
134 | uint32_t parent_lkid, | |
135 | void (*lockast) (void *astarg), | |
136 | void *astarg, | |
3bcd3687 | 137 | void (*bast) (void *astarg, int mode)); |
e7fd4179 DT |
138 | |
139 | /* | |
140 | * dlm_unlock | |
141 | * | |
142 | * Asynchronously release a lock on a resource. The AST routine is called | |
143 | * when the resource is successfully unlocked. | |
144 | * | |
145 | * lockspace: context for the request | |
146 | * lkid: the lock ID as returned in the lksb | |
147 | * flags: input flags (DLM_LKF_) | |
148 | * lksb: if NULL the lksb parameter passed to last lock request is used | |
149 | * astarg: the arg used with the completion ast for the unlock | |
150 | * | |
151 | * Returns: | |
152 | * 0 if request is successfully queued for processing | |
153 | * -EINVAL if any input parameters are invalid | |
154 | * -ENOTEMPTY if the lock still has sublocks | |
155 | * -EBUSY if the lock is waiting for a remote lock operation | |
156 | * -ENOTCONN if there is a communication error | |
157 | */ | |
158 | ||
159 | int dlm_unlock(dlm_lockspace_t *lockspace, | |
160 | uint32_t lkid, | |
161 | uint32_t flags, | |
162 | struct dlm_lksb *lksb, | |
163 | void *astarg); | |
164 | ||
165 | #endif /* __KERNEL__ */ | |
166 | ||
167 | #endif /* __DLM_DOT_H__ */ | |
168 |