Sparse reports a warning at dlm_empty_lockres()
warning: context imbalance in dlm_purge_lockres() - unexpected unlock
The root cause is the missing annotation at dlm_purge_lockres()
Add the missing __must_hold(&dlm->spinlock)
Signed-off-by: Jules Irenge <[email protected]>
---
fs/ocfs2/dlm/dlmmaster.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c
index 900f7e466d11..8cbd46b3509a 100644
--- a/fs/ocfs2/dlm/dlmmaster.c
+++ b/fs/ocfs2/dlm/dlmmaster.c
@@ -2762,6 +2762,7 @@ static int dlm_migrate_lockres(struct dlm_ctxt *dlm,
* Returns: 1 if dlm->spinlock was dropped/retaken, 0 if never dropped
*/
int dlm_empty_lockres(struct dlm_ctxt *dlm, struct dlm_lock_resource *res)
+ __must_hold(&dlm->spinlock)
{
int ret;
int lock_dropped = 0;
--
2.24.1
On 2020/4/4 00:05, Jules Irenge wrote:
> Sparse reports a warning at dlm_empty_lockres()
>
> warning: context imbalance in dlm_purge_lockres() - unexpected unlock
>
> The root cause is the missing annotation at dlm_purge_lockres()
>
> Add the missing __must_hold(&dlm->spinlock)
>
Seems this is duplicate with assert_spin_locked()?
Thanks,
Joseph
> Signed-off-by: Jules Irenge <[email protected]>
> ---
> fs/ocfs2/dlm/dlmmaster.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c
> index 900f7e466d11..8cbd46b3509a 100644
> --- a/fs/ocfs2/dlm/dlmmaster.c
> +++ b/fs/ocfs2/dlm/dlmmaster.c
> @@ -2762,6 +2762,7 @@ static int dlm_migrate_lockres(struct dlm_ctxt *dlm,
> * Returns: 1 if dlm->spinlock was dropped/retaken, 0 if never dropped
> */
> int dlm_empty_lockres(struct dlm_ctxt *dlm, struct dlm_lock_resource *res)
> + __must_hold(&dlm->spinlock)
> {
> int ret;
> int lock_dropped = 0;
>
On Sat, 4 Apr 2020 07:45:49 +0800 Joseph Qi <[email protected]> wrote:
> On 2020/4/4 00:05, Jules Irenge wrote:
> > Sparse reports a warning at dlm_empty_lockres()
> >
> > warning: context imbalance in dlm_purge_lockres() - unexpected unlock
> >
> > The root cause is the missing annotation at dlm_purge_lockres()
> >
> > Add the missing __must_hold(&dlm->spinlock)
> >
> Seems this is duplicate with assert_spin_locked()?
I doubt is sparse is smart enough to treat assert_spin_locked() as
equivalent to __must_hold(). It would be neat though.