Skip to content

Commit f328a26

Browse files
Alexander Aringteigland
authored andcommitted
dlm: introduce DLM_LSFL_SOFTIRQ_SAFE
Introduce a new external lockspace flag DLM_LSFL_SOFTIRQ_SAFE. A lockspace user will set this flag if it can handle dlm running the callback functions from softirq context. When not set, dlm will continue to run callback functions from the dlm_callback workqueue. The new lockspace flag cannot be used for user space lockspaces, so a uapi placeholder definition is used for the new flag value. Signed-off-by: Alexander Aring <[email protected]> Signed-off-by: David Teigland <[email protected]>
1 parent d3d85e9 commit f328a26

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

fs/dlm/lockspace.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,9 @@ int dlm_new_user_lockspace(const char *name, const char *cluster,
629629
void *ops_arg, int *ops_result,
630630
dlm_lockspace_t **lockspace)
631631
{
632+
if (flags & DLM_LSFL_SOFTIRQ)
633+
return -EINVAL;
634+
632635
return __dlm_new_lockspace(name, cluster, flags, lvblen, ops,
633636
ops_arg, ops_result, lockspace);
634637
}

include/linux/dlm.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ struct dlm_lockspace_ops {
3535
int num_slots, int our_slot, uint32_t generation);
3636
};
3737

38+
/* only relevant for kernel lockspaces, will be removed in future */
39+
#define DLM_LSFL_SOFTIRQ __DLM_LSFL_RESERVED0
40+
3841
/*
3942
* dlm_new_lockspace
4043
*
@@ -55,6 +58,11 @@ struct dlm_lockspace_ops {
5558
* used to select the directory node. Must be the same on all nodes.
5659
* DLM_LSFL_NEWEXCL
5760
* dlm_new_lockspace() should return -EEXIST if the lockspace exists.
61+
* DLM_LSFL_SOFTIRQ
62+
* dlm request callbacks (ast, bast) are softirq safe. Flag should be
63+
* preferred by users. Will be default in some future. If set the
64+
* strongest context for ast, bast callback is softirq as it avoids
65+
* an additional context switch.
5866
*
5967
* lvblen: length of lvb in bytes. Must be multiple of 8.
6068
* dlm_new_lockspace() returns an error if this does not match
@@ -121,7 +129,14 @@ int dlm_release_lockspace(dlm_lockspace_t *lockspace, int force);
121129
* call.
122130
*
123131
* AST routines should not block (at least not for long), but may make
124-
* any locking calls they please.
132+
* any locking calls they please. If DLM_LSFL_SOFTIRQ for kernel
133+
* users of dlm_new_lockspace() is passed the ast and bast callbacks
134+
* can be processed in softirq context. Also some of the callback
135+
* contexts are in the same context as the DLM lock request API, users
136+
* must not hold locks while calling dlm lock request API and trying
137+
* to acquire this lock in the callback again, this will end in a
138+
* lock recursion. For newer implementation the DLM_LSFL_SOFTIRQ
139+
* should be used.
125140
*/
126141

127142
int dlm_lock(dlm_lockspace_t *lockspace,

include/uapi/linux/dlm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ struct dlm_lksb {
7171
/* DLM_LSFL_TIMEWARN is deprecated and reserved. DO NOT USE! */
7272
#define DLM_LSFL_TIMEWARN 0x00000002
7373
#define DLM_LSFL_NEWEXCL 0x00000008
74+
/* currently reserved due in-kernel use */
75+
#define __DLM_LSFL_RESERVED0 0x00000010
7476

7577

7678
#endif /* _UAPI__DLM_DOT_H__ */

0 commit comments

Comments
 (0)