From: Brian Foster <bfoster@redhat.com>
To: xfs@oss.sgi.com
Subject: [PATCH 3/8] xfs: refactor and open code log record crc check
Date: Mon, 9 Nov 2015 15:21:10 -0500 [thread overview]
Message-ID: <1447100475-33465-4-git-send-email-bfoster@redhat.com> (raw)
In-Reply-To: <1447100475-33465-1-git-send-email-bfoster@redhat.com>
Log record CRC verification currently occurs during active log recovery,
immediately before a log record is unpacked. Therefore, the CRC
calculation code is buried within the data unpack function. CRC
verification pass support only needs to go so far as check the CRC, but
this is not easily allowed as the code is currently organized.
Since we now have a new log record processing helper, pull the record
CRC verification code out from the unpack helper and open-code it at the
top of the new process helper. This facilitates the ability to modify
how records are processed based on the type of the current pass. This
patch contains no functional changes.
Signed-off-by: Brian Foster <bfoster@redhat.com>
---
fs/xfs/xfs_log_recover.c | 72 +++++++++++++++++-------------------------------
1 file changed, 26 insertions(+), 46 deletions(-)
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index a15a506..c2bf307 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -4118,46 +4118,6 @@ xlog_recover_process_iunlinks(
mp->m_dmevmask = mp_dmevmask;
}
-/*
- * Upack the log buffer data and crc check it. If the check fails, issue a
- * warning if and only if the CRC in the header is non-zero. This makes the
- * check an advisory warning, and the zero CRC check will prevent failure
- * warnings from being emitted when upgrading the kernel from one that does not
- * add CRCs by default.
- *
- * When filesystems are CRC enabled, this CRC mismatch becomes a fatal log
- * corruption failure
- */
-STATIC int
-xlog_unpack_data_crc(
- struct xlog_rec_header *rhead,
- char *dp,
- struct xlog *log)
-{
- __le32 crc;
-
- crc = xlog_cksum(log, rhead, dp, be32_to_cpu(rhead->h_len));
- if (crc != rhead->h_crc) {
- if (rhead->h_crc || xfs_sb_version_hascrc(&log->l_mp->m_sb)) {
- xfs_alert(log->l_mp,
- "log record CRC mismatch: found 0x%x, expected 0x%x.",
- le32_to_cpu(rhead->h_crc),
- le32_to_cpu(crc));
- xfs_hex_dump(dp, 32);
- }
-
- /*
- * If we've detected a log record corruption, then we can't
- * recover past this point. Abort recovery if we are enforcing
- * CRC protection by punting an error back up the stack.
- */
- if (xfs_sb_version_hascrc(&log->l_mp->m_sb))
- return -EFSCORRUPTED;
- }
-
- return 0;
-}
-
STATIC int
xlog_unpack_data(
struct xlog_rec_header *rhead,
@@ -4165,11 +4125,6 @@ xlog_unpack_data(
struct xlog *log)
{
int i, j, k;
- int error;
-
- error = xlog_unpack_data_crc(rhead, dp, log);
- if (error)
- return error;
for (i = 0; i < BTOBB(be32_to_cpu(rhead->h_len)) &&
i < (XLOG_HEADER_CYCLE_SIZE / BBSIZE); i++) {
@@ -4191,7 +4146,7 @@ xlog_unpack_data(
}
/*
- * Unpack and process a log record.
+ * CRC check, unpack and process a log record.
*/
STATIC int
xlog_recover_process(
@@ -4202,6 +4157,31 @@ xlog_recover_process(
int pass)
{
int error;
+ __le32 crc;
+
+ /*
+ * 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.
+ */
+ 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,
+ "log record CRC mismatch: found 0x%x, expected 0x%x.",
+ le32_to_cpu(rhead->h_crc),
+ le32_to_cpu(crc));
+ xfs_hex_dump(dp, 32);
+ }
+
+ /*
+ * If the filesystem is CRC enabled, this mismatch becomes a
+ * fatal log corruption failure.
+ */
+ if (xfs_sb_version_hascrc(&log->l_mp->m_sb))
+ return -EFSCORRUPTED;
+ }
error = xlog_unpack_data(rhead, dp, log);
if (error)
--
2.1.0
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2015-11-09 20:21 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-09 20:21 [PATCH 0/8] xfs: log recovery torn write detection Brian Foster
2015-11-09 20:21 ` [PATCH 1/8] xfs: detect and handle invalid iclog size set by mkfs Brian Foster
2015-11-09 20:21 ` [PATCH 2/8] xfs: refactor log record unpack and data processing Brian Foster
2015-11-09 20:21 ` Brian Foster [this message]
2015-11-09 20:21 ` [PATCH 4/8] xfs: return start block of first bad log record during recovery Brian Foster
2015-11-10 15:42 ` Brian Foster
2015-11-09 20:21 ` [PATCH 5/8] xfs: support a crc verification only log record pass Brian Foster
2015-11-09 20:21 ` [PATCH 6/8] xfs: refactor log record start detection into a new helper Brian Foster
2015-11-09 20:21 ` [PATCH 7/8] xfs: detect and trim torn writes during log recovery Brian Foster
2015-11-10 13:45 ` Brian Foster
2015-11-09 20:21 ` [PATCH RFC 8/8] xfs: debug mode log recovery crc error injection Brian Foster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1447100475-33465-4-git-send-email-bfoster@redhat.com \
--to=bfoster@redhat.com \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox