Skip to content

Commit 7f6225e

Browse files
zhangyi089tytso
authored andcommitted
jbd2: clean __jbd2_journal_abort_hard() and __journal_abort_soft()
__jbd2_journal_abort_hard() is no longer used, so now we can merge __jbd2_journal_abort_hard() and __journal_abort_soft() these two functions into jbd2_journal_abort() and remove them. Signed-off-by: zhangyi (F) <[email protected]> Reviewed-by: Jan Kara <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 0e98c08 commit 7f6225e

File tree

2 files changed

+42
-62
lines changed

2 files changed

+42
-62
lines changed

fs/jbd2/journal.c

Lines changed: 42 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ EXPORT_SYMBOL(jbd2_journal_release_jbd_inode);
9696
EXPORT_SYMBOL(jbd2_journal_begin_ordered_truncate);
9797
EXPORT_SYMBOL(jbd2_inode_cache);
9898

99-
static void __journal_abort_soft (journal_t *journal, int errno);
10099
static int jbd2_journal_create_slab(size_t slab_size);
101100

102101
#ifdef CONFIG_JBD2_DEBUG
@@ -805,7 +804,7 @@ int jbd2_journal_bmap(journal_t *journal, unsigned long blocknr,
805804
"at offset %lu on %s\n",
806805
__func__, blocknr, journal->j_devname);
807806
err = -EIO;
808-
__journal_abort_soft(journal, err);
807+
jbd2_journal_abort(journal, err);
809808
}
810809
} else {
811810
*retp = blocknr; /* +journal->j_blk_offset */
@@ -2103,64 +2102,6 @@ int jbd2_journal_wipe(journal_t *journal, int write)
21032102
return err;
21042103
}
21052104

2106-
/*
2107-
* Journal abort has very specific semantics, which we describe
2108-
* for journal abort.
2109-
*
2110-
* Two internal functions, which provide abort to the jbd layer
2111-
* itself are here.
2112-
*/
2113-
2114-
/*
2115-
* Quick version for internal journal use (doesn't lock the journal).
2116-
* Aborts hard --- we mark the abort as occurred, but do _nothing_ else,
2117-
* and don't attempt to make any other journal updates.
2118-
*/
2119-
void __jbd2_journal_abort_hard(journal_t *journal)
2120-
{
2121-
transaction_t *transaction;
2122-
2123-
if (journal->j_flags & JBD2_ABORT)
2124-
return;
2125-
2126-
printk(KERN_ERR "Aborting journal on device %s.\n",
2127-
journal->j_devname);
2128-
2129-
write_lock(&journal->j_state_lock);
2130-
journal->j_flags |= JBD2_ABORT;
2131-
transaction = journal->j_running_transaction;
2132-
if (transaction)
2133-
__jbd2_log_start_commit(journal, transaction->t_tid);
2134-
write_unlock(&journal->j_state_lock);
2135-
}
2136-
2137-
/* Soft abort: record the abort error status in the journal superblock,
2138-
* but don't do any other IO. */
2139-
static void __journal_abort_soft (journal_t *journal, int errno)
2140-
{
2141-
int old_errno;
2142-
2143-
write_lock(&journal->j_state_lock);
2144-
old_errno = journal->j_errno;
2145-
if (!journal->j_errno || errno == -ESHUTDOWN)
2146-
journal->j_errno = errno;
2147-
2148-
if (journal->j_flags & JBD2_ABORT) {
2149-
write_unlock(&journal->j_state_lock);
2150-
if (old_errno != -ESHUTDOWN && errno == -ESHUTDOWN)
2151-
jbd2_journal_update_sb_errno(journal);
2152-
return;
2153-
}
2154-
write_unlock(&journal->j_state_lock);
2155-
2156-
__jbd2_journal_abort_hard(journal);
2157-
2158-
jbd2_journal_update_sb_errno(journal);
2159-
write_lock(&journal->j_state_lock);
2160-
journal->j_flags |= JBD2_REC_ERR;
2161-
write_unlock(&journal->j_state_lock);
2162-
}
2163-
21642105
/**
21652106
* void jbd2_journal_abort () - Shutdown the journal immediately.
21662107
* @journal: the journal to shutdown.
@@ -2204,7 +2145,47 @@ static void __journal_abort_soft (journal_t *journal, int errno)
22042145

22052146
void jbd2_journal_abort(journal_t *journal, int errno)
22062147
{
2207-
__journal_abort_soft(journal, errno);
2148+
transaction_t *transaction;
2149+
2150+
/*
2151+
* ESHUTDOWN always takes precedence because a file system check
2152+
* caused by any other journal abort error is not required after
2153+
* a shutdown triggered.
2154+
*/
2155+
write_lock(&journal->j_state_lock);
2156+
if (journal->j_flags & JBD2_ABORT) {
2157+
int old_errno = journal->j_errno;
2158+
2159+
write_unlock(&journal->j_state_lock);
2160+
if (old_errno != -ESHUTDOWN && errno == -ESHUTDOWN) {
2161+
journal->j_errno = errno;
2162+
jbd2_journal_update_sb_errno(journal);
2163+
}
2164+
return;
2165+
}
2166+
2167+
/*
2168+
* Mark the abort as occurred and start current running transaction
2169+
* to release all journaled buffer.
2170+
*/
2171+
pr_err("Aborting journal on device %s.\n", journal->j_devname);
2172+
2173+
journal->j_flags |= JBD2_ABORT;
2174+
journal->j_errno = errno;
2175+
transaction = journal->j_running_transaction;
2176+
if (transaction)
2177+
__jbd2_log_start_commit(journal, transaction->t_tid);
2178+
write_unlock(&journal->j_state_lock);
2179+
2180+
/*
2181+
* Record errno to the journal super block, so that fsck and jbd2
2182+
* layer could realise that a filesystem check is needed.
2183+
*/
2184+
jbd2_journal_update_sb_errno(journal);
2185+
2186+
write_lock(&journal->j_state_lock);
2187+
journal->j_flags |= JBD2_REC_ERR;
2188+
write_unlock(&journal->j_state_lock);
22082189
}
22092190

22102191
/**

include/linux/jbd2.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1403,7 +1403,6 @@ extern int jbd2_journal_skip_recovery (journal_t *);
14031403
extern void jbd2_journal_update_sb_errno(journal_t *);
14041404
extern int jbd2_journal_update_sb_log_tail (journal_t *, tid_t,
14051405
unsigned long, int);
1406-
extern void __jbd2_journal_abort_hard (journal_t *);
14071406
extern void jbd2_journal_abort (journal_t *, int);
14081407
extern int jbd2_journal_errno (journal_t *);
14091408
extern void jbd2_journal_ack_err (journal_t *);

0 commit comments

Comments
 (0)