Skip to content

Commit

Permalink
[PATCH] ext3/4: fix J_ASSERT(transaction->t_updates > 0) in journal_s…
Browse files Browse the repository at this point in the history
…top()

A disk generated some I/O error, after it, I hitted
J_ASSERT(transaction->t_updates > 0) in journal_stop().

It seems to happened on ext3_truncate() path from stack trace. Then,
maybe the following case may trigger J_ASSERT(transaction->t_updates > 0).

ext3_truncate()
    -> ext3_free_branches()
        -> ext3_journal_test_restart()
	    -> ext3_journal_restart()
                -> journal_restart()
                transaction->t_updates--;
                /* another process aborted journal */
                    -> start_this_handle()
		    returns -EROFS without transaction->t_updates++;

    -> ext3_journal_stop()
        -> journal_stop()
	J_ASSERT(transaction->t_updates > 0)

If journal was aborted in middle of journal_restart(), ext3_truncate()
may trigger J_ASSERT().

Signed-off-by: OGAWA Hirofumi <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
OGAWAHirofumi authored and Linus Torvalds committed Oct 20, 2006
1 parent 82591e6 commit 3e2a532
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions fs/jbd/transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -1314,13 +1314,14 @@ int journal_stop(handle_t *handle)
int old_handle_count, err;
pid_t pid;

J_ASSERT(transaction->t_updates > 0);
J_ASSERT(journal_current_handle() == handle);

if (is_handle_aborted(handle))
err = -EIO;
else
else {
J_ASSERT(transaction->t_updates > 0);
err = 0;
}

if (--handle->h_ref > 0) {
jbd_debug(4, "h_ref %d -> %d\n", handle->h_ref + 1,
Expand Down
5 changes: 3 additions & 2 deletions fs/jbd2/transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -1314,13 +1314,14 @@ int jbd2_journal_stop(handle_t *handle)
int old_handle_count, err;
pid_t pid;

J_ASSERT(transaction->t_updates > 0);
J_ASSERT(journal_current_handle() == handle);

if (is_handle_aborted(handle))
err = -EIO;
else
else {
J_ASSERT(transaction->t_updates > 0);
err = 0;
}

if (--handle->h_ref > 0) {
jbd_debug(4, "h_ref %d -> %d\n", handle->h_ref + 1,
Expand Down

0 comments on commit 3e2a532

Please sign in to comment.