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 dlm/next 3/3] fs: dlm: fix context imbalance warning in put_rsb()
Date: Thu, 23 Jun 2022 21:29:00 -0400	[thread overview]
Message-ID: <20220624012900.2355825-3-aahringo@redhat.com> (raw)
In-Reply-To: <20220624012900.2355825-1-aahringo@redhat.com>

This patch fixes the following sparse warning:

warning: context imbalance in 'put_rsb' - unexpected unlock

it does this by unlock the ls_rsbtbl[bucket].lock lock inside of the
release functionality of kref_put_lock() and do a __releases() annotation
at the release function.

Signed-off-by: Alexander Aring <aahringo@redhat.com>
---
 fs/dlm/lock.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c
index 4b5cff76d376..70ee15c44bd2 100644
--- a/fs/dlm/lock.c
+++ b/fs/dlm/lock.c
@@ -352,12 +352,9 @@ static void put_rsb(struct dlm_rsb *r)
 {
 	struct dlm_ls *ls = r->res_ls;
 	uint32_t bucket = r->res_bucket;
-	int rv;
 
-	rv = kref_put_lock(&r->res_ref, toss_rsb,
-			   &ls->ls_rsbtbl[bucket].lock);
-	if (rv)
-		spin_unlock(&ls->ls_rsbtbl[bucket].lock);
+	kref_put_lock(&r->res_ref, toss_rsb,
+		      &ls->ls_rsbtbl[bucket].lock);
 }
 
 void dlm_put_rsb(struct dlm_rsb *r)
@@ -1140,20 +1137,24 @@ void dlm_dump_rsb_name(struct dlm_ls *ls, char *name, int len)
 }
 
 static void toss_rsb(struct kref *kref)
+	__releases(&ls->ls_rsbtbl[bucket].lock)
 {
 	struct dlm_rsb *r = container_of(kref, struct dlm_rsb, res_ref);
+	uint32_t bucket = r->res_bucket;
 	struct dlm_ls *ls = r->res_ls;
 
 	DLM_ASSERT(list_empty(&r->res_root_list), dlm_print_rsb(r););
 	kref_init(&r->res_ref);
-	rb_erase(&r->res_hashnode, &ls->ls_rsbtbl[r->res_bucket].keep);
-	rsb_insert(r, &ls->ls_rsbtbl[r->res_bucket].toss);
+	rb_erase(&r->res_hashnode, &ls->ls_rsbtbl[bucket].keep);
+	rsb_insert(r, &ls->ls_rsbtbl[bucket].toss);
 	r->res_toss_time = jiffies;
-	ls->ls_rsbtbl[r->res_bucket].flags |= DLM_RTF_SHRINK;
+	ls->ls_rsbtbl[bucket].flags |= DLM_RTF_SHRINK;
 	if (r->res_lvbptr) {
 		dlm_free_lvb(r->res_lvbptr);
 		r->res_lvbptr = NULL;
 	}
+
+	spin_unlock(&ls->ls_rsbtbl[bucket].lock);
 }
 
 /* See comment for unhold_lkb */
-- 
2.31.1


      parent reply	other threads:[~2022-06-24  1:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-24  1:28 [Cluster-devel] [PATCH dlm/next 1/3] fs: dlm: move assert into release function Alexander Aring
2022-06-24  1:28 ` [Cluster-devel] [PATCH dlm/next 2/3] fs: dlm: fix context imbalance warning in __put_lkb() Alexander Aring
2022-06-24  1:29 ` Alexander Aring [this message]

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=20220624012900.2355825-3-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).