diff mbox

[RFC] jbd2: Call the commit callback before the transaction could get dropped

Message ID 20081028022838.GA8869@mit.edu
State Accepted, archived
Headers show

Commit Message

Theodore Y. Ts'o Oct. 28, 2008, 2:28 a.m. UTC
This is what I plan to send to Linus to fix the problem.

commit 6fecbc3c7d27800e90a5f5fbca2fb2847e2c2854
Author: Theodore Ts'o <tytso@mit.edu>
Date:   Mon Oct 27 22:11:39 2008 -0400

    jbd2: Call the commit callback before the transaction could get dropped
    
    The transaction can potentially get dropped if there are no buffers
    that need to be written.  Make sure we call the commit callback before
    potentially deciding to drop the transaction.  Also avoid
    dereferencing the commit_transaction pointer in the marker for the
    same reason.
    
    This patch fixes the bug reported by Eric Paris at:
    http://bugzilla.kernel.org/show_bug.cgi?id=11838
    
    Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>

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

Comments

Eric Sandeen Oct. 28, 2008, 2:41 a.m. UTC | #1
Theodore Tso wrote:
> This is what I plan to send to Linus to fix the problem.
> 
> commit 6fecbc3c7d27800e90a5f5fbca2fb2847e2c2854
> Author: Theodore Ts'o <tytso@mit.edu>
> Date:   Mon Oct 27 22:11:39 2008 -0400
> 
>     jbd2: Call the commit callback before the transaction could get dropped
>     
>     The transaction can potentially get dropped if there are no buffers
>     that need to be written.  Make sure we call the commit callback before
>     potentially deciding to drop the transaction.  Also avoid
>     dereferencing the commit_transaction pointer in the marker for the
>     same reason.
>     
>     This patch fixes the bug reported by Eric Paris at:
>     http://bugzilla.kernel.org/show_bug.cgi?id=11838
>     
>     Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>

Acked-by: Eric Sandeen <sandeen@redhat.com>

> diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
> index 8b119e1..ebc667b 100644
> --- a/fs/jbd2/commit.c
> +++ b/fs/jbd2/commit.c
> @@ -974,6 +974,9 @@ restart_loop:
>  	journal->j_committing_transaction = NULL;
>  	spin_unlock(&journal->j_state_lock);
>  
> +	if (journal->j_commit_callback)
> +		journal->j_commit_callback(journal, commit_transaction);
> +
>  	if (commit_transaction->t_checkpoint_list == NULL &&
>  	    commit_transaction->t_checkpoint_io_list == NULL) {
>  		__jbd2_journal_drop_transaction(journal, commit_transaction);
> @@ -995,11 +998,8 @@ restart_loop:
>  	}
>  	spin_unlock(&journal->j_list_lock);
>  
> -	if (journal->j_commit_callback)
> -		journal->j_commit_callback(journal, commit_transaction);
> -
>  	trace_mark(jbd2_end_commit, "dev %s transaction %d head %d",
> -		   journal->j_devname, commit_transaction->t_tid,
> +		   journal->j_devname, journal->j_commit_sequence,
>  		   journal->j_tail_sequence);
>  	jbd_debug(1, "JBD: commit %d complete, head %d\n",
>  		  journal->j_commit_sequence, journal->j_tail_sequence);

--
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
Eric Paris Oct. 28, 2008, 1:46 p.m. UTC | #2
On Mon, 2008-10-27 at 21:41 -0500, Eric Sandeen wrote:
> Theodore Tso wrote:
> > This is what I plan to send to Linus to fix the problem.
> > 
> > commit 6fecbc3c7d27800e90a5f5fbca2fb2847e2c2854
> > Author: Theodore Ts'o <tytso@mit.edu>
> > Date:   Mon Oct 27 22:11:39 2008 -0400
> > 
> >     jbd2: Call the commit callback before the transaction could get dropped
> >     
> >     The transaction can potentially get dropped if there are no buffers
> >     that need to be written.  Make sure we call the commit callback before
> >     potentially deciding to drop the transaction.  Also avoid
> >     dereferencing the commit_transaction pointer in the marker for the
> >     same reason.
> >     
> >     This patch fixes the bug reported by Eric Paris at:
> >     http://bugzilla.kernel.org/show_bug.cgi?id=11838
> >     
> >     Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
> 
> Acked-by: Eric Sandeen <sandeen@redhat.com>

Tested-by: Eric Paris <eparis@redhat.com>

--
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
diff mbox

Patch

diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
index 8b119e1..ebc667b 100644
--- a/fs/jbd2/commit.c
+++ b/fs/jbd2/commit.c
@@ -974,6 +974,9 @@  restart_loop:
 	journal->j_committing_transaction = NULL;
 	spin_unlock(&journal->j_state_lock);
 
+	if (journal->j_commit_callback)
+		journal->j_commit_callback(journal, commit_transaction);
+
 	if (commit_transaction->t_checkpoint_list == NULL &&
 	    commit_transaction->t_checkpoint_io_list == NULL) {
 		__jbd2_journal_drop_transaction(journal, commit_transaction);
@@ -995,11 +998,8 @@  restart_loop:
 	}
 	spin_unlock(&journal->j_list_lock);
 
-	if (journal->j_commit_callback)
-		journal->j_commit_callback(journal, commit_transaction);
-
 	trace_mark(jbd2_end_commit, "dev %s transaction %d head %d",
-		   journal->j_devname, commit_transaction->t_tid,
+		   journal->j_devname, journal->j_commit_sequence,
 		   journal->j_tail_sequence);
 	jbd_debug(1, "JBD: commit %d complete, head %d\n",
 		  journal->j_commit_sequence, journal->j_tail_sequence);