Skip to content

Commit

Permalink
xfs: support a crc verification only log record pass
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Brian Foster authored and Dave Chinner committed Jan 4, 2016
1 parent d7f3769 commit 6528250
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions fs/xfs/libxfs/xfs_log_recover.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ typedef struct xlog_recover {
*/
#define XLOG_BC_TABLE_SIZE 64

#define XLOG_RECOVER_CRCPASS 0
#define XLOG_RECOVER_PASS1 1
#define XLOG_RECOVER_PASS2 2

Expand Down
24 changes: 19 additions & 5 deletions fs/xfs/xfs_log_recover.c
Original file line number Diff line number Diff line change
Expand Up @@ -4159,13 +4159,27 @@ xlog_recover_process(
int error;
__le32 crc;

crc = xlog_cksum(log, rhead, dp, be32_to_cpu(rhead->h_len));

/*
* Check the CRC and issue a warning if and only if the CRC in the
* header is non-zero. This is an advisory warning and the zero CRC
* check prevents warnings from being emitted when upgrading the kernel
* from one that does not add CRCs by default.
* Nothing else to do if this is a CRC verification pass. Just return
* if this a record with a non-zero crc. Unfortunately, mkfs always
* sets h_crc to 0 so we must consider this valid even on v5 supers.
* Otherwise, return EFSBADCRC on failure so the callers up the stack
* know precisely what failed.
*/
if (pass == XLOG_RECOVER_CRCPASS) {
if (rhead->h_crc && crc != le32_to_cpu(rhead->h_crc))
return -EFSBADCRC;
return 0;
}

/*
* We're in the normal recovery path. Issue a warning if and only if the
* CRC in the header is non-zero. This is an advisory warning and the
* zero CRC check prevents warnings from being emitted when upgrading
* the kernel from one that does not add CRCs by default.
*/
crc = xlog_cksum(log, rhead, dp, be32_to_cpu(rhead->h_len));
if (crc != le32_to_cpu(rhead->h_crc)) {
if (rhead->h_crc || xfs_sb_version_hascrc(&log->l_mp->m_sb)) {
xfs_alert(log->l_mp,
Expand Down

0 comments on commit 6528250

Please sign in to comment.