cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Alexander Aring <aahringo@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH RESEND v5.18-rc1 10/19] fs: dlm: add __CHECKER__ for false positives
Date: Mon,  4 Apr 2022 16:06:37 -0400	[thread overview]
Message-ID: <20220404200646.3170301-11-aahringo@redhat.com> (raw)
In-Reply-To: <20220404200646.3170301-1-aahringo@redhat.com>

This patch will adds #ifndef __CHECKER__ for false positives warnings
about an imbalance lock/unlock srcu handling. Which are shown by running
sparse checks:

fs/dlm/midcomms.c:1065:20: warning: context imbalance in 'dlm_midcomms_get_mhandle' - wrong count at exit

Using __CHECKER__ will tell sparse to ignore these sections.

Those imbalances are false positive because from upper layer it is
always required to call a function in sequence, e.g. if
dlm_midcomms_get_mhandle() is successful there must be a
dlm_midcomms_commit_mhandle() call afterwards.

Signed-off-by: Alexander Aring <aahringo@redhat.com>
---
 fs/dlm/lowcomms.c | 10 ++++++++++
 fs/dlm/midcomms.c | 10 ++++++++++
 2 files changed, 20 insertions(+)

diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c
index 6ed935ad8247..19e82f08c0e0 100644
--- a/fs/dlm/lowcomms.c
+++ b/fs/dlm/lowcomms.c
@@ -1303,6 +1303,10 @@ static struct dlm_msg *dlm_lowcomms_new_msg_con(struct connection *con, int len,
 	return msg;
 }
 
+/* avoid false positive for nodes_srcu, unlock happens in
+ * dlm_lowcomms_commit_msg which is a must call if success
+ */
+#ifndef __CHECKER__
 struct dlm_msg *dlm_lowcomms_new_msg(int nodeid, int len, gfp_t allocation,
 				     char **ppc, void (*cb)(void *data),
 				     void *data)
@@ -1336,6 +1340,7 @@ struct dlm_msg *dlm_lowcomms_new_msg(int nodeid, int len, gfp_t allocation,
 	msg->idx = idx;
 	return msg;
 }
+#endif
 
 static void _dlm_lowcomms_commit_msg(struct dlm_msg *msg)
 {
@@ -1362,11 +1367,16 @@ static void _dlm_lowcomms_commit_msg(struct dlm_msg *msg)
 	return;
 }
 
+/* avoid false positive for nodes_srcu, lock was happen in
+ * dlm_lowcomms_new_msg
+ */
+#ifndef __CHECKER__
 void dlm_lowcomms_commit_msg(struct dlm_msg *msg)
 {
 	_dlm_lowcomms_commit_msg(msg);
 	srcu_read_unlock(&connections_srcu, msg->idx);
 }
+#endif
 
 void dlm_lowcomms_put_msg(struct dlm_msg *msg)
 {
diff --git a/fs/dlm/midcomms.c b/fs/dlm/midcomms.c
index 3635e42b0669..f95f6f40c404 100644
--- a/fs/dlm/midcomms.c
+++ b/fs/dlm/midcomms.c
@@ -1062,6 +1062,10 @@ static struct dlm_msg *dlm_midcomms_get_msg_3_2(struct dlm_mhandle *mh, int node
 	return msg;
 }
 
+/* avoid false positive for nodes_srcu, unlock happens in
+ * dlm_midcomms_commit_mhandle which is a must call if success
+ */
+#ifndef __CHECKER__
 struct dlm_mhandle *dlm_midcomms_get_mhandle(int nodeid, int len,
 					     gfp_t allocation, char **ppc)
 {
@@ -1127,6 +1131,7 @@ struct dlm_mhandle *dlm_midcomms_get_mhandle(int nodeid, int len,
 	srcu_read_unlock(&nodes_srcu, idx);
 	return NULL;
 }
+#endif
 
 static void dlm_midcomms_commit_msg_3_2(struct dlm_mhandle *mh)
 {
@@ -1136,6 +1141,10 @@ static void dlm_midcomms_commit_msg_3_2(struct dlm_mhandle *mh)
 	dlm_lowcomms_commit_msg(mh->msg);
 }
 
+/* avoid false positive for nodes_srcu, lock was happen in
+ * dlm_midcomms_get_mhandle
+ */
+#ifndef __CHECKER__
 void dlm_midcomms_commit_mhandle(struct dlm_mhandle *mh)
 {
 	switch (mh->node->version) {
@@ -1157,6 +1166,7 @@ void dlm_midcomms_commit_mhandle(struct dlm_mhandle *mh)
 		break;
 	}
 }
+#endif
 
 int dlm_midcomms_start(void)
 {
-- 
2.31.1


  parent reply	other threads:[~2022-04-04 20:06 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-04 20:06 [Cluster-devel] [PATCH RESEND v5.18-rc1 00/19] fs: dlm: resend patches for v5.18-rc1 Alexander Aring
2022-04-04 20:06 ` [Cluster-devel] [PATCH RESEND v5.18-rc1 01/19] fs: dlm: uninitialized variable on error in dlm_listen_for_all() Alexander Aring
2022-04-04 20:06 ` [Cluster-devel] [PATCH RESEND v5.18-rc1 02/19] fs: dlm: fix missing check in validate_lock_args Alexander Aring
2022-04-04 20:06 ` [Cluster-devel] [PATCH RESEND v5.18-rc1 03/19] fs: dlm: fix plock invalid read Alexander Aring
2022-04-04 20:06 ` [Cluster-devel] [PATCH RESEND v5.18-rc1 04/19] fs: dlm: replace sanity checks with WARN_ON Alexander Aring
2022-04-04 20:06 ` [Cluster-devel] [PATCH RESEND v5.18-rc1 05/19] fs: dlm: cleanup plock_op vs plock_xop Alexander Aring
2022-04-04 20:06 ` [Cluster-devel] [PATCH RESEND v5.18-rc1 06/19] fs: dlm: rearrange async condition return Alexander Aring
2022-04-04 20:06 ` [Cluster-devel] [PATCH RESEND v5.18-rc1 07/19] fs: dlm: improve plock logging if interrupted Alexander Aring
2022-04-04 20:06 ` [Cluster-devel] [PATCH RESEND v5.18-rc1 08/19] fs: dlm: remove unnecessary INIT_LIST_HEAD() Alexander Aring
2022-04-04 20:06 ` [Cluster-devel] [PATCH RESEND v5.18-rc1 09/19] fs: dlm: move global to static inits Alexander Aring
2022-04-04 20:06 ` Alexander Aring [this message]
2022-04-04 20:06 ` [Cluster-devel] [PATCH RESEND v5.18-rc1 11/19] fs: dlm: use __le types for options header Alexander Aring
2022-04-04 20:06 ` [Cluster-devel] [PATCH RESEND v5.18-rc1 12/19] fs: dlm: use __le types for dlm header Alexander Aring
2022-04-04 20:06 ` [Cluster-devel] [PATCH RESEND v5.18-rc1 13/19] fs: dlm: use __le types for rcom messages Alexander Aring
2022-04-04 20:06 ` [Cluster-devel] [PATCH RESEND v5.18-rc1 14/19] fs: dlm: use __le types for dlm messages Alexander Aring
2022-04-04 20:06 ` [Cluster-devel] [PATCH RESEND v5.18-rc1 15/19] fs: dlm: move conversion to compile time Alexander Aring
2022-04-04 20:06 ` [Cluster-devel] [PATCH RESEND v5.18-rc1 16/19] fs: dlm: remove __user conversion warnings Alexander Aring
2022-04-04 20:06 ` [Cluster-devel] [PATCH RESEND v5.18-rc1 17/19] fs: dlm: remove found label in dlm_master_lookup Alexander Aring
2022-04-04 20:06 ` [Cluster-devel] [PATCH RESEND v5.18-rc1 18/19] fs: dlm: cleanup lock handling " Alexander Aring
2022-04-04 20:06 ` [Cluster-devel] [PATCH RESEND v5.18-rc1 19/19] fs: dlm: check required context while close 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=20220404200646.3170301-11-aahringo@redhat.com \
    --to=aahringo@redhat.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;
as well as URLs for NNTP newsgroup(s).