提交 8503a897 编写于 作者: J Jan Kara 提交者: Yang Yingliang

jbd2: Reorganize jbd2_journal_stop()

mainline inclusion
from mainline-5.5-rc1
commit dfaf5ffda227be3e867fee7c0f6a66749392fbd0
category: bugfix
bugzilla: 25031
CVE: NA
---------------------------

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: NTheodore Ts'o <tytso@mit.edu>
Signed-off-by: NJan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20191105164437.32602-14-jack@suse.czSigned-off-by: NTheodore Ts'o <tytso@mit.edu>
Signed-off-by: Nzhangyi (F) <yi.zhang@huawei.com>
Reviewed-by: NYang Erkun <yangerkun@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 c75a7e3b
...@@ -1672,41 +1672,34 @@ int jbd2_journal_stop(handle_t *handle) ...@@ -1672,41 +1672,34 @@ int jbd2_journal_stop(handle_t *handle)
tid_t tid; tid_t tid;
pid_t pid; pid_t pid;
if (--handle->h_ref > 0) {
jbd_debug(4, "h_ref %d -> %d\n", handle->h_ref + 1,
handle->h_ref);
if (is_handle_aborted(handle))
return -EIO;
return 0;
}
if (!transaction) { if (!transaction) {
/* /*
* Handle is already detached from the transaction so * Handle is already detached from the transaction so there is
* there is nothing to do other than decrease a refcount, * nothing to do other than free the handle.
* or free the handle if refcount drops to zero
*/ */
if (--handle->h_ref > 0) { if (handle->h_rsv_handle)
jbd_debug(4, "h_ref %d -> %d\n", handle->h_ref + 1, jbd2_free_handle(handle->h_rsv_handle);
handle->h_ref); goto free_and_exit;
return err;
} else {
if (handle->h_rsv_handle)
jbd2_free_handle(handle->h_rsv_handle);
goto free_and_exit;
}
} }
journal = transaction->t_journal; journal = transaction->t_journal;
tid = transaction->t_tid;
J_ASSERT(journal_current_handle() == handle); J_ASSERT(journal_current_handle() == handle);
J_ASSERT(atomic_read(&transaction->t_updates) > 0);
if (is_handle_aborted(handle)) if (is_handle_aborted(handle))
err = -EIO; 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); jbd_debug(4, "Handle %p going down\n", handle);
trace_jbd2_handle_stats(journal->j_fs_dev->bd_dev, trace_jbd2_handle_stats(journal->j_fs_dev->bd_dev,
transaction->t_tid, tid, handle->h_type, handle->h_line_no,
handle->h_type, handle->h_line_no,
jiffies - handle->h_start_jiffies, jiffies - handle->h_start_jiffies,
handle->h_sync, handle->h_requested_credits, handle->h_sync, handle->h_requested_credits,
(handle->h_requested_credits - (handle->h_requested_credits -
...@@ -1791,7 +1784,7 @@ int jbd2_journal_stop(handle_t *handle) ...@@ -1791,7 +1784,7 @@ int jbd2_journal_stop(handle_t *handle)
jbd_debug(2, "transaction too old, requesting commit for " jbd_debug(2, "transaction too old, requesting commit for "
"handle %p\n", handle); "handle %p\n", handle);
/* This is non-blocking */ /* 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 * Special case: JBD2_SYNC synchronous updates require us
...@@ -1807,7 +1800,6 @@ int jbd2_journal_stop(handle_t *handle) ...@@ -1807,7 +1800,6 @@ int jbd2_journal_stop(handle_t *handle)
* once we do this, we must not dereference transaction * once we do this, we must not dereference transaction
* pointer again. * pointer again.
*/ */
tid = transaction->t_tid;
if (atomic_dec_and_test(&transaction->t_updates)) { if (atomic_dec_and_test(&transaction->t_updates)) {
wake_up(&journal->j_wait_updates); wake_up(&journal->j_wait_updates);
if (journal->j_barrier_count) if (journal->j_barrier_count)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册