xref: /linux/include/uapi/linux/dlmconstants.h (revision 1ac731c529cd4d6adbce134754b51ff7d822b145)
1e2be04c7SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2607ca46eSDavid Howells /******************************************************************************
3607ca46eSDavid Howells *******************************************************************************
4607ca46eSDavid Howells **
5607ca46eSDavid Howells **  Copyright (C) Sistina Software, Inc.  1997-2003  All rights reserved.
6607ca46eSDavid Howells **  Copyright (C) 2004-2007 Red Hat, Inc.  All rights reserved.
7607ca46eSDavid Howells **
8607ca46eSDavid Howells **  This copyrighted material is made available to anyone wishing to use,
9607ca46eSDavid Howells **  modify, copy, or redistribute it subject to the terms and conditions
10607ca46eSDavid Howells **  of the GNU General Public License v.2.
11607ca46eSDavid Howells **
12607ca46eSDavid Howells *******************************************************************************
13607ca46eSDavid Howells ******************************************************************************/
14607ca46eSDavid Howells 
15607ca46eSDavid Howells #ifndef __DLMCONSTANTS_DOT_H__
16607ca46eSDavid Howells #define __DLMCONSTANTS_DOT_H__
17607ca46eSDavid Howells 
18607ca46eSDavid Howells /*
19607ca46eSDavid Howells  * Constants used by DLM interface.
20607ca46eSDavid Howells  */
21607ca46eSDavid Howells 
22607ca46eSDavid Howells #define DLM_LOCKSPACE_LEN       64
23607ca46eSDavid Howells #define DLM_RESNAME_MAXLEN      64
24607ca46eSDavid Howells 
25607ca46eSDavid Howells 
26607ca46eSDavid Howells /*
27607ca46eSDavid Howells  * Lock Modes
28607ca46eSDavid Howells  */
29607ca46eSDavid Howells 
30607ca46eSDavid Howells #define DLM_LOCK_IV		(-1)	/* invalid */
31607ca46eSDavid Howells #define DLM_LOCK_NL		0	/* null */
32607ca46eSDavid Howells #define DLM_LOCK_CR		1	/* concurrent read */
33607ca46eSDavid Howells #define DLM_LOCK_CW		2	/* concurrent write */
34607ca46eSDavid Howells #define DLM_LOCK_PR		3	/* protected read */
35607ca46eSDavid Howells #define DLM_LOCK_PW		4	/* protected write */
36607ca46eSDavid Howells #define DLM_LOCK_EX		5	/* exclusive */
37607ca46eSDavid Howells 
38607ca46eSDavid Howells 
39607ca46eSDavid Howells /*
40607ca46eSDavid Howells  * Flags to dlm_lock
41607ca46eSDavid Howells  *
42607ca46eSDavid Howells  * DLM_LKF_NOQUEUE
43607ca46eSDavid Howells  *
44607ca46eSDavid Howells  * Do not queue the lock request on the wait queue if it cannot be granted
45607ca46eSDavid Howells  * immediately.  If the lock cannot be granted because of this flag, DLM will
46607ca46eSDavid Howells  * either return -EAGAIN from the dlm_lock call or will return 0 from
47607ca46eSDavid Howells  * dlm_lock and -EAGAIN in the lock status block when the AST is executed.
48607ca46eSDavid Howells  *
49607ca46eSDavid Howells  * DLM_LKF_CANCEL
50607ca46eSDavid Howells  *
51607ca46eSDavid Howells  * Used to cancel a pending lock request or conversion.  A converting lock is
52607ca46eSDavid Howells  * returned to its previously granted mode.
53607ca46eSDavid Howells  *
54607ca46eSDavid Howells  * DLM_LKF_CONVERT
55607ca46eSDavid Howells  *
56607ca46eSDavid Howells  * Indicates a lock conversion request.  For conversions the name and namelen
57607ca46eSDavid Howells  * are ignored and the lock ID in the LKSB is used to identify the lock.
58607ca46eSDavid Howells  *
59607ca46eSDavid Howells  * DLM_LKF_VALBLK
60607ca46eSDavid Howells  *
61607ca46eSDavid Howells  * Requests DLM to return the current contents of the lock value block in the
62607ca46eSDavid Howells  * lock status block.  When this flag is set in a lock conversion from PW or EX
63607ca46eSDavid Howells  * modes, DLM assigns the value specified in the lock status block to the lock
64607ca46eSDavid Howells  * value block of the lock resource.  The LVB is a DLM_LVB_LEN size array
65607ca46eSDavid Howells  * containing application-specific information.
66607ca46eSDavid Howells  *
67607ca46eSDavid Howells  * DLM_LKF_QUECVT
68607ca46eSDavid Howells  *
69607ca46eSDavid Howells  * Force a conversion request to be queued, even if it is compatible with
70607ca46eSDavid Howells  * the granted modes of other locks on the same resource.
71607ca46eSDavid Howells  *
72607ca46eSDavid Howells  * DLM_LKF_IVVALBLK
73607ca46eSDavid Howells  *
74607ca46eSDavid Howells  * Invalidate the lock value block.
75607ca46eSDavid Howells  *
76607ca46eSDavid Howells  * DLM_LKF_CONVDEADLK
77607ca46eSDavid Howells  *
78607ca46eSDavid Howells  * Allows the dlm to resolve conversion deadlocks internally by demoting the
79607ca46eSDavid Howells  * granted mode of a converting lock to NL.  The DLM_SBF_DEMOTED flag is
80607ca46eSDavid Howells  * returned for a conversion that's been effected by this.
81607ca46eSDavid Howells  *
82607ca46eSDavid Howells  * DLM_LKF_PERSISTENT
83607ca46eSDavid Howells  *
84607ca46eSDavid Howells  * Only relevant to locks originating in userspace.  A persistent lock will not
85607ca46eSDavid Howells  * be removed if the process holding the lock exits.
86607ca46eSDavid Howells  *
87607ca46eSDavid Howells  * DLM_LKF_NODLCKWT
88607ca46eSDavid Howells  *
89607ca46eSDavid Howells  * Do not cancel the lock if it gets into conversion deadlock.
90607ca46eSDavid Howells  *
91607ca46eSDavid Howells  * DLM_LKF_NODLCKBLK
92607ca46eSDavid Howells  *
93607ca46eSDavid Howells  * net yet implemented
94607ca46eSDavid Howells  *
95607ca46eSDavid Howells  * DLM_LKF_EXPEDITE
96607ca46eSDavid Howells  *
97607ca46eSDavid Howells  * Used only with new requests for NL mode locks.  Tells the lock manager
98607ca46eSDavid Howells  * to grant the lock, ignoring other locks in convert and wait queues.
99607ca46eSDavid Howells  *
100607ca46eSDavid Howells  * DLM_LKF_NOQUEUEBAST
101607ca46eSDavid Howells  *
102607ca46eSDavid Howells  * Send blocking AST's before returning -EAGAIN to the caller.  It is only
103607ca46eSDavid Howells  * used along with the NOQUEUE flag.  Blocking AST's are not sent for failed
104607ca46eSDavid Howells  * NOQUEUE requests otherwise.
105607ca46eSDavid Howells  *
106607ca46eSDavid Howells  * DLM_LKF_HEADQUE
107607ca46eSDavid Howells  *
108607ca46eSDavid Howells  * Add a lock to the head of the convert or wait queue rather than the tail.
109607ca46eSDavid Howells  *
110607ca46eSDavid Howells  * DLM_LKF_NOORDER
111607ca46eSDavid Howells  *
112607ca46eSDavid Howells  * Disregard the standard grant order rules and grant a lock as soon as it
113607ca46eSDavid Howells  * is compatible with other granted locks.
114607ca46eSDavid Howells  *
115607ca46eSDavid Howells  * DLM_LKF_ORPHAN
116607ca46eSDavid Howells  *
1172ab4bd8eSDavid Teigland  * Acquire an orphan lock.
118607ca46eSDavid Howells  *
119607ca46eSDavid Howells  * DLM_LKF_ALTPR
120607ca46eSDavid Howells  *
121607ca46eSDavid Howells  * If the requested mode cannot be granted immediately, try to grant the lock
122607ca46eSDavid Howells  * in PR mode instead.  If this alternate mode is granted instead of the
123607ca46eSDavid Howells  * requested mode, DLM_SBF_ALTMODE is returned in the lksb.
124607ca46eSDavid Howells  *
125607ca46eSDavid Howells  * DLM_LKF_ALTCW
126607ca46eSDavid Howells  *
127607ca46eSDavid Howells  * The same as ALTPR, but the alternate mode is CW.
128607ca46eSDavid Howells  *
129607ca46eSDavid Howells  * DLM_LKF_FORCEUNLOCK
130607ca46eSDavid Howells  *
131607ca46eSDavid Howells  * Unlock the lock even if it is converting or waiting or has sublocks.
132607ca46eSDavid Howells  * Only really for use by the userland device.c code.
133607ca46eSDavid Howells  *
134*01c7a597SAlexander Aring  * DLM_LKF_TIMEOUT
135*01c7a597SAlexander Aring  *
136*01c7a597SAlexander Aring  * This value is deprecated and reserved. DO NOT USE!
137*01c7a597SAlexander Aring  *
138607ca46eSDavid Howells  */
139607ca46eSDavid Howells 
140607ca46eSDavid Howells #define DLM_LKF_NOQUEUE		0x00000001
141607ca46eSDavid Howells #define DLM_LKF_CANCEL		0x00000002
142607ca46eSDavid Howells #define DLM_LKF_CONVERT		0x00000004
143607ca46eSDavid Howells #define DLM_LKF_VALBLK		0x00000008
144607ca46eSDavid Howells #define DLM_LKF_QUECVT		0x00000010
145607ca46eSDavid Howells #define DLM_LKF_IVVALBLK	0x00000020
146607ca46eSDavid Howells #define DLM_LKF_CONVDEADLK	0x00000040
147607ca46eSDavid Howells #define DLM_LKF_PERSISTENT	0x00000080
148607ca46eSDavid Howells #define DLM_LKF_NODLCKWT	0x00000100
149607ca46eSDavid Howells #define DLM_LKF_NODLCKBLK	0x00000200
150607ca46eSDavid Howells #define DLM_LKF_EXPEDITE	0x00000400
151607ca46eSDavid Howells #define DLM_LKF_NOQUEUEBAST	0x00000800
152607ca46eSDavid Howells #define DLM_LKF_HEADQUE		0x00001000
153607ca46eSDavid Howells #define DLM_LKF_NOORDER		0x00002000
154607ca46eSDavid Howells #define DLM_LKF_ORPHAN		0x00004000
155607ca46eSDavid Howells #define DLM_LKF_ALTPR		0x00008000
156607ca46eSDavid Howells #define DLM_LKF_ALTCW		0x00010000
157607ca46eSDavid Howells #define DLM_LKF_FORCEUNLOCK	0x00020000
158607ca46eSDavid Howells #define DLM_LKF_TIMEOUT		0x00040000
159607ca46eSDavid Howells 
160607ca46eSDavid Howells /*
161607ca46eSDavid Howells  * Some return codes that are not in errno.h
162607ca46eSDavid Howells  */
163607ca46eSDavid Howells 
164607ca46eSDavid Howells #define DLM_ECANCEL		0x10001
165607ca46eSDavid Howells #define DLM_EUNLOCK		0x10002
166607ca46eSDavid Howells 
167607ca46eSDavid Howells #endif  /* __DLMCONSTANTS_DOT_H__ */
168