From: Jan Kara <jack@suse.cz>
To: <linux-ext4@vger.kernel.org>
Cc: Ted Tso <tytso@mit.edu>, Jan Kara <jack@suse.cz>
Subject: [PATCH 05/15] jbd2: Reorganize jbd2_journal_stop()
Date: Fri, 27 Sep 2019 13:15:26 +0200 [thread overview]
Message-ID: <20190927111536.16455-6-jack@suse.cz> (raw)
In-Reply-To: <20190927111536.16455-1-jack@suse.cz>
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.
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/jbd2/transaction.c | 40 ++++++++++++++++------------------------
1 file changed, 16 insertions(+), 24 deletions(-)
diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index 990e7b5062e7..5987dc8273db 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -1703,41 +1703,34 @@ int jbd2_journal_stop(handle_t *handle)
tid_t tid;
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) {
/*
- * 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
+ * Handle is already detached from the transaction so there is
+ * nothing to do other than free the handle.
*/
- if (--handle->h_ref > 0) {
- jbd_debug(4, "h_ref %d -> %d\n", handle->h_ref + 1,
- handle->h_ref);
- return err;
- } else {
- if (handle->h_rsv_handle)
- jbd2_free_handle(handle->h_rsv_handle);
- goto free_and_exit;
- }
+ 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 -
@@ -1822,7 +1815,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
@@ -1838,7 +1831,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)
--
2.16.4
next prev parent reply other threads:[~2019-09-27 11:16 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-27 11:15 [PATCH 0/15] ext4: Fix transaction overflow due to revoke descriptors Jan Kara
2019-09-27 11:15 ` [PATCH 01/15] jbd2: Fix possible overflow in jbd2_log_space_left() Jan Kara
2019-09-27 11:15 ` [PATCH 02/15] jbd2: Fixup stale comment in commit code Jan Kara
2019-09-27 11:15 ` [PATCH 03/15] ext4: Do not iput inode under running transaction in ext4_mkdir() Jan Kara
2019-09-27 11:15 ` [PATCH 04/15] ext4: Use ext4_journal_extend() instead of jbd2_journal_extend() Jan Kara
2019-09-27 11:15 ` Jan Kara [this message]
2019-09-27 11:15 ` [PATCH 06/15] jbd2: Drop pointless check from jbd2_journal_stop() Jan Kara
2019-09-27 11:15 ` [PATCH 07/15] jbd2: Drop pointless wakeup " Jan Kara
2019-09-27 11:15 ` [PATCH 08/15] jbd2: Factor out common parts of stopping and restarting a handle Jan Kara
2019-09-27 11:15 ` [PATCH 09/15] jbd2: Account descriptor blocks into t_outstanding_credits Jan Kara
2019-09-27 11:15 ` [PATCH 10/15] jbd2: Drop jbd2_space_needed() Jan Kara
2019-09-27 11:15 ` [PATCH 11/15] jbd2: Reserve space for revoke descriptor blocks Jan Kara
2019-09-27 11:15 ` [PATCH 12/15] ext4: Avoid unnecessary revokes in ext4_alloc_branch() Jan Kara
2019-09-27 11:15 ` [PATCH 13/15] jbd2: Fix statistics for the number of logged blocks Jan Kara
2019-09-27 11:15 ` [PATCH 14/15] ext4: Provide function to handle transaction restarts Jan Kara
2019-09-27 11:15 ` [PATCH 15/15] ext4: Reserve revoke credits for freed blocks Jan Kara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190927111536.16455-6-jack@suse.cz \
--to=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).