public inbox for gfs2@lists.linux.dev
 help / color / mirror / Atom feed
From: Alexander Aring <aahringo@redhat.com>
To: teigland@redhat.com
Cc: gfs2@lists.linux.dev, song@kernel.org, yukuai3@huawei.com,
	agruenba@redhat.com, mark@fasheh.com, jlbec@evilplan.org,
	joseph.qi@linux.alibaba.com, gregkh@linuxfoundation.org,
	rafael@kernel.org, akpm@linux-foundation.org,
	linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org,
	ocfs2-devel@lists.linux.dev, netdev@vger.kernel.org,
	vvidic@valentin-vidic.from.hr, heming.zhao@suse.com,
	lucien.xin@gmail.com, paulmck@kernel.org, rcu@vger.kernel.org,
	juri.lelli@redhat.com, williams@redhat.com, aahringo@redhat.com
Subject: [RFC 5/7] dlm: add lkb rv mode to ast tracepoint
Date: Tue, 27 Aug 2024 14:02:34 -0400	[thread overview]
Message-ID: <20240827180236.316946-6-aahringo@redhat.com> (raw)
In-Reply-To: <20240827180236.316946-1-aahringo@redhat.com>

This patch adds the lkb_rv_mode to the ast tracepoint. The lkb_rv_mode
is the requested mode by dlm_lock() requests. We cannot use lkb_mode as
dlm internally sometimes changes this value and for cases like the dlm
kernel verifier we want to check on DLM correctness from what the user
is seeing. This new tracepoint events tells us what the requested mode
was.

Signed-off-by: Alexander Aring <aahringo@redhat.com>
---
 fs/dlm/ast.c               |  9 +++++----
 fs/dlm/dlm_internal.h      |  2 ++
 fs/dlm/lock.c              |  1 +
 fs/dlm/user.c              |  2 +-
 include/trace/events/dlm.h | 11 +++++++----
 5 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/fs/dlm/ast.c b/fs/dlm/ast.c
index 01de0d4b9450..fc2ca37011d8 100644
--- a/fs/dlm/ast.c
+++ b/fs/dlm/ast.c
@@ -24,7 +24,7 @@ static void dlm_run_callback(int our_nodeid, uint32_t ls_id, uint32_t lkb_id,
 			     void (*astfn)(void *astparam),
 			     void (*bastfn)(void *astparam, int mode),
 			     void *astparam, const char *res_name,
-			     size_t res_length)
+			     size_t res_length, int rv_mode)
 {
 	if (flags & DLM_CB_BAST) {
 		trace_dlm_bast(our_nodeid, ls_id, lkb_id, mode, res_name,
@@ -32,7 +32,7 @@ static void dlm_run_callback(int our_nodeid, uint32_t ls_id, uint32_t lkb_id,
 		bastfn(astparam, mode);
 	} else if (flags & DLM_CB_CAST) {
 		trace_dlm_ast(our_nodeid, ls_id, lkb_id, sb_flags, sb_status,
-			      res_name, res_length);
+			      res_name, res_length, rv_mode);
 		lksb->sb_status = sb_status;
 		lksb->sb_flags = sb_flags;
 		astfn(astparam);
@@ -44,7 +44,7 @@ static void dlm_do_callback(struct dlm_callback *cb)
 	dlm_run_callback(cb->our_nodeid, cb->ls_id, cb->lkb_id, cb->mode,
 			 cb->flags, cb->sb_flags, cb->sb_status, cb->lkb_lksb,
 			 cb->astfn, cb->bastfn, cb->astparam,
-			 cb->res_name, cb->res_length);
+			 cb->res_name, cb->res_length, cb->rv_mode);
 	dlm_free_cb(cb);
 }
 
@@ -134,6 +134,7 @@ int dlm_get_cb(struct dlm_lkb *lkb, uint32_t flags, int mode,
 	(*cb)->our_nodeid = ls->ls_dn->our_node->id;
 	(*cb)->lkb_id = lkb->lkb_id;
 	(*cb)->ls_id = ls->ls_global_id;
+	(*cb)->rv_mode = lkb->lkb_rv_mode;
 	memcpy((*cb)->res_name, rsb->res_name, rsb->res_length);
 	(*cb)->res_length = rsb->res_length;
 
@@ -192,7 +193,7 @@ void dlm_add_cb(struct dlm_lkb *lkb, uint32_t flags, int mode, int status,
 					 flags, sbflags, status, lkb->lkb_lksb,
 					 lkb->lkb_astfn, lkb->lkb_bastfn,
 					 lkb->lkb_astparam, rsb->res_name,
-					 rsb->res_length);
+					 rsb->res_length, lkb->lkb_rv_mode);
 		} else {
 			rv = dlm_get_queue_cb(lkb, flags, mode, status, sbflags, &cb);
 			if (!rv)
diff --git a/fs/dlm/dlm_internal.h b/fs/dlm/dlm_internal.h
index bc3ff1b64e0c..3f630696f7ab 100644
--- a/fs/dlm/dlm_internal.h
+++ b/fs/dlm/dlm_internal.h
@@ -247,6 +247,7 @@ struct dlm_callback {
 	size_t			res_length;
 	uint32_t		ls_id;
 	uint32_t		lkb_id;
+	int			rv_mode;
 
 	struct list_head	list;
 };
@@ -296,6 +297,7 @@ struct dlm_lkb {
 		void			*lkb_astparam;	/* caller's ast arg */
 		struct dlm_user_args	*lkb_ua;
 	};
+	int			lkb_rv_mode;
 	struct rcu_head		rcu;
 };
 
diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c
index 8cb5a537bfd3..21bb9603a0df 100644
--- a/fs/dlm/lock.c
+++ b/fs/dlm/lock.c
@@ -2844,6 +2844,7 @@ static int validate_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb,
 	lkb->lkb_lksb = args->lksb;
 	lkb->lkb_lvbptr = args->lksb->sb_lvbptr;
 	lkb->lkb_ownpid = (int) current->pid;
+	lkb->lkb_rv_mode = args->mode;
 	rv = 0;
  out:
 	switch (rv) {
diff --git a/fs/dlm/user.c b/fs/dlm/user.c
index c4d6e67ff63e..75fb85676e90 100644
--- a/fs/dlm/user.c
+++ b/fs/dlm/user.c
@@ -875,7 +875,7 @@ static ssize_t device_read(struct file *file, char __user *buf, size_t count,
 		cb->lkb_lksb->sb_flags = cb->sb_flags;
 		trace_dlm_ast(cb->our_nodeid, cb->ls_id, cb->lkb_id,
 			      cb->sb_status, cb->sb_flags, cb->res_name,
-			      cb->res_length);
+			      cb->res_length, cb->rv_mode);
 	}
 
 	ret = copy_result_to_user(&cb->ua,
diff --git a/include/trace/events/dlm.h b/include/trace/events/dlm.h
index 2621bb7ac3a8..f8d7ca451760 100644
--- a/include/trace/events/dlm.h
+++ b/include/trace/events/dlm.h
@@ -228,10 +228,10 @@ TRACE_EVENT(dlm_ast,
 
 	TP_PROTO(unsigned int our_nodeid, __u32 ls_id, __u32 lkb_id,
 		 __u8 sb_flags, int sb_status, const char *res_name,
-		 size_t res_length),
+		 size_t res_length, int rv_mode),
 
 	TP_ARGS(our_nodeid, ls_id, lkb_id, sb_flags, sb_status, res_name,
-		res_length),
+		res_length, rv_mode),
 
 	TP_STRUCT__entry(
 		__field(unsigned int, our_nodeid)
@@ -239,6 +239,7 @@ TRACE_EVENT(dlm_ast,
 		__field(__u32, lkb_id)
 		__field(__u8, sb_flags)
 		__field(int, sb_status)
+		__field(int, rv_mode)
 		__dynamic_array(unsigned char, res_name, res_length)
 	),
 
@@ -248,16 +249,18 @@ TRACE_EVENT(dlm_ast,
 		__entry->lkb_id = lkb_id;
 		__entry->sb_flags = sb_flags;
 		__entry->sb_status = sb_status;
+		__entry->rv_mode = rv_mode;
 
 		memcpy(__get_dynamic_array(res_name), res_name,
 		       __get_dynamic_array_len(res_name));
 	),
 
-	TP_printk("our_nodeid=%u ls_id=%u lkb_id=%x sb_flags=%s sb_status=%d res_name=%s",
+	TP_printk("our_nodeid=%u ls_id=%u lkb_id=%x sb_flags=%s sb_status=%d res_name=%s rv_mode=%d",
 		  __entry->our_nodeid, __entry->ls_id, __entry->lkb_id,
 		  show_dlm_sb_flags(__entry->sb_flags), __entry->sb_status,
 		  __print_hex_str(__get_dynamic_array(res_name),
-				  __get_dynamic_array_len(res_name)))
+				  __get_dynamic_array_len(res_name)),
+		  __entry->rv_mode)
 
 );
 
-- 
2.43.0


  parent reply	other threads:[~2024-08-27 18:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-27 18:02 [RFC 0/7] dlm: the ultimate verifier for DLM lock correctness Alexander Aring
2024-08-27 18:02 ` [RFC 1/7] dlm: fix possible lkb_resource null dereference Alexander Aring
2024-08-27 18:02 ` [RFC 2/7] dlm: fix swapped args sb_flags vs sb_status Alexander Aring
2024-08-27 18:02 ` [RFC 3/7] dlm: make add_to_waiters() that is can't fail Alexander Aring
2024-08-27 18:02 ` [RFC 4/7] dlm: add our_nodeid to tracepoints Alexander Aring
2024-08-27 18:02 ` Alexander Aring [this message]
2024-08-27 18:02 ` [RFC 6/7] dlm: add more tracepoints for DLM kernel verifier Alexander Aring
2024-08-27 18:02 ` [RFC 7/7] rv: add dlm compatible lock state " Alexander Aring
2024-08-30 12:55   ` Alexander Aring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240827180236.316946-6-aahringo@redhat.com \
    --to=aahringo@redhat.com \
    --cc=agruenba@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=gfs2@lists.linux.dev \
    --cc=gregkh@linuxfoundation.org \
    --cc=heming.zhao@suse.com \
    --cc=jlbec@evilplan.org \
    --cc=joseph.qi@linux.alibaba.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=lucien.xin@gmail.com \
    --cc=mark@fasheh.com \
    --cc=netdev@vger.kernel.org \
    --cc=ocfs2-devel@lists.linux.dev \
    --cc=paulmck@kernel.org \
    --cc=rafael@kernel.org \
    --cc=rcu@vger.kernel.org \
    --cc=song@kernel.org \
    --cc=teigland@redhat.com \
    --cc=vvidic@valentin-vidic.from.hr \
    --cc=williams@redhat.com \
    --cc=yukuai3@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox