All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] jbd2: fix incorrect unlock on j_list_lock
@ 2015-03-18  2:08 Taesoo Kim
  2015-03-18 10:43 ` Lukáš Czerner
  2016-10-12 22:58 ` Andreas Dilger
  0 siblings, 2 replies; 9+ messages in thread
From: Taesoo Kim @ 2015-03-18  2:08 UTC (permalink / raw)
  To: tytso, linux-ext4, linux-kernel
  Cc: taesoo, changwoo, sanidhya, blee, csong84, Taesoo Kim

When 'jh->b_transaction == transaction' (asserted by below)

  J_ASSERT_JH(jh, (jh->b_transaction == transaction || ...

'journal->j_list_lock' will be incorrectly unlocked, since
the the lock is aquired only at the end of if / else-if
statements (missing the else case).

Signed-off-by: Taesoo Kim <tsgatesv@gmail.com>
---
 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);

 	/*
--
2.3.3


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

* Re: [PATCH 1/1] jbd2: fix incorrect unlock on j_list_lock
  2015-03-18  2:08 [PATCH 1/1] jbd2: fix incorrect unlock on j_list_lock Taesoo Kim
@ 2015-03-18 10:43 ` Lukáš Czerner
  2015-03-18 17:39   ` Taesoo Kim
  2016-10-12 22:58 ` Andreas Dilger
  1 sibling, 1 reply; 9+ messages in thread
From: Lukáš Czerner @ 2015-03-18 10:43 UTC (permalink / raw)
  To: Taesoo Kim
  Cc: tytso, linux-ext4, linux-kernel, taesoo, changwoo, sanidhya,
	blee, csong84

On Tue, 17 Mar 2015, Taesoo Kim wrote:

> Date: Tue, 17 Mar 2015 22:08:38 -0400
> From: Taesoo Kim <tsgatesv@gmail.com>
> To: tytso@mit.edu, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org
> Cc: taesoo@gatech.edu, changwoo@gatech.edu, sanidhya@gatech.edu,
>     blee@gatech.edu, csong84@gatech.edu, Taesoo Kim <tsgatesv@gmail.com>
> Subject: [PATCH 1/1] jbd2: fix incorrect unlock on j_list_lock
> 
> When 'jh->b_transaction == transaction' (asserted by below)
> 
>   J_ASSERT_JH(jh, (jh->b_transaction == transaction || ...
> 
> 'journal->j_list_lock' will be incorrectly unlocked, since
> the the lock is aquired only at the end of if / else-if
> statements (missing the else case).

The patch looks good, thanks.

Reviewed-by: Lukas Czerner <lczerner@redhat.com>

Btw, were you able to reproduce the problem, or have you seen the
problem in the wild ? Or did you just spot it in the code ?

Thanks!
-Lukas

> 
> Signed-off-by: Taesoo Kim <tsgatesv@gmail.com>
> ---
>  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);
> 
>  	/*
> --
> 2.3.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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

* Re: [PATCH 1/1] jbd2: fix incorrect unlock on j_list_lock
  2015-03-18 10:43 ` Lukáš Czerner
@ 2015-03-18 17:39   ` Taesoo Kim
  2015-03-19  9:48     ` Lukáš Czerner
  0 siblings, 1 reply; 9+ messages in thread
From: Taesoo Kim @ 2015-03-18 17:39 UTC (permalink / raw)
  To: Lukáš Czerner
  Cc: Taesoo Kim, tytso, linux-ext4, linux-kernel, changwoo, sanidhya,
	blee, csong84

> The patch looks good, thanks.

Thank you.
 
> Reviewed-by: Lukas Czerner <lczerner@redhat.com>
> 
> Btw, were you able to reproduce the problem, or have you seen the
> problem in the wild ? Or did you just spot it in the code ?

We are developing a static checker to spot inconsistent programming
patterns; our first goal is to scan over existing filesystems and
figure out how they are implemented differently (or similarly). We
will report bugs in sequence as soon as our team confirm (just start
sending patches to other fs).

Thanks,
Taesoo

> Thanks!
> -Lukas
> 
> > 
> > Signed-off-by: Taesoo Kim <tsgatesv@gmail.com>
> > ---
> >  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);
> > 
> >  	/*
> > --
> > 2.3.3
> > 
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > 

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

* Re: [PATCH 1/1] jbd2: fix incorrect unlock on j_list_lock
  2015-03-18 17:39   ` Taesoo Kim
@ 2015-03-19  9:48     ` Lukáš Czerner
  2015-03-19 12:02         ` Taesoo Kim
  0 siblings, 1 reply; 9+ messages in thread
From: Lukáš Czerner @ 2015-03-19  9:48 UTC (permalink / raw)
  To: Taesoo Kim
  Cc: Taesoo Kim, tytso, linux-ext4, linux-kernel, changwoo, sanidhya,
	blee, csong84

[-- Attachment #1: Type: TEXT/PLAIN, Size: 2725 bytes --]

On Wed, 18 Mar 2015, Taesoo Kim wrote:

> Date: Wed, 18 Mar 2015 13:39:31 -0400
> From: Taesoo Kim <taesoo@gatech.edu>
> To: Lukáš Czerner <lczerner@redhat.com>
> Cc: Taesoo Kim <tsgatesv@gmail.com>, tytso@mit.edu,
>     linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org,
>     changwoo@gatech.edu, sanidhya@gatech.edu, blee@gatech.edu,
>     csong84@gatech.edu
> Subject: Re: [PATCH 1/1] jbd2: fix incorrect unlock on j_list_lock
> 
> > The patch looks good, thanks.
> 
> Thank you.
>  
> > Reviewed-by: Lukas Czerner <lczerner@redhat.com>
> > 
> > Btw, were you able to reproduce the problem, or have you seen the
> > problem in the wild ? Or did you just spot it in the code ?
> 
> We are developing a static checker to spot inconsistent programming
> patterns; our first goal is to scan over existing filesystems and
> figure out how they are implemented differently (or similarly). We
> will report bugs in sequence as soon as our team confirm (just start
> sending patches to other fs).

And this was found but it ?

But anyway it sounds really interesting, do you have any more
information you can share about the project ? Project website,
description, or source code would be great :)

Thanks!
-Lukas

> 
> Thanks,
> Taesoo
> 
> > Thanks!
> > -Lukas
> > 
> > > 
> > > Signed-off-by: Taesoo Kim <tsgatesv@gmail.com>
> > > ---
> > >  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);
> > > 
> > >  	/*
> > > --
> > > 2.3.3
> > > 
> > > --
> > > To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> > > the body of a message to majordomo@vger.kernel.org
> > > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > > 
> 

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

* Re: [PATCH 1/1] jbd2: fix incorrect unlock on j_list_lock
  2015-03-19  9:48     ` Lukáš Czerner
@ 2015-03-19 12:02         ` Taesoo Kim
  0 siblings, 0 replies; 9+ messages in thread
From: Taesoo Kim @ 2015-03-19 12:02 UTC (permalink / raw)
  To: Lukáš Czerner
  Cc: Taesoo Kim, tytso, linux-ext4, linux-kernel, changwoo, sanidhya,
	blee, csong84

On 03/19/15 at 10:48am, Lukáš Czerner wrote:
> On Wed, 18 Mar 2015, Taesoo Kim wrote:
> 
> > Date: Wed, 18 Mar 2015 13:39:31 -0400
> > From: Taesoo Kim <taesoo@gatech.edu>
> > To: Lukáš Czerner <lczerner@redhat.com>
> > Cc: Taesoo Kim <tsgatesv@gmail.com>, tytso@mit.edu,
> >     linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org,
> >     changwoo@gatech.edu, sanidhya@gatech.edu, blee@gatech.edu,
> >     csong84@gatech.edu
> > Subject: Re: [PATCH 1/1] jbd2: fix incorrect unlock on j_list_lock
> > 
> > > The patch looks good, thanks.
> > 
> > Thank you.
> >  
> > > Reviewed-by: Lukas Czerner <lczerner@redhat.com>
> > > 
> > > Btw, were you able to reproduce the problem, or have you seen the
> > > problem in the wild ? Or did you just spot it in the code ?
> > 
> > We are developing a static checker to spot inconsistent programming
> > patterns; our first goal is to scan over existing filesystems and
> > figure out how they are implemented differently (or similarly). We
> > will report bugs in sequence as soon as our team confirm (just start
> > sending patches to other fs).
> 
> And this was found but it ?

Our current prototype.
 
> But anyway it sounds really interesting, do you have any more
> information you can share about the project ? Project website,
> description, or source code would be great :)

We need 1-2 months to wrap up. I would say, right after the deadline,
we plan to make the code/result publicly available :)

Taesoo
 
> Thanks!
> -Lukas
> 
> > 
> > Thanks,
> > Taesoo
> > 
> > > Thanks!
> > > -Lukas
> > > 
> > > > 
> > > > Signed-off-by: Taesoo Kim <tsgatesv@gmail.com>
> > > > ---
> > > >  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);
> > > > 
> > > >  	/*
> > > > --
> > > > 2.3.3
> > > > 
> > > > --
> > > > To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> > > > the body of a message to majordomo@vger.kernel.org
> > > > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > > > 
> > 


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

* Re: [PATCH 1/1] jbd2: fix incorrect unlock on j_list_lock
@ 2015-03-19 12:02         ` Taesoo Kim
  0 siblings, 0 replies; 9+ messages in thread
From: Taesoo Kim @ 2015-03-19 12:02 UTC (permalink / raw)
  To: Lukáš Czerner
  Cc: Taesoo Kim, tytso, linux-ext4, linux-kernel, changwoo, sanidhya,
	blee, csong84

On 03/19/15 at 10:48am, Lukáš Czerner wrote:
> On Wed, 18 Mar 2015, Taesoo Kim wrote:
> 
> > Date: Wed, 18 Mar 2015 13:39:31 -0400
> > From: Taesoo Kim <taesoo@gatech.edu>
> > To: Lukáš Czerner <lczerner@redhat.com>
> > Cc: Taesoo Kim <tsgatesv@gmail.com>, tytso@mit.edu,
> >     linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org,
> >     changwoo@gatech.edu, sanidhya@gatech.edu, blee@gatech.edu,
> >     csong84@gatech.edu
> > Subject: Re: [PATCH 1/1] jbd2: fix incorrect unlock on j_list_lock
> > 
> > > The patch looks good, thanks.
> > 
> > Thank you.
> >  
> > > Reviewed-by: Lukas Czerner <lczerner@redhat.com>
> > > 
> > > Btw, were you able to reproduce the problem, or have you seen the
> > > problem in the wild ? Or did you just spot it in the code ?
> > 
> > We are developing a static checker to spot inconsistent programming
> > patterns; our first goal is to scan over existing filesystems and
> > figure out how they are implemented differently (or similarly). We
> > will report bugs in sequence as soon as our team confirm (just start
> > sending patches to other fs).
> 
> And this was found but it ?

Our current prototype.
 
> But anyway it sounds really interesting, do you have any more
> information you can share about the project ? Project website,
> description, or source code would be great :)

We need 1-2 months to wrap up. I would say, right after the deadline,
we plan to make the code/result publicly available :)

Taesoo
 
> Thanks!
> -Lukas
> 
> > 
> > Thanks,
> > Taesoo
> > 
> > > Thanks!
> > > -Lukas
> > > 
> > > > 
> > > > Signed-off-by: Taesoo Kim <tsgatesv@gmail.com>
> > > > ---
> > > >  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);
> > > > 
> > > >  	/*
> > > > --
> > > > 2.3.3
> > > > 
> > > > --
> > > > To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> > > > the body of a message to majordomo@vger.kernel.org
> > > > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > > > 
> > 

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1/1] jbd2: fix incorrect unlock on j_list_lock
  2015-03-19 12:02         ` Taesoo Kim
  (?)
@ 2015-03-19 12:13         ` Lukáš Czerner
  -1 siblings, 0 replies; 9+ messages in thread
From: Lukáš Czerner @ 2015-03-19 12:13 UTC (permalink / raw)
  To: Taesoo Kim
  Cc: Taesoo Kim, tytso, linux-ext4, linux-kernel, changwoo, sanidhya,
	blee, csong84

[-- Attachment #1: Type: TEXT/PLAIN, Size: 2023 bytes --]

On Thu, 19 Mar 2015, Taesoo Kim wrote:

> Date: Thu, 19 Mar 2015 08:02:43 -0400
> From: Taesoo Kim <taesoo@gatech.edu>
> To: Lukáš Czerner <lczerner@redhat.com>
> Cc: Taesoo Kim <tsgatesv@gmail.com>, tytso@mit.edu,
>     linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org,
>     changwoo@gatech.edu, sanidhya@gatech.edu, blee@gatech.edu,
>     csong84@gatech.edu
> Subject: Re: [PATCH 1/1] jbd2: fix incorrect unlock on j_list_lock
> 
> On 03/19/15 at 10:48am, Lukáš Czerner wrote:
> > On Wed, 18 Mar 2015, Taesoo Kim wrote:
> > 
> > > Date: Wed, 18 Mar 2015 13:39:31 -0400
> > > From: Taesoo Kim <taesoo@gatech.edu>
> > > To: Lukáš Czerner <lczerner@redhat.com>
> > > Cc: Taesoo Kim <tsgatesv@gmail.com>, tytso@mit.edu,
> > >     linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org,
> > >     changwoo@gatech.edu, sanidhya@gatech.edu, blee@gatech.edu,
> > >     csong84@gatech.edu
> > > Subject: Re: [PATCH 1/1] jbd2: fix incorrect unlock on j_list_lock
> > > 
> > > > The patch looks good, thanks.
> > > 
> > > Thank you.
> > >  
> > > > Reviewed-by: Lukas Czerner <lczerner@redhat.com>
> > > > 
> > > > Btw, were you able to reproduce the problem, or have you seen the
> > > > problem in the wild ? Or did you just spot it in the code ?
> > > 
> > > We are developing a static checker to spot inconsistent programming
> > > patterns; our first goal is to scan over existing filesystems and
> > > figure out how they are implemented differently (or similarly). We
> > > will report bugs in sequence as soon as our team confirm (just start
> > > sending patches to other fs).
> > 
> > And this was found but it ?
> 
> Our current prototype.
>  
> > But anyway it sounds really interesting, do you have any more
> > information you can share about the project ? Project website,
> > description, or source code would be great :)
> 
> We need 1-2 months to wrap up. I would say, right after the deadline,
> we plan to make the code/result publicly available :)

Great! Looking forward to it.

Thanks!
-Lukas

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

* Re: [PATCH 1/1] jbd2: fix incorrect unlock on j_list_lock
  2015-03-18  2:08 [PATCH 1/1] jbd2: fix incorrect unlock on j_list_lock Taesoo Kim
  2015-03-18 10:43 ` Lukáš Czerner
@ 2016-10-12 22:58 ` Andreas Dilger
  2016-10-13  3:21   ` Theodore Ts'o
  1 sibling, 1 reply; 9+ messages in thread
From: Andreas Dilger @ 2016-10-12 22:58 UTC (permalink / raw)
  To: Taesoo Kim, Theodore Ts'o
  Cc: Ext4 Developers List, LKML, taesoo, changwoo, sanidhya, blee,
	csong84, stable, Faccini, Bruno

[-- Attachment #1: Type: text/plain, Size: 2430 bytes --]

On Mar 17, 2015, at 8:08 PM, Taesoo Kim <tsgatesv@gmail.com> wrote:
> 
> When 'jh->b_transaction == transaction' (asserted by below)
> 
>         J_ASSERT_JH(jh, (jh->b_transaction == transaction || ...
> 
> 'journal->j_list_lock' will be incorrectly unlocked, since
> spin_lock() is called only in the 'if' and 'else-if' blocks but
> not in the missing 'else' case, which results in a hang or an oops:
> 
>     ------------[ cut here ]------------
>     kernel BUG at fs/jbd2/transaction.c:2239!
>     invalid opcode: 0000 [#1] SMP
>     RIP: 0010: __jbd2_journal_file_buffer+0x206/0x220 [jbd2]
>     Call Trace:
>     do_get_write_access+0x33c/0x4e0 [jbd2]
>     jbd2_journal_get_write_access+0x27/0x40 [jbd2]
>     __ext4_journal_get_write_access+0x3b/0x80 [ext4]
>     ext4_delete_entry+0xa9/0x1a0 [ext4]
>     ext4_unlink+0x600/0xa90 [ext4]
> 
> which is assert_spin_locked(&transaction->t_journal->j_list_lock).
> 
> Move spin_unlock() into the two cases where it is actually locked.
> 
> Signed-off-by: Taesoo Kim <tsgatesv@gmail.com>

We've hit this repeatedly on kernels with commit v3.14-rc2-30-g6e4862a
"jbd2: minimize region locked by j_list_lock in journal_get_create_access"
under heavy load and this patch has fixed the problem.

It should also be considered for stable kernels after 3.14.

[I've updated the above commit message slightly to give more details.]

Reviewed-by: Andreas Dilger <adilger@dilger.ca>

> ---
> 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
>  		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
>  		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);
> 
>  	/*
> --
> 2.3.3


Cheers, Andreas






[-- Attachment #2: Message signed with OpenPGP using GPGMail --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH 1/1] jbd2: fix incorrect unlock on j_list_lock
  2016-10-12 22:58 ` Andreas Dilger
@ 2016-10-13  3:21   ` Theodore Ts'o
  0 siblings, 0 replies; 9+ messages in thread
From: Theodore Ts'o @ 2016-10-13  3:21 UTC (permalink / raw)
  To: Andreas Dilger
  Cc: Taesoo Kim, Ext4 Developers List, LKML, taesoo, changwoo,
	sanidhya, blee, csong84, stable, Faccini, Bruno

On Wed, Oct 12, 2016 at 04:58:35PM -0600, Andreas Dilger wrote:
> On Mar 17, 2015, at 8:08 PM, Taesoo Kim <tsgatesv@gmail.com> wrote:
> > 
> > When 'jh->b_transaction == transaction' (asserted by below)
> > 
> >         J_ASSERT_JH(jh, (jh->b_transaction == transaction || ...
> > 
> > 'journal->j_list_lock' will be incorrectly unlocked, since
> > spin_lock() is called only in the 'if' and 'else-if' blocks but
> > not in the missing 'else' case, which results in a hang or an oops....
> > 
> > Signed-off-by: Taesoo Kim <tsgatesv@gmail.com>
> 
> We've hit this repeatedly on kernels with commit v3.14-rc2-30-g6e4862a
> "jbd2: minimize region locked by j_list_lock in journal_get_create_access"
> under heavy load and this patch has fixed the problem.
> 
> It should also be considered for stable kernels after 3.14.
> 
> [I've updated the above commit message slightly to give more details.]
> 
> Reviewed-by: Andreas Dilger <adilger@dilger.ca>

Thanks, applied.

Apologies, this got lost which is why I hadn't handled it earlier.

	   	    	       	      - Ted

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

end of thread, other threads:[~2016-10-13  3:23 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-18  2:08 [PATCH 1/1] jbd2: fix incorrect unlock on j_list_lock Taesoo Kim
2015-03-18 10:43 ` Lukáš Czerner
2015-03-18 17:39   ` Taesoo Kim
2015-03-19  9:48     ` Lukáš Czerner
2015-03-19 12:02       ` Taesoo Kim
2015-03-19 12:02         ` Taesoo Kim
2015-03-19 12:13         ` Lukáš Czerner
2016-10-12 22:58 ` Andreas Dilger
2016-10-13  3:21   ` Theodore Ts'o

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.