Skip to contentSkip to conversation

fs: dlm: move internal non shared flags to bitops

PATCH New Alexander Aring 1 participant 2 messages Feb 17, 2023

Subsystems (2)
lore
Share & tools
lore

Alexander Aring

author maintainer
#0 lore raw

PATCH v2 1/2 fs: dlm: move internal non shared flags to bitops

This patch moves all upper bits of lkb->lkb_flags to lkb->lkb_insflags, except DLM_IFL_STUB_MS which needs a special handling. Those upper bits are non shared internal flags which should be separated from lkb->lkb_flags because they get read, masked and assigned again in a non atomic way e.g. in receive_flags(). Due concurrent possible flag like dlm_lock()/unlock() or user device handling changes could be reverted. When moving to lkb->lkb_insflags we converted all bit operations to atomic set/test/clear bit operation functions.

---
 fs/dlm/dlm_internal.h      |  32 +++++------
 fs/dlm/lock.c              | 114 ++++++++++++++++++-------------------
 fs/dlm/lockspace.c         |   2 +-
 fs/dlm/recover.c           |   2 +-
 fs/dlm/user.c              |  10 ++--
 include/trace/events/dlm.h |   7 ---
 6 files changed, 79 insertions(+), 88 deletions(-)
fs/dlm/dlm_internal.h +16 -16
index b967b4d7d55d..ce0a15858ae3 100644
@@ -197,26 +197,25 @@ struct dlm_args {
 #define DLM_LKSTS_GRANTED	2
 #define DLM_LKSTS_CONVERT	3
 
-/* lkb_flags */
-
-#define DLM_IFL_MSTCPY		0x00010000
-#define DLM_IFL_RESEND		0x00020000
-#define DLM_IFL_DEAD		0x00040000
-#define DLM_IFL_OVERLAP_UNLOCK  0x00080000
-#define DLM_IFL_OVERLAP_CANCEL  0x00100000
-#define DLM_IFL_ENDOFLIFE	0x00200000
-#ifdef CONFIG_DLM_DEPRECATED_API
-#define DLM_IFL_WATCH_TIMEWARN	0x00400000
-#define DLM_IFL_TIMEOUT_CANCEL	0x00800000
-#endif
-#define DLM_IFL_DEADLOCK_CANCEL	0x01000000
-#define DLM_IFL_STUB_MS		0x02000000 /* magic number for m_flags */
-
 /* lkb_insflags */
 
 #define DLM_IFLNS_CB_PENDING	0
+#define DLM_IFLNS_MSTCPY	1
+#define DLM_IFLNS_RESEND	2
+#define DLM_IFLNS_DEAD		3
+#define DLM_IFLNS_OVERLAP_UNLOCK 4
+#define DLM_IFLNS_OVERLAP_CANCEL 5
+#define DLM_IFLNS_ENDOFLIFE	6
+#ifdef CONFIG_DLM_DEPRECATED_API
+#define DLM_IFLNS_WATCH_TIMEWARN 7
+#define DLM_IFLNS_TIMEOUT_CANCEL 8
+#endif
+#define DLM_IFLNS_DEADLOCK_CANCEL 9
+
 
-/* least significant 2 bytes are message changed, they are full transmitted
+/* lkb_flags
+ *
+ * least significant 2 bytes are message changed, they are full transmitted
  * but at receive side only the 2 bytes LSB will be set.
  *
  * Even wireshark dlm dissector does only evaluate the lower bytes and note
@@ -226,6 +225,7 @@ struct dlm_args {
  */
 #define DLM_IFL_USER		0x00000001
 #define DLM_IFL_ORPHAN		0x00000002
+#define DLM_IFL_STUB_MS		0x00010000
 
 #define DLM_CB_CAST		0x00000001
 #define DLM_CB_BAST		0x00000002
fs/dlm/lock.c +55 -59

339 lines not on this page · raw message

fs/dlm/lockspace.c +1 -1
index 9f344d76afa3..c879549aca40 100644
@@ -764,7 +764,7 @@ static int lkb_idr_free(int id, void *p, void *data)
 {
 	struct dlm_lkb *lkb = p;
 
-	if (lkb->lkb_lvbptr && lkb->lkb_flags & DLM_IFL_MSTCPY)
+	if (lkb->lkb_lvbptr && test_bit(DLM_IFLNS_MSTCPY, &lkb->lkb_insflags))
 		dlm_free_lvb(lkb->lkb_lvbptr);
 
 	dlm_free_lkb(lkb);
fs/dlm/recover.c +1 -1
index ccff1791803f..00cb2b3b85a3 100644
@@ -403,7 +403,7 @@ static void set_lock_master(struct list_head *queue, int nodeid)
 	struct dlm_lkb *lkb;
 
 	list_for_each_entry(lkb, queue, lkb_statequeue) {
-		if (!(lkb->lkb_flags & DLM_IFL_MSTCPY)) {
+		if (!test_bit(DLM_IFLNS_MSTCPY, &lkb->lkb_insflags)) {
 			lkb->lkb_nodeid = nodeid;
 			lkb->lkb_remid = 0;
 		}
fs/dlm/user.c +6 -4
index 98488a1b702d..15715dd18c67 100644
@@ -183,7 +183,8 @@ void dlm_user_add_ast(struct dlm_lkb *lkb, uint32_t flags, int mode,
 	struct dlm_user_proc *proc;
 	int rv;
 
-	if (lkb->lkb_flags & (DLM_IFL_ORPHAN | DLM_IFL_DEAD))
+	if ((lkb->lkb_flags & DLM_IFL_ORPHAN) ||
+	    test_bit(DLM_IFLNS_DEAD, &lkb->lkb_insflags))
 		return;
 
 	ls = lkb->lkb_resource->res_ls;
@@ -195,7 +196,8 @@ void dlm_user_add_ast(struct dlm_lkb *lkb, uint32_t flags, int mode,
 	   for cases where a completion ast is received for an operation that
 	   began before clear_proc_locks did its cancel/unlock. */
 
-	if (lkb->lkb_flags & (DLM_IFL_ORPHAN | DLM_IFL_DEAD))
+	if ((lkb->lkb_flags & DLM_IFL_ORPHAN) ||
+	    test_bit(DLM_IFLNS_DEAD, &lkb->lkb_insflags))
 		goto out;
 
 	DLM_ASSERT(lkb->lkb_ua, dlm_print_lkb(lkb););
@@ -206,7 +208,7 @@ void dlm_user_add_ast(struct dlm_lkb *lkb, uint32_t flags, int mode,
 		goto out;
 
 	if ((flags & DLM_CB_CAST) && lkb_is_endoflife(mode, status))
-		lkb->lkb_flags |= DLM_IFL_ENDOFLIFE;
+		set_bit(DLM_IFLNS_ENDOFLIFE, &lkb->lkb_insflags);
 
 	spin_lock(&proc->asts_spin);
 
@@ -229,7 +231,7 @@ void dlm_user_add_ast(struct dlm_lkb *lkb, uint32_t flags, int mode,
 	}
 	spin_unlock(&proc->asts_spin);
 
-	if (lkb->lkb_flags & DLM_IFL_ENDOFLIFE) {
+	if (test_bit(DLM_IFLNS_ENDOFLIFE, &lkb->lkb_insflags)) {
 		/* N.B. spin_lock locks_spin, not asts_spin */
 		spin_lock(&proc->locks_spin);
 		if (!list_empty(&lkb->lkb_ownqueue)) {
include/trace/events/dlm.h +0 -7
index 37eb79e29b28..a34cd2e62691 100644
@@ -47,13 +47,6 @@
 	{ DLM_SBF_ALTMODE,	"ALTMODE" })
 
 #define show_lkb_flags(flags) __print_flags(flags, "|",		\
-	{ DLM_IFL_MSTCPY,	"MSTCPY" },			\
-	{ DLM_IFL_RESEND,	"RESEND" },			\
-	{ DLM_IFL_DEAD,		"DEAD" },			\
-	{ DLM_IFL_OVERLAP_UNLOCK, "OVERLAP_UNLOCK" },		\
-	{ DLM_IFL_OVERLAP_CANCEL, "OVERLAP_CANCEL" },		\
-	{ DLM_IFL_ENDOFLIFE,	"ENDOFLIFE" },			\
-	{ DLM_IFL_DEADLOCK_CANCEL, "DEADLOCK_CANCEL" },		\
 	{ DLM_IFL_STUB_MS,	"STUB_MS" },			\
 	{ DLM_IFL_USER,		"USER" },			\
 	{ DLM_IFL_ORPHAN,	"ORPHAN" })
Signature · 1 line
2.31.1
author maintainer
#1 lore raw

PATCH v2 2/2 fs: dlm: remove DLM_IFL_STUB_MS flag

The DLM_IFL_STUB_MS flag is an internal non shared flag but used in m_flags of dlm messages. It is not shared because it is only used for local messaging. Instead using DLM_IFL_STUB_MS in dlm messages we pass a parameter around to signal local messaging or not. This patch is adding the stub parameter to signal local messaging. Finally this patch removes the read/mask/write operation to lkb->lkb_flags which is not only used for shared internal flags like DLM_IFL_USER and DLM_IFL_ORPHAN.

---
 fs/dlm/dlm_internal.h      | 13 ++-----
 fs/dlm/lock.c              | 71 +++++++++++++++++++-------------------
 include/trace/events/dlm.h |  1 -
 3 files changed, 37 insertions(+), 48 deletions(-)
fs/dlm/dlm_internal.h +2 -11
index ce0a15858ae3..86b253aa9a09 100644
@@ -213,19 +213,10 @@ struct dlm_args {
 #define DLM_IFLNS_DEADLOCK_CANCEL 9
 
 
-/* lkb_flags
- *
- * least significant 2 bytes are message changed, they are full transmitted
- * but at receive side only the 2 bytes LSB will be set.
- *
- * Even wireshark dlm dissector does only evaluate the lower bytes and note
- * that they may not be used on transceiver side, we assume the higher bytes
- * are for internal use or reserved so long they are not parsed on receiver
- * side.
- */
+/* lkb_flags */
+
 #define DLM_IFL_USER		0x00000001
 #define DLM_IFL_ORPHAN		0x00000002
-#define DLM_IFL_STUB_MS		0x00010000
 
 #define DLM_CB_CAST		0x00000001
 #define DLM_CB_BAST		0x00000002
fs/dlm/lock.c +35 -36

237 lines not on this page · raw message

include/trace/events/dlm.h +0 -1
index a34cd2e62691..612d93e35e04 100644
@@ -47,7 +47,6 @@
 	{ DLM_SBF_ALTMODE,	"ALTMODE" })
 
 #define show_lkb_flags(flags) __print_flags(flags, "|",		\
-	{ DLM_IFL_STUB_MS,	"STUB_MS" },			\
 	{ DLM_IFL_USER,		"USER" },			\
 	{ DLM_IFL_ORPHAN,	"ORPHAN" })
 
Signature · 1 line
2.31.1