This patch series adds missing annotations to various functions,
that register warnings of context imbalance when built with Sparse tool.
The adds fix the warnings, improve on readability of the code
and give better insight or directive on what the functions are actually doing.
Jules Irenge (6):
namei: Add missing annotation for unlazy_walk()
namei: Add missing annotation for unlazy_child()
fs: Add missing annotation for __wait_on_freeing_inode()
fs/fs-writeback.c: Add missing annotation for
wbc_attach_and_unlock_inode()
fs/fs-writeback.c: replace two annotations for
__inode_wait_for_writeback()
fs: add missing annotation for pin_kill()
fs/fs-writeback.c | 4 ++--
fs/fs_pin.c | 1 +
fs/inode.c | 2 ++
fs/namei.c | 2 ++
4 files changed, 7 insertions(+), 2 deletions(-)
--
2.24.1
Sparse reports a warning at wbc_attach_and_unlock_inode()
warning: context imbalance in wbc_attach_and_unlock_inode() - unexpected unlock
The root cause is the missing annotation at wbc_attach_and_unlock_inode()
Add the missing __releases(&inode->i_lock) annotation
Signed-off-by: Jules Irenge <[email protected]>
---
fs/fs-writeback.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 76ac9c7d32ec..008e572faf32 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -556,6 +556,7 @@ static void inode_switch_wbs(struct inode *inode, int new_wb_id)
*/
void wbc_attach_and_unlock_inode(struct writeback_control *wbc,
struct inode *inode)
+ __releases(&inode->i_lock)
{
if (!inode_cgwb_enabled(inode)) {
spin_unlock(&inode->i_lock);
--
2.24.1
Sparse reports a warning at __wait_on_freeing_inode()
warning: context imbalance in __wait_on_freeing_inode() - unexpected unlock
The root cause is the missing annotations at __wait_on_freeing_inode()
Add the missing __releases(&inode->i_lock)
and __must_hold(&inode_hash_lock) annotations
Signed-off-by: Jules Irenge <[email protected]>
---
fs/inode.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/inode.c b/fs/inode.c
index 7d57068b6b7a..3b06c5c59883 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -1955,6 +1955,8 @@ EXPORT_SYMBOL(inode_needs_sync);
* will DTRT.
*/
static void __wait_on_freeing_inode(struct inode *inode)
+ __releases(&inode->i_lock)
+ __must_hold(&inode_hash_lock)
{
wait_queue_head_t *wq;
DEFINE_WAIT_BIT(wait, &inode->i_state, __I_NEW);
--
2.24.1
Sparse reports a warning at pin_kill()
warning: context imbalance in pin_kill() - unexpected unlock
The root cause is the missing annotation at pin_kill()
Add the missing __releases(RCU)
Signed-off-by: Jules Irenge <[email protected]>
---
fs/fs_pin.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/fs_pin.c b/fs/fs_pin.c
index 47ef3c71ce90..ee57700740df 100644
--- a/fs/fs_pin.c
+++ b/fs/fs_pin.c
@@ -28,6 +28,7 @@ void pin_insert(struct fs_pin *pin, struct vfsmount *m)
}
void pin_kill(struct fs_pin *p)
+ __releases(RCU)
{
wait_queue_entry_t wait;
--
2.24.1
To improve readability of the code,
__releases(inode->i_lock) and __acquires(inode->i_lock) annotations here
are replaced by one annotation __must_hold(inode->i_lock)
Signed-off-by: Jules Irenge <[email protected]>
---
fs/fs-writeback.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 008e572faf32..d0c0dc10526d 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -1322,8 +1322,7 @@ static int write_inode(struct inode *inode, struct writeback_control *wbc)
* Caller must make sure inode cannot go away when we drop i_lock.
*/
static void __inode_wait_for_writeback(struct inode *inode)
- __releases(inode->i_lock)
- __acquires(inode->i_lock)
+ __must_hold(inode->i_lock)
{
DEFINE_WAIT_BIT(wq, &inode->i_state, __I_SYNC);
wait_queue_head_t *wqh;
--
2.24.1
Sparse reports a warning at unlazy_walk()
warning: context imbalance in unlazy_walk() - unexpected unlock
The root cause is the missing annotation at unlazy_walk()
Add the missing __releases(RCU) annotation
Signed-off-by: Jules Irenge <[email protected]>
---
fs/namei.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/namei.c b/fs/namei.c
index db6565c99825..d80e1ac8c211 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -678,6 +678,7 @@ static bool legitimize_root(struct nameidata *nd)
* terminate_walk().
*/
static int unlazy_walk(struct nameidata *nd)
+ __releases(RCU)
{
struct dentry *parent = nd->path.dentry;
--
2.24.1
Sparse reports a warning at unlazy_child()
warning: context imbalance in unlazy_child() - unexpected unlock
The root cause is the missing annotation at unlazy_walk()
Add the missing __releases(RCU) annotation
Signed-off-by: Jules Irenge <[email protected]>
---
fs/namei.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/namei.c b/fs/namei.c
index d80e1ac8c211..9af3e8e438a1 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -717,6 +717,7 @@ static int unlazy_walk(struct nameidata *nd)
* terminate_walk().
*/
static int unlazy_child(struct nameidata *nd, struct dentry *dentry, unsigned seq)
+ __releases(RCU)
{
BUG_ON(!(nd->flags & LOOKUP_RCU));
--
2.24.1