xref: /OK3568_Linux_fs/kernel/include/uapi/linux/dlmconstants.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2*4882a593Smuzhiyun /******************************************************************************
3*4882a593Smuzhiyun *******************************************************************************
4*4882a593Smuzhiyun **
5*4882a593Smuzhiyun **  Copyright (C) Sistina Software, Inc.  1997-2003  All rights reserved.
6*4882a593Smuzhiyun **  Copyright (C) 2004-2007 Red Hat, Inc.  All rights reserved.
7*4882a593Smuzhiyun **
8*4882a593Smuzhiyun **  This copyrighted material is made available to anyone wishing to use,
9*4882a593Smuzhiyun **  modify, copy, or redistribute it subject to the terms and conditions
10*4882a593Smuzhiyun **  of the GNU General Public License v.2.
11*4882a593Smuzhiyun **
12*4882a593Smuzhiyun *******************************************************************************
13*4882a593Smuzhiyun ******************************************************************************/
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun #ifndef __DLMCONSTANTS_DOT_H__
16*4882a593Smuzhiyun #define __DLMCONSTANTS_DOT_H__
17*4882a593Smuzhiyun 
18*4882a593Smuzhiyun /*
19*4882a593Smuzhiyun  * Constants used by DLM interface.
20*4882a593Smuzhiyun  */
21*4882a593Smuzhiyun 
22*4882a593Smuzhiyun #define DLM_LOCKSPACE_LEN       64
23*4882a593Smuzhiyun #define DLM_RESNAME_MAXLEN      64
24*4882a593Smuzhiyun 
25*4882a593Smuzhiyun 
26*4882a593Smuzhiyun /*
27*4882a593Smuzhiyun  * Lock Modes
28*4882a593Smuzhiyun  */
29*4882a593Smuzhiyun 
30*4882a593Smuzhiyun #define DLM_LOCK_IV		(-1)	/* invalid */
31*4882a593Smuzhiyun #define DLM_LOCK_NL		0	/* null */
32*4882a593Smuzhiyun #define DLM_LOCK_CR		1	/* concurrent read */
33*4882a593Smuzhiyun #define DLM_LOCK_CW		2	/* concurrent write */
34*4882a593Smuzhiyun #define DLM_LOCK_PR		3	/* protected read */
35*4882a593Smuzhiyun #define DLM_LOCK_PW		4	/* protected write */
36*4882a593Smuzhiyun #define DLM_LOCK_EX		5	/* exclusive */
37*4882a593Smuzhiyun 
38*4882a593Smuzhiyun 
39*4882a593Smuzhiyun /*
40*4882a593Smuzhiyun  * Flags to dlm_lock
41*4882a593Smuzhiyun  *
42*4882a593Smuzhiyun  * DLM_LKF_NOQUEUE
43*4882a593Smuzhiyun  *
44*4882a593Smuzhiyun  * Do not queue the lock request on the wait queue if it cannot be granted
45*4882a593Smuzhiyun  * immediately.  If the lock cannot be granted because of this flag, DLM will
46*4882a593Smuzhiyun  * either return -EAGAIN from the dlm_lock call or will return 0 from
47*4882a593Smuzhiyun  * dlm_lock and -EAGAIN in the lock status block when the AST is executed.
48*4882a593Smuzhiyun  *
49*4882a593Smuzhiyun  * DLM_LKF_CANCEL
50*4882a593Smuzhiyun  *
51*4882a593Smuzhiyun  * Used to cancel a pending lock request or conversion.  A converting lock is
52*4882a593Smuzhiyun  * returned to its previously granted mode.
53*4882a593Smuzhiyun  *
54*4882a593Smuzhiyun  * DLM_LKF_CONVERT
55*4882a593Smuzhiyun  *
56*4882a593Smuzhiyun  * Indicates a lock conversion request.  For conversions the name and namelen
57*4882a593Smuzhiyun  * are ignored and the lock ID in the LKSB is used to identify the lock.
58*4882a593Smuzhiyun  *
59*4882a593Smuzhiyun  * DLM_LKF_VALBLK
60*4882a593Smuzhiyun  *
61*4882a593Smuzhiyun  * Requests DLM to return the current contents of the lock value block in the
62*4882a593Smuzhiyun  * lock status block.  When this flag is set in a lock conversion from PW or EX
63*4882a593Smuzhiyun  * modes, DLM assigns the value specified in the lock status block to the lock
64*4882a593Smuzhiyun  * value block of the lock resource.  The LVB is a DLM_LVB_LEN size array
65*4882a593Smuzhiyun  * containing application-specific information.
66*4882a593Smuzhiyun  *
67*4882a593Smuzhiyun  * DLM_LKF_QUECVT
68*4882a593Smuzhiyun  *
69*4882a593Smuzhiyun  * Force a conversion request to be queued, even if it is compatible with
70*4882a593Smuzhiyun  * the granted modes of other locks on the same resource.
71*4882a593Smuzhiyun  *
72*4882a593Smuzhiyun  * DLM_LKF_IVVALBLK
73*4882a593Smuzhiyun  *
74*4882a593Smuzhiyun  * Invalidate the lock value block.
75*4882a593Smuzhiyun  *
76*4882a593Smuzhiyun  * DLM_LKF_CONVDEADLK
77*4882a593Smuzhiyun  *
78*4882a593Smuzhiyun  * Allows the dlm to resolve conversion deadlocks internally by demoting the
79*4882a593Smuzhiyun  * granted mode of a converting lock to NL.  The DLM_SBF_DEMOTED flag is
80*4882a593Smuzhiyun  * returned for a conversion that's been effected by this.
81*4882a593Smuzhiyun  *
82*4882a593Smuzhiyun  * DLM_LKF_PERSISTENT
83*4882a593Smuzhiyun  *
84*4882a593Smuzhiyun  * Only relevant to locks originating in userspace.  A persistent lock will not
85*4882a593Smuzhiyun  * be removed if the process holding the lock exits.
86*4882a593Smuzhiyun  *
87*4882a593Smuzhiyun  * DLM_LKF_NODLCKWT
88*4882a593Smuzhiyun  *
89*4882a593Smuzhiyun  * Do not cancel the lock if it gets into conversion deadlock.
90*4882a593Smuzhiyun  * Exclude this lock from being monitored due to DLM_LSFL_TIMEWARN.
91*4882a593Smuzhiyun  *
92*4882a593Smuzhiyun  * DLM_LKF_NODLCKBLK
93*4882a593Smuzhiyun  *
94*4882a593Smuzhiyun  * net yet implemented
95*4882a593Smuzhiyun  *
96*4882a593Smuzhiyun  * DLM_LKF_EXPEDITE
97*4882a593Smuzhiyun  *
98*4882a593Smuzhiyun  * Used only with new requests for NL mode locks.  Tells the lock manager
99*4882a593Smuzhiyun  * to grant the lock, ignoring other locks in convert and wait queues.
100*4882a593Smuzhiyun  *
101*4882a593Smuzhiyun  * DLM_LKF_NOQUEUEBAST
102*4882a593Smuzhiyun  *
103*4882a593Smuzhiyun  * Send blocking AST's before returning -EAGAIN to the caller.  It is only
104*4882a593Smuzhiyun  * used along with the NOQUEUE flag.  Blocking AST's are not sent for failed
105*4882a593Smuzhiyun  * NOQUEUE requests otherwise.
106*4882a593Smuzhiyun  *
107*4882a593Smuzhiyun  * DLM_LKF_HEADQUE
108*4882a593Smuzhiyun  *
109*4882a593Smuzhiyun  * Add a lock to the head of the convert or wait queue rather than the tail.
110*4882a593Smuzhiyun  *
111*4882a593Smuzhiyun  * DLM_LKF_NOORDER
112*4882a593Smuzhiyun  *
113*4882a593Smuzhiyun  * Disregard the standard grant order rules and grant a lock as soon as it
114*4882a593Smuzhiyun  * is compatible with other granted locks.
115*4882a593Smuzhiyun  *
116*4882a593Smuzhiyun  * DLM_LKF_ORPHAN
117*4882a593Smuzhiyun  *
118*4882a593Smuzhiyun  * Acquire an orphan lock.
119*4882a593Smuzhiyun  *
120*4882a593Smuzhiyun  * DLM_LKF_ALTPR
121*4882a593Smuzhiyun  *
122*4882a593Smuzhiyun  * If the requested mode cannot be granted immediately, try to grant the lock
123*4882a593Smuzhiyun  * in PR mode instead.  If this alternate mode is granted instead of the
124*4882a593Smuzhiyun  * requested mode, DLM_SBF_ALTMODE is returned in the lksb.
125*4882a593Smuzhiyun  *
126*4882a593Smuzhiyun  * DLM_LKF_ALTCW
127*4882a593Smuzhiyun  *
128*4882a593Smuzhiyun  * The same as ALTPR, but the alternate mode is CW.
129*4882a593Smuzhiyun  *
130*4882a593Smuzhiyun  * DLM_LKF_FORCEUNLOCK
131*4882a593Smuzhiyun  *
132*4882a593Smuzhiyun  * Unlock the lock even if it is converting or waiting or has sublocks.
133*4882a593Smuzhiyun  * Only really for use by the userland device.c code.
134*4882a593Smuzhiyun  *
135*4882a593Smuzhiyun  */
136*4882a593Smuzhiyun 
137*4882a593Smuzhiyun #define DLM_LKF_NOQUEUE		0x00000001
138*4882a593Smuzhiyun #define DLM_LKF_CANCEL		0x00000002
139*4882a593Smuzhiyun #define DLM_LKF_CONVERT		0x00000004
140*4882a593Smuzhiyun #define DLM_LKF_VALBLK		0x00000008
141*4882a593Smuzhiyun #define DLM_LKF_QUECVT		0x00000010
142*4882a593Smuzhiyun #define DLM_LKF_IVVALBLK	0x00000020
143*4882a593Smuzhiyun #define DLM_LKF_CONVDEADLK	0x00000040
144*4882a593Smuzhiyun #define DLM_LKF_PERSISTENT	0x00000080
145*4882a593Smuzhiyun #define DLM_LKF_NODLCKWT	0x00000100
146*4882a593Smuzhiyun #define DLM_LKF_NODLCKBLK	0x00000200
147*4882a593Smuzhiyun #define DLM_LKF_EXPEDITE	0x00000400
148*4882a593Smuzhiyun #define DLM_LKF_NOQUEUEBAST	0x00000800
149*4882a593Smuzhiyun #define DLM_LKF_HEADQUE		0x00001000
150*4882a593Smuzhiyun #define DLM_LKF_NOORDER		0x00002000
151*4882a593Smuzhiyun #define DLM_LKF_ORPHAN		0x00004000
152*4882a593Smuzhiyun #define DLM_LKF_ALTPR		0x00008000
153*4882a593Smuzhiyun #define DLM_LKF_ALTCW		0x00010000
154*4882a593Smuzhiyun #define DLM_LKF_FORCEUNLOCK	0x00020000
155*4882a593Smuzhiyun #define DLM_LKF_TIMEOUT		0x00040000
156*4882a593Smuzhiyun 
157*4882a593Smuzhiyun /*
158*4882a593Smuzhiyun  * Some return codes that are not in errno.h
159*4882a593Smuzhiyun  */
160*4882a593Smuzhiyun 
161*4882a593Smuzhiyun #define DLM_ECANCEL		0x10001
162*4882a593Smuzhiyun #define DLM_EUNLOCK		0x10002
163*4882a593Smuzhiyun 
164*4882a593Smuzhiyun #endif  /* __DLMCONSTANTS_DOT_H__ */
165