Commit fd67d8a0 authored by Dave Chinner's avatar Dave Chinner Committed by Darrick J. Wong

xfs: move recovery needed state updates to xfs_log_mount_finish

xfs_log_mount_finish() needs to know if recovery is needed or not to
make decisions on whether to flush the log and AIL.  Move the
handling of the NEED_RECOVERY state out to this function rather than
needing a temporary variable to store this state over the call to
xlog_recover_finish().
Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
parent 5112e206
...@@ -726,9 +726,9 @@ int ...@@ -726,9 +726,9 @@ int
xfs_log_mount_finish( xfs_log_mount_finish(
struct xfs_mount *mp) struct xfs_mount *mp)
{ {
int error = 0; struct xlog *log = mp->m_log;
bool readonly = (mp->m_flags & XFS_MOUNT_RDONLY); bool readonly = (mp->m_flags & XFS_MOUNT_RDONLY);
bool recovered = mp->m_log->l_flags & XLOG_RECOVERY_NEEDED; int error = 0;
if (mp->m_flags & XFS_MOUNT_NORECOVERY) { if (mp->m_flags & XFS_MOUNT_NORECOVERY) {
ASSERT(mp->m_flags & XFS_MOUNT_RDONLY); ASSERT(mp->m_flags & XFS_MOUNT_RDONLY);
...@@ -759,7 +759,8 @@ xfs_log_mount_finish( ...@@ -759,7 +759,8 @@ xfs_log_mount_finish(
* mount failure occurs. * mount failure occurs.
*/ */
mp->m_super->s_flags |= SB_ACTIVE; mp->m_super->s_flags |= SB_ACTIVE;
error = xlog_recover_finish(mp->m_log); if (log->l_flags & XLOG_RECOVERY_NEEDED)
error = xlog_recover_finish(log);
if (!error) if (!error)
xfs_log_work_queue(mp); xfs_log_work_queue(mp);
mp->m_super->s_flags &= ~SB_ACTIVE; mp->m_super->s_flags &= ~SB_ACTIVE;
...@@ -774,17 +775,24 @@ xfs_log_mount_finish( ...@@ -774,17 +775,24 @@ xfs_log_mount_finish(
* Don't push in the error case because the AIL may have pending intents * Don't push in the error case because the AIL may have pending intents
* that aren't removed until recovery is cancelled. * that aren't removed until recovery is cancelled.
*/ */
if (!error && recovered) { if (log->l_flags & XLOG_RECOVERY_NEEDED) {
if (!error) {
xfs_log_force(mp, XFS_LOG_SYNC); xfs_log_force(mp, XFS_LOG_SYNC);
xfs_ail_push_all_sync(mp->m_ail); xfs_ail_push_all_sync(mp->m_ail);
} }
xfs_notice(mp, "Ending recovery (logdev: %s)",
mp->m_logname ? mp->m_logname : "internal");
} else {
xfs_info(mp, "Ending clean mount");
}
xfs_buftarg_drain(mp->m_ddev_targp); xfs_buftarg_drain(mp->m_ddev_targp);
log->l_flags &= ~XLOG_RECOVERY_NEEDED;
if (readonly) if (readonly)
mp->m_flags |= XFS_MOUNT_RDONLY; mp->m_flags |= XFS_MOUNT_RDONLY;
/* Make sure the log is dead if we're returning failure. */ /* Make sure the log is dead if we're returning failure. */
ASSERT(!error || (mp->m_log->l_flags & XLOG_IO_ERROR)); ASSERT(!error || xlog_is_shutdown(log));
return error; return error;
} }
......
...@@ -3449,57 +3449,46 @@ xlog_recover( ...@@ -3449,57 +3449,46 @@ xlog_recover(
} }
/* /*
* In the first part of recovery we replay inodes and buffers and build * In the first part of recovery we replay inodes and buffers and build up the
* up the list of extent free items which need to be processed. Here * list of intents which need to be processed. Here we process the intents and
* we process the extent free items and clean up the on disk unlinked * clean up the on disk unlinked inode lists. This is separated from the first
* inode lists. This is separated from the first part of recovery so * part of recovery so that the root and real-time bitmap inodes can be read in
* that the root and real-time bitmap inodes can be read in from disk in * from disk in between the two stages. This is necessary so that we can free
* between the two stages. This is necessary so that we can free space * space in the real-time portion of the file system.
* in the real-time portion of the file system.
*/ */
int int
xlog_recover_finish( xlog_recover_finish(
struct xlog *log) struct xlog *log)
{ {
/*
* Now we're ready to do the transactions needed for the
* rest of recovery. Start with completing all the extent
* free intent records and then process the unlinked inode
* lists. At this point, we essentially run in normal mode
* except that we're still performing recovery actions
* rather than accepting new requests.
*/
if (log->l_flags & XLOG_RECOVERY_NEEDED) {
int error; int error;
error = xlog_recover_process_intents(log); error = xlog_recover_process_intents(log);
if (error) { if (error) {
/* /*
* Cancel all the unprocessed intent items now so that * Cancel all the unprocessed intent items now so that we don't
* we don't leave them pinned in the AIL. This can * leave them pinned in the AIL. This can cause the AIL to
* cause the AIL to livelock on the pinned item if * livelock on the pinned item if anyone tries to push the AIL
* anyone tries to push the AIL (inode reclaim does * (inode reclaim does this) before we get around to
* this) before we get around to xfs_log_mount_cancel. * xfs_log_mount_cancel.
*/ */
xlog_recover_cancel_intents(log); xlog_recover_cancel_intents(log);
xfs_force_shutdown(log->l_mp, SHUTDOWN_LOG_IO_ERROR);
xfs_alert(log->l_mp, "Failed to recover intents"); xfs_alert(log->l_mp, "Failed to recover intents");
xfs_force_shutdown(log->l_mp, SHUTDOWN_LOG_IO_ERROR);
return error; return error;
} }
/* /*
* Sync the log to get all the intents out of the AIL. * Sync the log to get all the intents out of the AIL. This isn't
* This isn't absolutely necessary, but it helps in * absolutely necessary, but it helps in case the unlink transactions
* case the unlink transactions would have problems * would have problems pushing the intents out of the way.
* pushing the intents out of the way.
*/ */
xfs_log_force(log->l_mp, XFS_LOG_SYNC); xfs_log_force(log->l_mp, XFS_LOG_SYNC);
/* /*
* Now that we've recovered the log and all the intents, we can * Now that we've recovered the log and all the intents, we can clear
* clear the log incompat feature bits in the superblock * the log incompat feature bits in the superblock because there's no
* because there's no longer anything to protect. We rely on * longer anything to protect. We rely on the AIL push to write out the
* the AIL push to write out the updated superblock after * updated superblock after everything else.
* everything else.
*/ */
if (xfs_clear_incompat_log_features(log->l_mp)) { if (xfs_clear_incompat_log_features(log->l_mp)) {
error = xfs_sync_sb(log->l_mp, false); error = xfs_sync_sb(log->l_mp, false);
...@@ -3511,16 +3500,7 @@ xlog_recover_finish( ...@@ -3511,16 +3500,7 @@ xlog_recover_finish(
} }
xlog_recover_process_iunlinks(log); xlog_recover_process_iunlinks(log);
xlog_recover_check_summary(log); xlog_recover_check_summary(log);
xfs_notice(log->l_mp, "Ending recovery (logdev: %s)",
log->l_mp->m_logname ? log->l_mp->m_logname
: "internal");
log->l_flags &= ~XLOG_RECOVERY_NEEDED;
} else {
xfs_info(log->l_mp, "Ending clean mount");
}
return 0; return 0;
} }
......
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