Linux Audio

Check our new training course

Linux kernel drivers training

Mar 31-Apr 9, 2025, special US time zones
Register
Loading...
v5.4
  1/* SPDX-License-Identifier: GPL-2.0-or-later */
  2/* -*- mode: c; c-basic-offset: 8; -*-
  3 * vim: noexpandtab sw=8 ts=8 sts=0:
  4 *
  5 * dlmapi.h
  6 *
  7 * externally exported dlm interfaces
  8 *
  9 * Copyright (C) 2004 Oracle.  All rights reserved.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 10 */
 11
 12#ifndef DLMAPI_H
 13#define DLMAPI_H
 14
 15struct dlm_lock;
 16struct dlm_ctxt;
 17
 18/* NOTE: changes made to this enum should be reflected in dlmdebug.c */
 19enum dlm_status {
 20	DLM_NORMAL = 0,           /*  0: request in progress */
 21	DLM_GRANTED,              /*  1: request granted */
 22	DLM_DENIED,               /*  2: request denied */
 23	DLM_DENIED_NOLOCKS,       /*  3: request denied, out of system resources */
 24	DLM_WORKING,              /*  4: async request in progress */
 25	DLM_BLOCKED,              /*  5: lock request blocked */
 26	DLM_BLOCKED_ORPHAN,       /*  6: lock request blocked by a orphan lock*/
 27	DLM_DENIED_GRACE_PERIOD,  /*  7: topological change in progress */
 28	DLM_SYSERR,               /*  8: system error */
 29	DLM_NOSUPPORT,            /*  9: unsupported */
 30	DLM_CANCELGRANT,          /* 10: can't cancel convert: already granted */
 31	DLM_IVLOCKID,             /* 11: bad lockid */
 32	DLM_SYNC,                 /* 12: synchronous request granted */
 33	DLM_BADTYPE,              /* 13: bad resource type */
 34	DLM_BADRESOURCE,          /* 14: bad resource handle */
 35	DLM_MAXHANDLES,           /* 15: no more resource handles */
 36	DLM_NOCLINFO,             /* 16: can't contact cluster manager */
 37	DLM_NOLOCKMGR,            /* 17: can't contact lock manager */
 38	DLM_NOPURGED,             /* 18: can't contact purge daemon */
 39	DLM_BADARGS,              /* 19: bad api args */
 40	DLM_VOID,                 /* 20: no status */
 41	DLM_NOTQUEUED,            /* 21: NOQUEUE was specified and request failed */
 42	DLM_IVBUFLEN,             /* 22: invalid resource name length */
 43	DLM_CVTUNGRANT,           /* 23: attempted to convert ungranted lock */
 44	DLM_BADPARAM,             /* 24: invalid lock mode specified */
 45	DLM_VALNOTVALID,          /* 25: value block has been invalidated */
 46	DLM_REJECTED,             /* 26: request rejected, unrecognized client */
 47	DLM_ABORT,                /* 27: blocked lock request cancelled */
 48	DLM_CANCEL,               /* 28: conversion request cancelled */
 49	DLM_IVRESHANDLE,          /* 29: invalid resource handle */
 50	DLM_DEADLOCK,             /* 30: deadlock recovery refused this request */
 51	DLM_DENIED_NOASTS,        /* 31: failed to allocate AST */
 52	DLM_FORWARD,              /* 32: request must wait for primary's response */
 53	DLM_TIMEOUT,              /* 33: timeout value for lock has expired */
 54	DLM_IVGROUPID,            /* 34: invalid group specification */
 55	DLM_VERS_CONFLICT,        /* 35: version conflicts prevent request handling */
 56	DLM_BAD_DEVICE_PATH,      /* 36: Locks device does not exist or path wrong */
 57	DLM_NO_DEVICE_PERMISSION, /* 37: Client has insufficient pers for device */
 58	DLM_NO_CONTROL_DEVICE,    /* 38: Cannot set options on opened device */
 59
 60	DLM_RECOVERING,           /* 39: extension, allows caller to fail a lock
 61				     request if it is being recovered */
 62	DLM_MIGRATING,            /* 40: extension, allows caller to fail a lock
 63				     request if it is being migrated */
 64	DLM_MAXSTATS,             /* 41: upper limit for return code validation */
 65};
 66
 67/* for pretty-printing dlm_status error messages */
 68const char *dlm_errmsg(enum dlm_status err);
 69/* for pretty-printing dlm_status error names */
 70const char *dlm_errname(enum dlm_status err);
 71
 72/* Eventually the DLM will use standard errno values, but in the
 73 * meantime this lets us track dlm errors as they bubble up. When we
 74 * bring its error reporting into line with the rest of the stack,
 75 * these can just be replaced with calls to mlog_errno. */
 76#define dlm_error(st) do {						\
 77	if ((st) != DLM_RECOVERING &&					\
 78	    (st) != DLM_MIGRATING &&					\
 79	    (st) != DLM_FORWARD)					\
 80		mlog(ML_ERROR, "dlm status = %s\n", dlm_errname((st)));	\
 81} while (0)
 82
 83#define DLM_LKSB_UNUSED1           0x01
 84#define DLM_LKSB_PUT_LVB           0x02
 85#define DLM_LKSB_GET_LVB           0x04
 86#define DLM_LKSB_UNUSED2           0x08
 87#define DLM_LKSB_UNUSED3           0x10
 88#define DLM_LKSB_UNUSED4           0x20
 89#define DLM_LKSB_UNUSED5           0x40
 90#define DLM_LKSB_UNUSED6           0x80
 91
 92#define DLM_LVB_LEN  64
 93
 94/* Callers are only allowed access to the lvb and status members of
 95 * this struct. */
 96struct dlm_lockstatus {
 97	enum dlm_status status;
 98	u32 flags;
 99	struct dlm_lock *lockid;
100	char lvb[DLM_LVB_LEN];
101};
102
103/* Valid lock modes. */
104#define LKM_IVMODE      (-1)            /* invalid mode */
105#define LKM_NLMODE      0               /* null lock */
106#define LKM_CRMODE      1               /* concurrent read    unsupported */
107#define LKM_CWMODE      2               /* concurrent write   unsupported */
108#define LKM_PRMODE      3               /* protected read */
109#define LKM_PWMODE      4               /* protected write    unsupported */
110#define LKM_EXMODE      5               /* exclusive */
111#define LKM_MAXMODE     5
112#define LKM_MODEMASK    0xff
113
114/* Flags passed to dlmlock and dlmunlock:
115 * reserved: flags used by the "real" dlm
116 * only a few are supported by this dlm
117 * (U) = unsupported by ocfs2 dlm */
118#define LKM_ORPHAN       0x00000010  /* this lock is orphanable (U) */
119#define LKM_PARENTABLE   0x00000020  /* this lock was orphaned (U) */
120#define LKM_BLOCK        0x00000040  /* blocking lock request (U) */
121#define LKM_LOCAL        0x00000080  /* local lock request */
122#define LKM_VALBLK       0x00000100  /* lock value block request */
123#define LKM_NOQUEUE      0x00000200  /* non blocking request */
124#define LKM_CONVERT      0x00000400  /* conversion request */
125#define LKM_NODLCKWT     0x00000800  /* this lock wont deadlock (U) */
126#define LKM_UNLOCK       0x00001000  /* deallocate this lock */
127#define LKM_CANCEL       0x00002000  /* cancel conversion request */
128#define LKM_DEQALL       0x00004000  /* remove all locks held by proc (U) */
129#define LKM_INVVALBLK    0x00008000  /* invalidate lock value block */
130#define LKM_SYNCSTS      0x00010000  /* return synchronous status if poss (U) */
131#define LKM_TIMEOUT      0x00020000  /* lock request contains timeout (U) */
132#define LKM_SNGLDLCK     0x00040000  /* request can self-deadlock (U) */
133#define LKM_FINDLOCAL    0x00080000  /* find local lock request (U) */
134#define LKM_PROC_OWNED   0x00100000  /* owned by process, not group (U) */
135#define LKM_XID          0x00200000  /* use transaction id for deadlock (U) */
136#define LKM_XID_CONFLICT 0x00400000  /* do not allow lock inheritance (U) */
137#define LKM_FORCE        0x00800000  /* force unlock flag */
138#define LKM_REVVALBLK    0x01000000  /* temporary solution: re-validate
139					lock value block (U) */
140/* unused */
141#define LKM_UNUSED1      0x00000001  /* unused */
142#define LKM_UNUSED2      0x00000002  /* unused */
143#define LKM_UNUSED3      0x00000004  /* unused */
144#define LKM_UNUSED4      0x00000008  /* unused */
145#define LKM_UNUSED5      0x02000000  /* unused */
146#define LKM_UNUSED6      0x04000000  /* unused */
147#define LKM_UNUSED7      0x08000000  /* unused */
148
149/* ocfs2 extensions: internal only
150 * should never be used by caller */
151#define LKM_MIGRATION    0x10000000  /* extension: lockres is to be migrated
152					to another node */
153#define LKM_PUT_LVB      0x20000000  /* extension: lvb is being passed
154					should be applied to lockres */
155#define LKM_GET_LVB      0x40000000  /* extension: lvb should be copied
156					from lockres when lock is granted */
157#define LKM_RECOVERY     0x80000000  /* extension: flag for recovery lock
158					used to avoid recovery rwsem */
159
160
161typedef void (dlm_astlockfunc_t)(void *);
162typedef void (dlm_bastlockfunc_t)(void *, int);
163typedef void (dlm_astunlockfunc_t)(void *, enum dlm_status);
164
165enum dlm_status dlmlock(struct dlm_ctxt *dlm,
166			int mode,
167			struct dlm_lockstatus *lksb,
168			int flags,
169			const char *name,
170			int namelen,
171			dlm_astlockfunc_t *ast,
172			void *data,
173			dlm_bastlockfunc_t *bast);
174
175enum dlm_status dlmunlock(struct dlm_ctxt *dlm,
176			  struct dlm_lockstatus *lksb,
177			  int flags,
178			  dlm_astunlockfunc_t *unlockast,
179			  void *data);
180
181struct dlm_protocol_version {
182	u8 pv_major;
183	u8 pv_minor;
184};
185struct dlm_ctxt * dlm_register_domain(const char *domain, u32 key,
186				      struct dlm_protocol_version *fs_proto);
187
188void dlm_unregister_domain(struct dlm_ctxt *dlm);
189
190void dlm_print_one_lock(struct dlm_lock *lockid);
191
192typedef void (dlm_eviction_func)(int, void *);
193struct dlm_eviction_cb {
194	struct list_head        ec_item;
195	dlm_eviction_func       *ec_func;
196	void                    *ec_data;
197};
198void dlm_setup_eviction_cb(struct dlm_eviction_cb *cb,
199			   dlm_eviction_func *f,
200			   void *data);
201void dlm_register_eviction_cb(struct dlm_ctxt *dlm,
202			      struct dlm_eviction_cb *cb);
203void dlm_unregister_eviction_cb(struct dlm_eviction_cb *cb);
204
205#endif /* DLMAPI_H */
v3.1
 
  1/* -*- mode: c; c-basic-offset: 8; -*-
  2 * vim: noexpandtab sw=8 ts=8 sts=0:
  3 *
  4 * dlmapi.h
  5 *
  6 * externally exported dlm interfaces
  7 *
  8 * Copyright (C) 2004 Oracle.  All rights reserved.
  9 *
 10 * This program is free software; you can redistribute it and/or
 11 * modify it under the terms of the GNU General Public
 12 * License as published by the Free Software Foundation; either
 13 * version 2 of the License, or (at your option) any later version.
 14 *
 15 * This program is distributed in the hope that it will be useful,
 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 18 * General Public License for more details.
 19 *
 20 * You should have received a copy of the GNU General Public
 21 * License along with this program; if not, write to the
 22 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 23 * Boston, MA 021110-1307, USA.
 24 *
 25 */
 26
 27#ifndef DLMAPI_H
 28#define DLMAPI_H
 29
 30struct dlm_lock;
 31struct dlm_ctxt;
 32
 33/* NOTE: changes made to this enum should be reflected in dlmdebug.c */
 34enum dlm_status {
 35	DLM_NORMAL = 0,           /*  0: request in progress */
 36	DLM_GRANTED,              /*  1: request granted */
 37	DLM_DENIED,               /*  2: request denied */
 38	DLM_DENIED_NOLOCKS,       /*  3: request denied, out of system resources */
 39	DLM_WORKING,              /*  4: async request in progress */
 40	DLM_BLOCKED,              /*  5: lock request blocked */
 41	DLM_BLOCKED_ORPHAN,       /*  6: lock request blocked by a orphan lock*/
 42	DLM_DENIED_GRACE_PERIOD,  /*  7: topological change in progress */
 43	DLM_SYSERR,               /*  8: system error */
 44	DLM_NOSUPPORT,            /*  9: unsupported */
 45	DLM_CANCELGRANT,          /* 10: can't cancel convert: already granted */
 46	DLM_IVLOCKID,             /* 11: bad lockid */
 47	DLM_SYNC,                 /* 12: synchronous request granted */
 48	DLM_BADTYPE,              /* 13: bad resource type */
 49	DLM_BADRESOURCE,          /* 14: bad resource handle */
 50	DLM_MAXHANDLES,           /* 15: no more resource handles */
 51	DLM_NOCLINFO,             /* 16: can't contact cluster manager */
 52	DLM_NOLOCKMGR,            /* 17: can't contact lock manager */
 53	DLM_NOPURGED,             /* 18: can't contact purge daemon */
 54	DLM_BADARGS,              /* 19: bad api args */
 55	DLM_VOID,                 /* 20: no status */
 56	DLM_NOTQUEUED,            /* 21: NOQUEUE was specified and request failed */
 57	DLM_IVBUFLEN,             /* 22: invalid resource name length */
 58	DLM_CVTUNGRANT,           /* 23: attempted to convert ungranted lock */
 59	DLM_BADPARAM,             /* 24: invalid lock mode specified */
 60	DLM_VALNOTVALID,          /* 25: value block has been invalidated */
 61	DLM_REJECTED,             /* 26: request rejected, unrecognized client */
 62	DLM_ABORT,                /* 27: blocked lock request cancelled */
 63	DLM_CANCEL,               /* 28: conversion request cancelled */
 64	DLM_IVRESHANDLE,          /* 29: invalid resource handle */
 65	DLM_DEADLOCK,             /* 30: deadlock recovery refused this request */
 66	DLM_DENIED_NOASTS,        /* 31: failed to allocate AST */
 67	DLM_FORWARD,              /* 32: request must wait for primary's response */
 68	DLM_TIMEOUT,              /* 33: timeout value for lock has expired */
 69	DLM_IVGROUPID,            /* 34: invalid group specification */
 70	DLM_VERS_CONFLICT,        /* 35: version conflicts prevent request handling */
 71	DLM_BAD_DEVICE_PATH,      /* 36: Locks device does not exist or path wrong */
 72	DLM_NO_DEVICE_PERMISSION, /* 37: Client has insufficient pers for device */
 73	DLM_NO_CONTROL_DEVICE,    /* 38: Cannot set options on opened device */
 74
 75	DLM_RECOVERING,           /* 39: extension, allows caller to fail a lock
 76				     request if it is being recovered */
 77	DLM_MIGRATING,            /* 40: extension, allows caller to fail a lock
 78				     request if it is being migrated */
 79	DLM_MAXSTATS,             /* 41: upper limit for return code validation */
 80};
 81
 82/* for pretty-printing dlm_status error messages */
 83const char *dlm_errmsg(enum dlm_status err);
 84/* for pretty-printing dlm_status error names */
 85const char *dlm_errname(enum dlm_status err);
 86
 87/* Eventually the DLM will use standard errno values, but in the
 88 * meantime this lets us track dlm errors as they bubble up. When we
 89 * bring its error reporting into line with the rest of the stack,
 90 * these can just be replaced with calls to mlog_errno. */
 91#define dlm_error(st) do {						\
 92	if ((st) != DLM_RECOVERING &&					\
 93	    (st) != DLM_MIGRATING &&					\
 94	    (st) != DLM_FORWARD)					\
 95		mlog(ML_ERROR, "dlm status = %s\n", dlm_errname((st)));	\
 96} while (0)
 97
 98#define DLM_LKSB_UNUSED1           0x01
 99#define DLM_LKSB_PUT_LVB           0x02
100#define DLM_LKSB_GET_LVB           0x04
101#define DLM_LKSB_UNUSED2           0x08
102#define DLM_LKSB_UNUSED3           0x10
103#define DLM_LKSB_UNUSED4           0x20
104#define DLM_LKSB_UNUSED5           0x40
105#define DLM_LKSB_UNUSED6           0x80
106
107#define DLM_LVB_LEN  64
108
109/* Callers are only allowed access to the lvb and status members of
110 * this struct. */
111struct dlm_lockstatus {
112	enum dlm_status status;
113	u32 flags;
114	struct dlm_lock *lockid;
115	char lvb[DLM_LVB_LEN];
116};
117
118/* Valid lock modes. */
119#define LKM_IVMODE      (-1)            /* invalid mode */
120#define LKM_NLMODE      0               /* null lock */
121#define LKM_CRMODE      1               /* concurrent read    unsupported */
122#define LKM_CWMODE      2               /* concurrent write   unsupported */
123#define LKM_PRMODE      3               /* protected read */
124#define LKM_PWMODE      4               /* protected write    unsupported */
125#define LKM_EXMODE      5               /* exclusive */
126#define LKM_MAXMODE     5
127#define LKM_MODEMASK    0xff
128
129/* Flags passed to dlmlock and dlmunlock:
130 * reserved: flags used by the "real" dlm
131 * only a few are supported by this dlm
132 * (U) = unsupported by ocfs2 dlm */
133#define LKM_ORPHAN       0x00000010  /* this lock is orphanable (U) */
134#define LKM_PARENTABLE   0x00000020  /* this lock was orphaned (U) */
135#define LKM_BLOCK        0x00000040  /* blocking lock request (U) */
136#define LKM_LOCAL        0x00000080  /* local lock request */
137#define LKM_VALBLK       0x00000100  /* lock value block request */
138#define LKM_NOQUEUE      0x00000200  /* non blocking request */
139#define LKM_CONVERT      0x00000400  /* conversion request */
140#define LKM_NODLCKWT     0x00000800  /* this lock wont deadlock (U) */
141#define LKM_UNLOCK       0x00001000  /* deallocate this lock */
142#define LKM_CANCEL       0x00002000  /* cancel conversion request */
143#define LKM_DEQALL       0x00004000  /* remove all locks held by proc (U) */
144#define LKM_INVVALBLK    0x00008000  /* invalidate lock value block */
145#define LKM_SYNCSTS      0x00010000  /* return synchronous status if poss (U) */
146#define LKM_TIMEOUT      0x00020000  /* lock request contains timeout (U) */
147#define LKM_SNGLDLCK     0x00040000  /* request can self-deadlock (U) */
148#define LKM_FINDLOCAL    0x00080000  /* find local lock request (U) */
149#define LKM_PROC_OWNED   0x00100000  /* owned by process, not group (U) */
150#define LKM_XID          0x00200000  /* use transaction id for deadlock (U) */
151#define LKM_XID_CONFLICT 0x00400000  /* do not allow lock inheritance (U) */
152#define LKM_FORCE        0x00800000  /* force unlock flag */
153#define LKM_REVVALBLK    0x01000000  /* temporary solution: re-validate
154					lock value block (U) */
155/* unused */
156#define LKM_UNUSED1      0x00000001  /* unused */
157#define LKM_UNUSED2      0x00000002  /* unused */
158#define LKM_UNUSED3      0x00000004  /* unused */
159#define LKM_UNUSED4      0x00000008  /* unused */
160#define LKM_UNUSED5      0x02000000  /* unused */
161#define LKM_UNUSED6      0x04000000  /* unused */
162#define LKM_UNUSED7      0x08000000  /* unused */
163
164/* ocfs2 extensions: internal only
165 * should never be used by caller */
166#define LKM_MIGRATION    0x10000000  /* extension: lockres is to be migrated
167					to another node */
168#define LKM_PUT_LVB      0x20000000  /* extension: lvb is being passed
169					should be applied to lockres */
170#define LKM_GET_LVB      0x40000000  /* extension: lvb should be copied
171					from lockres when lock is granted */
172#define LKM_RECOVERY     0x80000000  /* extension: flag for recovery lock
173					used to avoid recovery rwsem */
174
175
176typedef void (dlm_astlockfunc_t)(void *);
177typedef void (dlm_bastlockfunc_t)(void *, int);
178typedef void (dlm_astunlockfunc_t)(void *, enum dlm_status);
179
180enum dlm_status dlmlock(struct dlm_ctxt *dlm,
181			int mode,
182			struct dlm_lockstatus *lksb,
183			int flags,
184			const char *name,
185			int namelen,
186			dlm_astlockfunc_t *ast,
187			void *data,
188			dlm_bastlockfunc_t *bast);
189
190enum dlm_status dlmunlock(struct dlm_ctxt *dlm,
191			  struct dlm_lockstatus *lksb,
192			  int flags,
193			  dlm_astunlockfunc_t *unlockast,
194			  void *data);
195
196struct dlm_protocol_version {
197	u8 pv_major;
198	u8 pv_minor;
199};
200struct dlm_ctxt * dlm_register_domain(const char *domain, u32 key,
201				      struct dlm_protocol_version *fs_proto);
202
203void dlm_unregister_domain(struct dlm_ctxt *dlm);
204
205void dlm_print_one_lock(struct dlm_lock *lockid);
206
207typedef void (dlm_eviction_func)(int, void *);
208struct dlm_eviction_cb {
209	struct list_head        ec_item;
210	dlm_eviction_func       *ec_func;
211	void                    *ec_data;
212};
213void dlm_setup_eviction_cb(struct dlm_eviction_cb *cb,
214			   dlm_eviction_func *f,
215			   void *data);
216void dlm_register_eviction_cb(struct dlm_ctxt *dlm,
217			      struct dlm_eviction_cb *cb);
218void dlm_unregister_eviction_cb(struct dlm_eviction_cb *cb);
219
220#endif /* DLMAPI_H */