linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1 linux-next] jbd2: Fix sparse context imbalance warning
@ 2014-09-18 18:29 Fabian Frederick
  2014-09-18 20:44 ` Theodore Ts'o
  0 siblings, 1 reply; 3+ messages in thread
From: Fabian Frederick @ 2014-09-18 18:29 UTC (permalink / raw)
  To: linux-kernel; +Cc: Fabian Frederick, Theodore Ts'o, linux-ext4

spin_unlock after spin_lock only.

This fixes the following sparse warning:
fs/jbd2/transaction.c:1102:20: warning: context imbalance
in 'jbd2_journal_get_create_access' - different lock contexts for basic block

Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
 fs/jbd2/transaction.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index 5f09370..edb7f59 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -1091,6 +1091,7 @@ int jbd2_journal_get_create_access(handle_t *handle, struct buffer_head *bh)
 		JBUFFER_TRACE(jh, "file as BJ_Reserved");
 		spin_lock(&journal->j_list_lock);
 		__jbd2_journal_file_buffer(jh, transaction, BJ_Reserved);
+		spin_unlock(&journal->j_list_lock);
 	} else if (jh->b_transaction == journal->j_committing_transaction) {
 		/* first access by this transaction */
 		jh->b_modified = 0;
@@ -1098,8 +1099,8 @@ int jbd2_journal_get_create_access(handle_t *handle, struct buffer_head *bh)
 		JBUFFER_TRACE(jh, "set next transaction");
 		spin_lock(&journal->j_list_lock);
 		jh->b_next_transaction = transaction;
+		spin_unlock(&journal->j_list_lock);
 	}
-	spin_unlock(&journal->j_list_lock);
 	jbd_unlock_bh_state(bh);
 
 	/*
-- 
1.9.1

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

* Re: [PATCH 1/1 linux-next] jbd2: Fix sparse context imbalance warning
  2014-09-18 18:29 [PATCH 1/1 linux-next] jbd2: Fix sparse context imbalance warning Fabian Frederick
@ 2014-09-18 20:44 ` Theodore Ts'o
  2014-09-20  7:14   ` Fabian Frederick
  0 siblings, 1 reply; 3+ messages in thread
From: Theodore Ts'o @ 2014-09-18 20:44 UTC (permalink / raw)
  To: Fabian Frederick; +Cc: linux-kernel, linux-ext4

On Thu, Sep 18, 2014 at 08:29:34PM +0200, Fabian Frederick wrote:
> spin_unlock after spin_lock only.
> 
> This fixes the following sparse warning:
> fs/jbd2/transaction.c:1102:20: warning: context imbalance
> in 'jbd2_journal_get_create_access' - different lock contexts for basic block
> 
> Signed-off-by: Fabian Frederick <fabf@skynet.be>

NAK, this is a case where I think it's better to make the static
analyzers better.  In any case sparse gives a lot of false positives
for this particular warning, so adding lines of code to try to shut up
sparse for every single false positive seems to be a losing
proposition.

I'll note that these sorts of bugs are much more easily picked up
using lockdep in any case, so we're probably better of just ignoring
these sorts of warnings.  Better to let the 0day kernel tester warn
for new sparse warnings, instead of trying to drive sparse warnings
down to zero.

Cheers,

					- Ted

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

* Re: [PATCH 1/1 linux-next] jbd2: Fix sparse context imbalance warning
  2014-09-18 20:44 ` Theodore Ts'o
@ 2014-09-20  7:14   ` Fabian Frederick
  0 siblings, 0 replies; 3+ messages in thread
From: Fabian Frederick @ 2014-09-20  7:14 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: linux-ext4, linux-kernel



> On 18 September 2014 at 22:44 Theodore Ts'o <tytso@mit.edu> wrote:
>
>
> On Thu, Sep 18, 2014 at 08:29:34PM +0200, Fabian Frederick wrote:
> > spin_unlock after spin_lock only.
> >
> > This fixes the following sparse warning:
> > fs/jbd2/transaction.c:1102:20: warning: context imbalance
> > in 'jbd2_journal_get_create_access' - different lock contexts for basic
> > block
> >
> > Signed-off-by: Fabian Frederick <fabf@skynet.be>
>
> NAK, this is a case where I think it's better to make the static
> analyzers better.  In any case sparse gives a lot of false positives
> for this particular warning, so adding lines of code to try to shut up
> sparse for every single false positive seems to be a losing
> proposition.
>
> I'll note that these sorts of bugs are much more easily picked up
> using lockdep in any case, so we're probably better of just ignoring
> these sorts of warnings.  Better to let the 0day kernel tester warn
> for new sparse warnings, instead of trying to drive sparse warnings
> down to zero.
>
> Cheers,
>
>                                       - Ted

Thanks a lot for explanation Ted. I didn't see J_ASSERT_JH above which BUG_ON
if b_transaction is not ok.


Regards,
Fabian

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

end of thread, other threads:[~2014-09-20  7:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-18 18:29 [PATCH 1/1 linux-next] jbd2: Fix sparse context imbalance warning Fabian Frederick
2014-09-18 20:44 ` Theodore Ts'o
2014-09-20  7:14   ` Fabian Frederick

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).