lock warning cleanups
cover lock warning cleanups
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(-)
Signature · 1 line
2.24.1
PATCH 1/6 namei: Add missing annotation for unlazy_walk()
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
--- fs/namei.c | 1 + 1 file changed, 1 insertion(+)
fs/namei.c +1 -0
@@ -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;
Signature · 1 line
2.24.1
PATCH 2/6 namei: Add missing annotation for unlazy_child()
In reply to Jules IrengeSparse 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
--- fs/namei.c | 1 + 1 file changed, 1 insertion(+)
fs/namei.c +1 -0
@@ -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 ));
Signature · 1 line
2.24.1
PATCH 3/6 fs: Add missing annotation for __wait_on_freeing_inode()
In reply to Jules IrengeSparse 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
--- fs/inode.c | 2 ++ 1 file changed, 2 insertions(+)
fs/inode.c +2 -0
@@ -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);
Signature · 1 line
2.24.1
PATCH 4/6 fs/fs-writeback.c: Add missing annotation for wbc_attach_and_unlock_inode()
In reply to Jules IrengeSparse 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
--- fs/fs-writeback.c | 1 + 1 file changed, 1 insertion(+)
fs/fs-writeback.c +1 -0
@@ -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);
Signature · 1 line
2.24.1
PATCH 5/6 fs/fs-writeback.c: replace two annotations for __inode_wait_for_writeback()
In reply to Jules IrengeTo 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)
--- fs/fs-writeback.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/fs-writeback.c +1 -2
@@ -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;
Signature · 1 line
2.24.1
PATCH 6/6 fs: add missing annotation for pin_kill()
In reply to Jules IrengeSparse 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)
--- fs/fs_pin.c | 1 + 1 file changed, 1 insertion(+)
fs/fs_pin.c +1 -0
@@ -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;
Signature · 1 line
2.24.1