![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0-only */ 0002 /****************************************************************************** 0003 ******************************************************************************* 0004 ** 0005 ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. 0006 ** Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved. 0007 ** 0008 ** 0009 ******************************************************************************* 0010 ******************************************************************************/ 0011 #ifndef __DLM_DOT_H__ 0012 #define __DLM_DOT_H__ 0013 0014 #include <uapi/linux/dlm.h> 0015 0016 0017 struct dlm_slot { 0018 int nodeid; /* 1 to MAX_INT */ 0019 int slot; /* 1 to MAX_INT */ 0020 }; 0021 0022 /* 0023 * recover_prep: called before the dlm begins lock recovery. 0024 * Notfies lockspace user that locks from failed members will be granted. 0025 * recover_slot: called after recover_prep and before recover_done. 0026 * Identifies a failed lockspace member. 0027 * recover_done: called after the dlm completes lock recovery. 0028 * Identifies lockspace members and lockspace generation number. 0029 */ 0030 0031 struct dlm_lockspace_ops { 0032 void (*recover_prep) (void *ops_arg); 0033 void (*recover_slot) (void *ops_arg, struct dlm_slot *slot); 0034 void (*recover_done) (void *ops_arg, struct dlm_slot *slots, 0035 int num_slots, int our_slot, uint32_t generation); 0036 }; 0037 0038 /* 0039 * dlm_new_lockspace 0040 * 0041 * Create/join a lockspace. 0042 * 0043 * name: lockspace name, null terminated, up to DLM_LOCKSPACE_LEN (not 0044 * including terminating null). 0045 * 0046 * cluster: cluster name, null terminated, up to DLM_LOCKSPACE_LEN (not 0047 * including terminating null). Optional. When cluster is null, it 0048 * is not used. When set, dlm_new_lockspace() returns -EBADR if cluster 0049 * is not equal to the dlm cluster name. 0050 * 0051 * flags: 0052 * DLM_LSFL_NODIR 0053 * The dlm should not use a resource directory, but statically assign 0054 * resource mastery to nodes based on the name hash that is otherwise 0055 * used to select the directory node. Must be the same on all nodes. 0056 * DLM_LSFL_TIMEWARN 0057 * The dlm should emit netlink messages if locks have been waiting 0058 * for a configurable amount of time. (Unused.) 0059 * DLM_LSFL_FS 0060 * The lockspace user is in the kernel (i.e. filesystem). Enables 0061 * direct bast/cast callbacks. 0062 * DLM_LSFL_NEWEXCL 0063 * dlm_new_lockspace() should return -EEXIST if the lockspace exists. 0064 * 0065 * lvblen: length of lvb in bytes. Must be multiple of 8. 0066 * dlm_new_lockspace() returns an error if this does not match 0067 * what other nodes are using. 0068 * 0069 * ops: callbacks that indicate lockspace recovery points so the 0070 * caller can coordinate its recovery and know lockspace members. 0071 * This is only used by the initial dlm_new_lockspace() call. 0072 * Optional. 0073 * 0074 * ops_arg: arg for ops callbacks. 0075 * 0076 * ops_result: tells caller if the ops callbacks (if provided) will 0077 * be used or not. 0: will be used, -EXXX will not be used. 0078 * -EOPNOTSUPP: the dlm does not have recovery_callbacks enabled. 0079 * 0080 * lockspace: handle for dlm functions 0081 */ 0082 0083 int dlm_new_lockspace(const char *name, const char *cluster, 0084 uint32_t flags, int lvblen, 0085 const struct dlm_lockspace_ops *ops, void *ops_arg, 0086 int *ops_result, dlm_lockspace_t **lockspace); 0087 0088 /* 0089 * dlm_release_lockspace 0090 * 0091 * Stop a lockspace. 0092 */ 0093 0094 int dlm_release_lockspace(dlm_lockspace_t *lockspace, int force); 0095 0096 /* 0097 * dlm_lock 0098 * 0099 * Make an asynchronous request to acquire or convert a lock on a named 0100 * resource. 0101 * 0102 * lockspace: context for the request 0103 * mode: the requested mode of the lock (DLM_LOCK_) 0104 * lksb: lock status block for input and async return values 0105 * flags: input flags (DLM_LKF_) 0106 * name: name of the resource to lock, can be binary 0107 * namelen: the length in bytes of the resource name (MAX_RESNAME_LEN) 0108 * parent: the lock ID of a parent lock or 0 if none 0109 * lockast: function DLM executes when it completes processing the request 0110 * astarg: argument passed to lockast and bast functions 0111 * bast: function DLM executes when this lock later blocks another request 0112 * 0113 * Returns: 0114 * 0 if request is successfully queued for processing 0115 * -EINVAL if any input parameters are invalid 0116 * -EAGAIN if request would block and is flagged DLM_LKF_NOQUEUE 0117 * -ENOMEM if there is no memory to process request 0118 * -ENOTCONN if there is a communication error 0119 * 0120 * If the call to dlm_lock returns an error then the operation has failed and 0121 * the AST routine will not be called. If dlm_lock returns 0 it is still 0122 * possible that the lock operation will fail. The AST routine will be called 0123 * when the locking is complete and the status is returned in the lksb. 0124 * 0125 * If the AST routines or parameter are passed to a conversion operation then 0126 * they will overwrite those values that were passed to a previous dlm_lock 0127 * call. 0128 * 0129 * AST routines should not block (at least not for long), but may make 0130 * any locking calls they please. 0131 */ 0132 0133 int dlm_lock(dlm_lockspace_t *lockspace, 0134 int mode, 0135 struct dlm_lksb *lksb, 0136 uint32_t flags, 0137 void *name, 0138 unsigned int namelen, 0139 uint32_t parent_lkid, 0140 void (*lockast) (void *astarg), 0141 void *astarg, 0142 void (*bast) (void *astarg, int mode)); 0143 0144 /* 0145 * dlm_unlock 0146 * 0147 * Asynchronously release a lock on a resource. The AST routine is called 0148 * when the resource is successfully unlocked. 0149 * 0150 * lockspace: context for the request 0151 * lkid: the lock ID as returned in the lksb 0152 * flags: input flags (DLM_LKF_) 0153 * lksb: if NULL the lksb parameter passed to last lock request is used 0154 * astarg: the arg used with the completion ast for the unlock 0155 * 0156 * Returns: 0157 * 0 if request is successfully queued for processing 0158 * -EINVAL if any input parameters are invalid 0159 * -ENOTEMPTY if the lock still has sublocks 0160 * -EBUSY if the lock is waiting for a remote lock operation 0161 * -ENOTCONN if there is a communication error 0162 */ 0163 0164 int dlm_unlock(dlm_lockspace_t *lockspace, 0165 uint32_t lkid, 0166 uint32_t flags, 0167 struct dlm_lksb *lksb, 0168 void *astarg); 0169 0170 #endif /* __DLM_DOT_H__ */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |