提交 6bbb9a25 编写于 作者: D Darrick J. Wong 提交者: Zheng Zengkai

xfs: force the log offline when log intent item recovery fails

mainline-inclusion
from mainline-v5.13-rc4
commit 4e6b8270
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4KIAO
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=4e6b8270c820c8c57a73f869799a0af2b56eff3e

-------------------------------------------------

If any part of log intent item recovery fails, we should shut down the
log immediately to stop the log from writing a clean unmount record to
disk, because the metadata is not consistent.  The inability to cancel a
dirty transaction catches most of these cases, but there are a few
things that have slipped through the cracks, such as ENOSPC from a
transaction allocation, or runtime errors that result in cancellation of
a non-dirty transaction.

This solves some weird behaviors reported by customers where a system
goes down, the first mount fails, the second succeeds, but then the fs
goes down later because of inconsistent metadata.
Signed-off-by: NDarrick J. Wong <djwong@kernel.org>
Reviewed-by: NChristoph Hellwig <hch@lst.de>
Signed-off-by: NGuo Xuenan <guoxuenan@huawei.com>
Reviewed-by: NLihong Kou <koulihong@huawei.com>
Reviewed-by: NZhang Yi <yi.zhang@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 365e8cb7
...@@ -729,6 +729,9 @@ xfs_log_mount_finish( ...@@ -729,6 +729,9 @@ xfs_log_mount_finish(
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. */
ASSERT(!error || (mp->m_log->l_flags & XLOG_IO_ERROR));
return error; return error;
} }
......
...@@ -2457,8 +2457,10 @@ xlog_finish_defer_ops( ...@@ -2457,8 +2457,10 @@ xlog_finish_defer_ops(
error = xfs_trans_alloc(mp, &resv, dfc->dfc_blkres, error = xfs_trans_alloc(mp, &resv, dfc->dfc_blkres,
dfc->dfc_rtxres, XFS_TRANS_RESERVE, &tp); dfc->dfc_rtxres, XFS_TRANS_RESERVE, &tp);
if (error) if (error) {
xfs_force_shutdown(mp, SHUTDOWN_LOG_IO_ERROR);
return error; return error;
}
/* /*
* Transfer to this new transaction all the dfops we captured * Transfer to this new transaction all the dfops we captured
...@@ -3454,6 +3456,7 @@ xlog_recover_finish( ...@@ -3454,6 +3456,7 @@ xlog_recover_finish(
* this) before we get around to xfs_log_mount_cancel. * this) before we get around to 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");
return error; return error;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册