>From 7d1c4c0ee7f8b6734d41d857b7c8dd94e6b55b4e Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Fri, 27 Jun 2014 23:27:11 +0200 Subject: [PATCH] xfs: Fix CRC errors after unclean umount After unclean shutdown and log recovery filesystem checker reports CRC errors in AGI or AGF blocks. The problem is that we don't properly set buffer verifiers when replay of some log item is skipped because the lsn of the transaction is less than or equal to lsn stored in the corresponding AGI / AGF. Thus next time the AGI / AGF buffer is modified (e.g. during unlinked inode removal) it is written to disk without updating the CRC and lsn. Fix the problem by setting proper buffer verifiers even if we skip replay of the log item. Signed-off-by: Jan Kara --- fs/xfs/xfs_log_recover.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index 981af0f6504b..feb9330962f1 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c @@ -2508,8 +2508,15 @@ xlog_recover_buffer_pass2( * the lsn of the transaction we are replaying. */ lsn = xlog_recover_get_buf_lsn(mp, bp); - if (lsn && lsn != -1 && XFS_LSN_CMP(lsn, current_lsn) >= 0) + if (lsn && lsn != -1 && XFS_LSN_CMP(lsn, current_lsn) >= 0) { + if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (buf_f->blf_flags & XFS_BLF_INODE_BUF) + bp->b_ops = &xfs_inode_buf_ops; + else + xlog_recover_validate_buf_type(mp, bp, buf_f); + } goto out_release; + } if (buf_f->blf_flags & XFS_BLF_INODE_BUF) { error = xlog_recover_do_inode_buffer(mp, item, bp, buf_f); -- 1.8.1.4