aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorBrian Foster <bfoster@redhat.com>2016-01-03 23:55:10 -0500
committerDave Chinner <david@fromorbit.com>2016-01-03 23:55:10 -0500
commit6528250b712102a7481c28db535ef251459d1868 (patch)
treefdde13830aafdc7d039fb70883b4a504c3bab60e /fs/xfs
parentd7f37692e38798797d415153bc186afb2bbac645 (diff)
xfs: support a crc verification only log record pass
Log recovery torn write detection uses CRC verification over a range of the active log to identify torn writes. Since the generic log recovery pass code implements a superset of the functionality required for CRC verification, it can be easily modified to support a CRC verification only pass. Create a new CRC pass type and update the log record processing helper to skip everything beyond CRC verification when in this mode. This pass will be invoked in subsequent patches to implement torn write detection. Signed-off-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/libxfs/xfs_log_recover.h1
-rw-r--r--fs/xfs/xfs_log_recover.c24
2 files changed, 20 insertions, 5 deletions
diff --git a/fs/xfs/libxfs/xfs_log_recover.h b/fs/xfs/libxfs/xfs_log_recover.h
index 1c55ccbb379d..8e385f91d660 100644
--- a/fs/xfs/libxfs/xfs_log_recover.h
+++ b/fs/xfs/libxfs/xfs_log_recover.h
@@ -60,6 +60,7 @@ typedef struct xlog_recover {
60 */ 60 */
61#define XLOG_BC_TABLE_SIZE 64 61#define XLOG_BC_TABLE_SIZE 64
62 62
63#define XLOG_RECOVER_CRCPASS 0
63#define XLOG_RECOVER_PASS1 1 64#define XLOG_RECOVER_PASS1 1
64#define XLOG_RECOVER_PASS2 2 65#define XLOG_RECOVER_PASS2 2
65 66
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index e0318e8a0771..1be259044096 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -4159,13 +4159,27 @@ xlog_recover_process(
4159 int error; 4159 int error;
4160 __le32 crc; 4160 __le32 crc;
4161 4161
4162 crc = xlog_cksum(log, rhead, dp, be32_to_cpu(rhead->h_len));
4163
4162 /* 4164 /*
4163 * Check the CRC and issue a warning if and only if the CRC in the 4165 * Nothing else to do if this is a CRC verification pass. Just return
4164 * header is non-zero. This is an advisory warning and the zero CRC 4166 * if this a record with a non-zero crc. Unfortunately, mkfs always
4165 * check prevents warnings from being emitted when upgrading the kernel 4167 * sets h_crc to 0 so we must consider this valid even on v5 supers.
4166 * from one that does not add CRCs by default. 4168 * Otherwise, return EFSBADCRC on failure so the callers up the stack
4169 * know precisely what failed.
4170 */
4171 if (pass == XLOG_RECOVER_CRCPASS) {
4172 if (rhead->h_crc && crc != le32_to_cpu(rhead->h_crc))
4173 return -EFSBADCRC;
4174 return 0;
4175 }
4176
4177 /*
4178 * We're in the normal recovery path. Issue a warning if and only if the
4179 * CRC in the header is non-zero. This is an advisory warning and the
4180 * zero CRC check prevents warnings from being emitted when upgrading
4181 * the kernel from one that does not add CRCs by default.
4167 */ 4182 */
4168 crc = xlog_cksum(log, rhead, dp, be32_to_cpu(rhead->h_len));
4169 if (crc != le32_to_cpu(rhead->h_crc)) { 4183 if (crc != le32_to_cpu(rhead->h_crc)) {
4170 if (rhead->h_crc || xfs_sb_version_hascrc(&log->l_mp->m_sb)) { 4184 if (rhead->h_crc || xfs_sb_version_hascrc(&log->l_mp->m_sb)) {
4171 xfs_alert(log->l_mp, 4185 xfs_alert(log->l_mp,