Commit dfaf5ffd authored by Jan Kara's avatar Jan Kara Committed by Theodore Ts'o

jbd2: Reorganize jbd2_journal_stop()

Move code in jbd2_journal_stop() around a bit. It removes some
unnecessary code duplication and will make factoring out parts common
with jbd2__journal_restart() easier.
Reviewed-by: default avatarTheodore Ts'o <tytso@mit.edu>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20191105164437.32602-14-jack@suse.czSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
parent 015c6033
......@@ -1706,41 +1706,34 @@ int jbd2_journal_stop(handle_t *handle)
tid_t tid;
pid_t pid;
if (!transaction) {
/*
* Handle is already detached from the transaction so
* there is nothing to do other than decrease a refcount,
* or free the handle if refcount drops to zero
*/
if (--handle->h_ref > 0) {
jbd_debug(4, "h_ref %d -> %d\n", handle->h_ref + 1,
handle->h_ref);
return err;
} else {
if (is_handle_aborted(handle))
return -EIO;
return 0;
}
if (!transaction) {
/*
* Handle is already detached from the transaction so there is
* nothing to do other than free the handle.
*/
if (handle->h_rsv_handle)
jbd2_free_handle(handle->h_rsv_handle);
goto free_and_exit;
}
}
journal = transaction->t_journal;
tid = transaction->t_tid;
J_ASSERT(journal_current_handle() == handle);
J_ASSERT(atomic_read(&transaction->t_updates) > 0);
if (is_handle_aborted(handle))
err = -EIO;
else
J_ASSERT(atomic_read(&transaction->t_updates) > 0);
if (--handle->h_ref > 0) {
jbd_debug(4, "h_ref %d -> %d\n", handle->h_ref + 1,
handle->h_ref);
return err;
}
jbd_debug(4, "Handle %p going down\n", handle);
trace_jbd2_handle_stats(journal->j_fs_dev->bd_dev,
transaction->t_tid,
handle->h_type, handle->h_line_no,
tid, handle->h_type, handle->h_line_no,
jiffies - handle->h_start_jiffies,
handle->h_sync, handle->h_requested_credits,
(handle->h_requested_credits -
......@@ -1825,7 +1818,7 @@ int jbd2_journal_stop(handle_t *handle)
jbd_debug(2, "transaction too old, requesting commit for "
"handle %p\n", handle);
/* This is non-blocking */
jbd2_log_start_commit(journal, transaction->t_tid);
jbd2_log_start_commit(journal, tid);
/*
* Special case: JBD2_SYNC synchronous updates require us
......@@ -1841,7 +1834,6 @@ int jbd2_journal_stop(handle_t *handle)
* once we do this, we must not dereference transaction
* pointer again.
*/
tid = transaction->t_tid;
if (atomic_dec_and_test(&transaction->t_updates)) {
wake_up(&journal->j_wait_updates);
if (journal->j_barrier_count)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment