Skip to contentSkip to conversation

Sparse Warnings about locks in extent-tree.c

DISCUSSION nick 3 participants 4 messages Sep 23, 2014 Btrfs file system

lore
Share & tools
lore

nick

author
#0 lore raw

Hello Btfs Developers,
I am new so am unsure of how to fix this but we are hitting some sparse warnings about unlock/lock is having a wrong count when exiting certain functions in extent-tree.c. I will paste the warnings below for you guys. Hope this is of help.
Cheers,
Nick
fs/btrfs/extent-tree.c:6386:39: warning: context imbalance in 'btrfs_lock_cluster' - wrong count at exit fs/btrfs/extent-tree.c:6663:44: warning: context imbalance in 'find_free_extent' - unexpected unlock fs/btrfs/extent-tree.c:8810:9: warning: context imbalance in 'btrfs_put_block_group_cache' - wrong count at exit

#1 lore raw
Quoted 9 lines · nick

Hello Btfs Developers,
I am new so am unsure of how to fix this but we are hitting some sparse warnings about unlock/lock is having a wrong count when exiting certain functions in extent-tree.c. I will paste the warnings below for you guys. Hope this is of help.
Cheers,
Nick
fs/btrfs/extent-tree.c:6386:39: warning: context imbalance in 'btrfs_lock_cluster' - wrong count at exit fs/btrfs/extent-tree.c:6663:44: warning: context imbalance in 'find_free_extent' - unexpected unlock fs/btrfs/extent-tree.c:8810:9: warning: context imbalance in 'btrfs_put_block_group_cache' - wrong count at exit

Hi Nick,

What program is producing these warning? It looks like a static code analysis tool or something.

thanks,
-liubo

#2 lore raw
Quoted 11 lines · Liu Bo
Quoted 9 lines · nick

Hello Btfs Developers,
I am new so am unsure of how to fix this but we are hitting some sparse warnings about unlock/lock is having a wrong count when exiting certain functions in extent-tree.c. I will paste the warnings below for you guys. Hope this is of help.
Cheers,
Nick
fs/btrfs/extent-tree.c:6386:39: warning: context imbalance in 'btrfs_lock_cluster' - wrong count at exit fs/btrfs/extent-tree.c:6663:44: warning: context imbalance in 'find_free_extent' - unexpected unlock fs/btrfs/extent-tree.c:8810:9: warning: context imbalance in 'btrfs_put_block_group_cache' - wrong count at exit

Quoted 2 lines

What program is producing these warning? It looks like a static code analysis tool or something.

https://sparse.wiki.kernel.org/index.php/Main_Page

It understands a few semantics like the locking and reports when there's an unannotated function that has imbalanced locking, like the errors above.

Any static analyzer has some ratio of false positives so not every report means there's a bug. One would expect that a function 'btrfs_lock_cluster' would act as a lock and leaves some locks held at exit. The "fix" is to annotate it a after review.

#3 lore raw
Quoted 12 lines · David Sterba
Quoted 11 lines · Liu Bo
Quoted 9 lines · nick

Hello Btfs Developers,
I am new so am unsure of how to fix this but we are hitting some sparse warnings about unlock/lock is having a wrong count when exiting certain functions in extent-tree.c. I will paste the warnings below for you guys. Hope this is of help.
Cheers,
Nick
fs/btrfs/extent-tree.c:6386:39: warning: context imbalance in 'btrfs_lock_cluster' - wrong count at exit fs/btrfs/extent-tree.c:6663:44: warning: context imbalance in 'find_free_extent' - unexpected unlock fs/btrfs/extent-tree.c:8810:9: warning: context imbalance in 'btrfs_put_block_group_cache' - wrong count at exit

Quoted 8 lines
Quoted 2 lines

What program is producing these warning? It looks like a static code analysis tool or something.

https://sparse.wiki.kernel.org/index.php/Main_Page

It understands a few semantics like the locking and reports when there's an unannotated function that has imbalanced locking, like the errors above.

Cool, thanks Dave.

-liubo

Quoted 5 lines

Any static analyzer has some ratio of false positives so not every report means there's a bug. One would expect that a function 'btrfs_lock_cluster' would act as a lock and leaves some locks held at exit. The "fix" is to annotate it a after review.