linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] lock warning cleanups
       [not found] <0/6>
@ 2020-03-16 23:37 ` Jules Irenge
  2020-03-16 23:37   ` [PATCH 1/6] namei: Add missing annotation for unlazy_walk() Jules Irenge
                     ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Jules Irenge @ 2020-03-16 23:37 UTC (permalink / raw)
  To: boqun.feng; +Cc: linux-fsdevel, linux-kernel

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/6] namei: Add missing annotation for unlazy_walk()
  2020-03-16 23:37 ` [PATCH 0/6] lock warning cleanups Jules Irenge
@ 2020-03-16 23:37   ` Jules Irenge
  2020-03-16 23:38   ` [PATCH 2/6] namei: Add missing annotation for unlazy_child() Jules Irenge
                     ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Jules Irenge @ 2020-03-16 23:37 UTC (permalink / raw)
  To: boqun.feng; +Cc: linux-fsdevel, linux-kernel, Alexander Viro

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 <jbi.octave@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/6] namei: Add missing annotation for unlazy_child()
  2020-03-16 23:37 ` [PATCH 0/6] lock warning cleanups Jules Irenge
  2020-03-16 23:37   ` [PATCH 1/6] namei: Add missing annotation for unlazy_walk() Jules Irenge
@ 2020-03-16 23:38   ` Jules Irenge
  2020-03-16 23:38   ` [PATCH 3/6] fs: Add missing annotation for __wait_on_freeing_inode() Jules Irenge
                     ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Jules Irenge @ 2020-03-16 23:38 UTC (permalink / raw)
  To: boqun.feng; +Cc: linux-fsdevel, linux-kernel, Alexander Viro

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 <jbi.octave@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/6] fs: Add missing annotation for __wait_on_freeing_inode()
  2020-03-16 23:37 ` [PATCH 0/6] lock warning cleanups Jules Irenge
  2020-03-16 23:37   ` [PATCH 1/6] namei: Add missing annotation for unlazy_walk() Jules Irenge
  2020-03-16 23:38   ` [PATCH 2/6] namei: Add missing annotation for unlazy_child() Jules Irenge
@ 2020-03-16 23:38   ` Jules Irenge
  2020-03-16 23:38   ` [PATCH 4/6] fs/fs-writeback.c: Add missing annotation for wbc_attach_and_unlock_inode() Jules Irenge
                     ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Jules Irenge @ 2020-03-16 23:38 UTC (permalink / raw)
  To: boqun.feng; +Cc: linux-fsdevel, linux-kernel, Alexander Viro

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 <jbi.octave@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/6] fs/fs-writeback.c: Add missing annotation for wbc_attach_and_unlock_inode()
  2020-03-16 23:37 ` [PATCH 0/6] lock warning cleanups Jules Irenge
                     ` (2 preceding siblings ...)
  2020-03-16 23:38   ` [PATCH 3/6] fs: Add missing annotation for __wait_on_freeing_inode() Jules Irenge
@ 2020-03-16 23:38   ` Jules Irenge
  2020-03-16 23:38   ` [PATCH 5/6] fs/fs-writeback.c: replace two annotations for __inode_wait_for_writeback() Jules Irenge
  2020-03-16 23:38   ` [PATCH 6/6] fs: add missing annotation for pin_kill() Jules Irenge
  5 siblings, 0 replies; 7+ messages in thread
From: Jules Irenge @ 2020-03-16 23:38 UTC (permalink / raw)
  To: boqun.feng; +Cc: linux-fsdevel, linux-kernel, Alexander Viro

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 <jbi.octave@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 5/6] fs/fs-writeback.c: replace two annotations for __inode_wait_for_writeback()
  2020-03-16 23:37 ` [PATCH 0/6] lock warning cleanups Jules Irenge
                     ` (3 preceding siblings ...)
  2020-03-16 23:38   ` [PATCH 4/6] fs/fs-writeback.c: Add missing annotation for wbc_attach_and_unlock_inode() Jules Irenge
@ 2020-03-16 23:38   ` Jules Irenge
  2020-03-16 23:38   ` [PATCH 6/6] fs: add missing annotation for pin_kill() Jules Irenge
  5 siblings, 0 replies; 7+ messages in thread
From: Jules Irenge @ 2020-03-16 23:38 UTC (permalink / raw)
  To: boqun.feng; +Cc: linux-fsdevel, linux-kernel, Alexander Viro

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 <jbi.octave@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 6/6] fs: add missing annotation for pin_kill()
  2020-03-16 23:37 ` [PATCH 0/6] lock warning cleanups Jules Irenge
                     ` (4 preceding siblings ...)
  2020-03-16 23:38   ` [PATCH 5/6] fs/fs-writeback.c: replace two annotations for __inode_wait_for_writeback() Jules Irenge
@ 2020-03-16 23:38   ` Jules Irenge
  5 siblings, 0 replies; 7+ messages in thread
From: Jules Irenge @ 2020-03-16 23:38 UTC (permalink / raw)
  To: boqun.feng; +Cc: linux-fsdevel, linux-kernel, Alexander Viro

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 <jbi.octave@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-03-16 23:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <0/6>
2020-03-16 23:37 ` [PATCH 0/6] lock warning cleanups Jules Irenge
2020-03-16 23:37   ` [PATCH 1/6] namei: Add missing annotation for unlazy_walk() Jules Irenge
2020-03-16 23:38   ` [PATCH 2/6] namei: Add missing annotation for unlazy_child() Jules Irenge
2020-03-16 23:38   ` [PATCH 3/6] fs: Add missing annotation for __wait_on_freeing_inode() Jules Irenge
2020-03-16 23:38   ` [PATCH 4/6] fs/fs-writeback.c: Add missing annotation for wbc_attach_and_unlock_inode() Jules Irenge
2020-03-16 23:38   ` [PATCH 5/6] fs/fs-writeback.c: replace two annotations for __inode_wait_for_writeback() Jules Irenge
2020-03-16 23:38   ` [PATCH 6/6] fs: add missing annotation for pin_kill() Jules Irenge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).