From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexander Aring Date: Thu, 23 Jun 2022 21:29:00 -0400 Subject: [Cluster-devel] [PATCH dlm/next 3/3] fs: dlm: fix context imbalance warning in put_rsb() In-Reply-To: <20220624012900.2355825-1-aahringo@redhat.com> References: <20220624012900.2355825-1-aahringo@redhat.com> Message-ID: <20220624012900.2355825-3-aahringo@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 --- 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