Skip to content

Commit

Permalink
jbd2: clean __jbd2_journal_abort_hard() and __journal_abort_soft()
Browse files Browse the repository at this point in the history
__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]>
  • Loading branch information
zhangyi089 authored and tytso committed Jan 25, 2020
1 parent 0e98c08 commit 7f6225e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 62 deletions.
103 changes: 42 additions & 61 deletions fs/jbd2/journal.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ EXPORT_SYMBOL(jbd2_journal_release_jbd_inode);
EXPORT_SYMBOL(jbd2_journal_begin_ordered_truncate);
EXPORT_SYMBOL(jbd2_inode_cache);

static void __journal_abort_soft (journal_t *journal, int errno);
static int jbd2_journal_create_slab(size_t slab_size);

#ifdef CONFIG_JBD2_DEBUG
Expand Down Expand Up @@ -805,7 +804,7 @@ int jbd2_journal_bmap(journal_t *journal, unsigned long blocknr,
"at offset %lu on %s\n",
__func__, blocknr, journal->j_devname);
err = -EIO;
__journal_abort_soft(journal, err);
jbd2_journal_abort(journal, err);
}
} else {
*retp = blocknr; /* +journal->j_blk_offset */
Expand Down Expand Up @@ -2103,64 +2102,6 @@ int jbd2_journal_wipe(journal_t *journal, int write)
return err;
}

/*
* Journal abort has very specific semantics, which we describe
* for journal abort.
*
* Two internal functions, which provide abort to the jbd layer
* itself are here.
*/

/*
* Quick version for internal journal use (doesn't lock the journal).
* Aborts hard --- we mark the abort as occurred, but do _nothing_ else,
* and don't attempt to make any other journal updates.
*/
void __jbd2_journal_abort_hard(journal_t *journal)
{
transaction_t *transaction;

if (journal->j_flags & JBD2_ABORT)
return;

printk(KERN_ERR "Aborting journal on device %s.\n",
journal->j_devname);

write_lock(&journal->j_state_lock);
journal->j_flags |= JBD2_ABORT;
transaction = journal->j_running_transaction;
if (transaction)
__jbd2_log_start_commit(journal, transaction->t_tid);
write_unlock(&journal->j_state_lock);
}

/* Soft abort: record the abort error status in the journal superblock,
* but don't do any other IO. */
static void __journal_abort_soft (journal_t *journal, int errno)
{
int old_errno;

write_lock(&journal->j_state_lock);
old_errno = journal->j_errno;
if (!journal->j_errno || errno == -ESHUTDOWN)
journal->j_errno = errno;

if (journal->j_flags & JBD2_ABORT) {
write_unlock(&journal->j_state_lock);
if (old_errno != -ESHUTDOWN && errno == -ESHUTDOWN)
jbd2_journal_update_sb_errno(journal);
return;
}
write_unlock(&journal->j_state_lock);

__jbd2_journal_abort_hard(journal);

jbd2_journal_update_sb_errno(journal);
write_lock(&journal->j_state_lock);
journal->j_flags |= JBD2_REC_ERR;
write_unlock(&journal->j_state_lock);
}

/**
* void jbd2_journal_abort () - Shutdown the journal immediately.
* @journal: the journal to shutdown.
Expand Down Expand Up @@ -2204,7 +2145,47 @@ static void __journal_abort_soft (journal_t *journal, int errno)

void jbd2_journal_abort(journal_t *journal, int errno)
{
__journal_abort_soft(journal, errno);
transaction_t *transaction;

/*
* ESHUTDOWN always takes precedence because a file system check
* caused by any other journal abort error is not required after
* a shutdown triggered.
*/
write_lock(&journal->j_state_lock);
if (journal->j_flags & JBD2_ABORT) {
int old_errno = journal->j_errno;

write_unlock(&journal->j_state_lock);
if (old_errno != -ESHUTDOWN && errno == -ESHUTDOWN) {
journal->j_errno = errno;
jbd2_journal_update_sb_errno(journal);
}
return;
}

/*
* Mark the abort as occurred and start current running transaction
* to release all journaled buffer.
*/
pr_err("Aborting journal on device %s.\n", journal->j_devname);

journal->j_flags |= JBD2_ABORT;
journal->j_errno = errno;
transaction = journal->j_running_transaction;
if (transaction)
__jbd2_log_start_commit(journal, transaction->t_tid);
write_unlock(&journal->j_state_lock);

/*
* Record errno to the journal super block, so that fsck and jbd2
* layer could realise that a filesystem check is needed.
*/
jbd2_journal_update_sb_errno(journal);

write_lock(&journal->j_state_lock);
journal->j_flags |= JBD2_REC_ERR;
write_unlock(&journal->j_state_lock);
}

/**
Expand Down
1 change: 0 additions & 1 deletion include/linux/jbd2.h
Original file line number Diff line number Diff line change
Expand Up @@ -1403,7 +1403,6 @@ extern int jbd2_journal_skip_recovery (journal_t *);
extern void jbd2_journal_update_sb_errno(journal_t *);
extern int jbd2_journal_update_sb_log_tail (journal_t *, tid_t,
unsigned long, int);
extern void __jbd2_journal_abort_hard (journal_t *);
extern void jbd2_journal_abort (journal_t *, int);
extern int jbd2_journal_errno (journal_t *);
extern void jbd2_journal_ack_err (journal_t *);
Expand Down

0 comments on commit 7f6225e

Please sign in to comment.