Skip to content

Commit 5652ef3

Browse files
dgchinnerDarrick J. Wong
authored andcommitted
xfs: shutdown during log recovery needs to mark the log shutdown
When a checkpoint writeback is run by log recovery, corruption propagated from the log can result in writeback verifiers failing and calling xfs_force_shutdown() from xfs_buf_delwri_submit_buffers(). This results in the mount being marked as shutdown, but the log does not get marked as shut down because: /* * If this happens during log recovery then we aren't using the runtime * log mechanisms yet so there's nothing to shut down. */ if (!log || xlog_in_recovery(log)) return false; If there are other buffers that then fail (say due to detecting the mount shutdown), they will now hang in xfs_do_force_shutdown() waiting for the log to shut down like this: __schedule+0x30d/0x9e0 schedule+0x55/0xd0 xfs_do_force_shutdown+0x1cd/0x200 ? init_wait_var_entry+0x50/0x50 xfs_buf_ioend+0x47e/0x530 __xfs_buf_submit+0xb0/0x240 xfs_buf_delwri_submit_buffers+0xfe/0x270 xfs_buf_delwri_submit+0x3a/0xc0 xlog_do_recovery_pass+0x474/0x7b0 ? do_raw_spin_unlock+0x30/0xb0 xlog_do_log_recovery+0x91/0x140 xlog_do_recover+0x38/0x1e0 xlog_recover+0xdd/0x170 xfs_log_mount+0x17e/0x2e0 xfs_mountfs+0x457/0x930 xfs_fs_fill_super+0x476/0x830 xlog_force_shutdown() always needs to mark the log as shut down, regardless of whether recovery is in progress or not, so that multiple calls to xfs_force_shutdown() during recovery don't end up waiting for the log to be shut down like this. Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
1 parent 3c4cb76 commit 5652ef3

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

fs/xfs/xfs_log.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3847,11 +3847,7 @@ xlog_force_shutdown(
38473847
{
38483848
bool log_error = (shutdown_flags & SHUTDOWN_LOG_IO_ERROR);
38493849

3850-
/*
3851-
* If this happens during log recovery then we aren't using the runtime
3852-
* log mechanisms yet so there's nothing to shut down.
3853-
*/
3854-
if (!log || xlog_in_recovery(log))
3850+
if (!log)
38553851
return false;
38563852

38573853
/*
@@ -3860,10 +3856,16 @@ xlog_force_shutdown(
38603856
* before the force will prevent the log force from flushing the iclogs
38613857
* to disk.
38623858
*
3863-
* Re-entry due to a log IO error shutdown during the log force is
3864-
* prevented by the atomicity of higher level shutdown code.
3859+
* When we are in recovery, there are no transactions to flush, and
3860+
* we don't want to touch the log because we don't want to perturb the
3861+
* current head/tail for future recovery attempts. Hence we need to
3862+
* avoid a log force in this case.
3863+
*
3864+
* If we are shutting down due to a log IO error, then we must avoid
3865+
* trying to write the log as that may just result in more IO errors and
3866+
* an endless shutdown/force loop.
38653867
*/
3866-
if (!log_error)
3868+
if (!log_error && !xlog_in_recovery(log))
38673869
xfs_log_force(log->l_mp, XFS_LOG_SYNC);
38683870

38693871
/*

0 commit comments

Comments
 (0)