mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mark Fasheh <mfasheh@suse.com>
To: linux-kernel@vger.kernel.org
Cc: ocfs2-devel@oss.oracle.com, Joel Becker <joel.becker@oracle.com>,
	Mark Fasheh <mfasheh@suse.com>
Subject: [PATCH 05/35] ocfs2: block read meta ecc.
Date: Thu, 25 Dec 2008 10:04:20 -0800	[thread overview]
Message-ID: <1230228290-22803-6-git-send-email-mfasheh@suse.com> (raw)
In-Reply-To: <1230228290-22803-1-git-send-email-mfasheh@suse.com>

From: Joel Becker <joel.becker@oracle.com>

Add block check calls to the read_block validate functions.  This is the
almost all of the read-side checking of metaecc.  xattr buckets are not checked
yet.   Writes are also unchecked, and so a read-write mount will quickly fail.

Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
---
 fs/ocfs2/alloc.c        |   17 +++++++++++++++++
 fs/ocfs2/blockcheck.c   |    9 +++++++++
 fs/ocfs2/inode.c        |   18 +++++++++++++++++-
 fs/ocfs2/quota_global.c |   13 +++++++++++--
 fs/ocfs2/suballoc.c     |   31 ++++++++++++++++++++++++++++++-
 fs/ocfs2/xattr.c        |   17 +++++++++++++++++
 6 files changed, 101 insertions(+), 4 deletions(-)

diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index 84a7bd4..6b27f74 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -37,6 +37,7 @@
 
 #include "alloc.h"
 #include "aops.h"
+#include "blockcheck.h"
 #include "dlmglue.h"
 #include "extent_map.h"
 #include "inode.h"
@@ -682,12 +683,28 @@ struct ocfs2_merge_ctxt {
 static int ocfs2_validate_extent_block(struct super_block *sb,
 				       struct buffer_head *bh)
 {
+	int rc;
 	struct ocfs2_extent_block *eb =
 		(struct ocfs2_extent_block *)bh->b_data;
 
 	mlog(0, "Validating extent block %llu\n",
 	     (unsigned long long)bh->b_blocknr);
 
+	BUG_ON(!buffer_uptodate(bh));
+
+	/*
+	 * If the ecc fails, we return the error but otherwise
+	 * leave the filesystem running.  We know any error is
+	 * local to this block.
+	 */
+	rc = ocfs2_validate_meta_ecc(sb, bh->b_data, &eb->h_check);
+	if (rc)
+		return rc;
+
+	/*
+	 * Errors after here are fatal.
+	 */
+
 	if (!OCFS2_IS_VALID_EXTENT_BLOCK(eb)) {
 		ocfs2_error(sb,
 			    "Extent block #%llu has bad signature %.*s",
diff --git a/fs/ocfs2/blockcheck.c b/fs/ocfs2/blockcheck.c
index 2bf3d7f..2ce6ae5 100644
--- a/fs/ocfs2/blockcheck.c
+++ b/fs/ocfs2/blockcheck.c
@@ -24,6 +24,8 @@
 #include <linux/bitops.h>
 #include <asm/byteorder.h>
 
+#include <cluster/masklog.h>
+
 #include "ocfs2.h"
 
 #include "blockcheck.h"
@@ -292,6 +294,10 @@ int ocfs2_block_check_validate(void *data, size_t blocksize,
 	if (crc == check.bc_crc32e)
 		goto out;
 
+	mlog(ML_ERROR,
+	     "CRC32 failed: stored: %u, computed %u.  Applying ECC.\n",
+	     (unsigned int)check.bc_crc32e, (unsigned int)crc);
+
 	/* Ok, try ECC fixups */
 	ecc = ocfs2_hamming_encode_block(data, blocksize);
 	ocfs2_hamming_fix_block(data, blocksize, ecc ^ check.bc_ecc);
@@ -301,6 +307,9 @@ int ocfs2_block_check_validate(void *data, size_t blocksize,
 	if (crc == check.bc_crc32e)
 		goto out;
 
+	mlog(ML_ERROR, "Fixed CRC32 failed: stored: %u, computed %u\n",
+	     (unsigned int)check.bc_crc32e, (unsigned int)crc);
+
 	rc = -EIO;
 
 out:
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index 288512c..9370b65 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -38,6 +38,7 @@
 #include "ocfs2.h"
 
 #include "alloc.h"
+#include "blockcheck.h"
 #include "dlmglue.h"
 #include "extent_map.h"
 #include "file.h"
@@ -1262,7 +1263,7 @@ void ocfs2_refresh_inode(struct inode *inode,
 int ocfs2_validate_inode_block(struct super_block *sb,
 			       struct buffer_head *bh)
 {
-	int rc = -EINVAL;
+	int rc;
 	struct ocfs2_dinode *di = (struct ocfs2_dinode *)bh->b_data;
 
 	mlog(0, "Validating dinode %llu\n",
@@ -1270,6 +1271,21 @@ int ocfs2_validate_inode_block(struct super_block *sb,
 
 	BUG_ON(!buffer_uptodate(bh));
 
+	/*
+	 * If the ecc fails, we return the error but otherwise
+	 * leave the filesystem running.  We know any error is
+	 * local to this block.
+	 */
+	rc = ocfs2_validate_meta_ecc(sb, bh->b_data, &di->i_check);
+	if (rc)
+		goto bail;
+
+	/*
+	 * Errors after here are fatal.
+	 */
+
+	rc = -EINVAL;
+
 	if (!OCFS2_IS_VALID_DINODE(di)) {
 		ocfs2_error(sb, "Invalid dinode #%llu: signature = %.*s\n",
 			    (unsigned long long)bh->b_blocknr, 7,
diff --git a/fs/ocfs2/quota_global.c b/fs/ocfs2/quota_global.c
index 5b05f94..d338438 100644
--- a/fs/ocfs2/quota_global.c
+++ b/fs/ocfs2/quota_global.c
@@ -16,6 +16,7 @@
 #include "ocfs2_fs.h"
 #include "ocfs2.h"
 #include "alloc.h"
+#include "blockcheck.h"
 #include "inode.h"
 #include "journal.h"
 #include "file.h"
@@ -88,12 +89,20 @@ struct qtree_fmt_operations ocfs2_global_ops = {
 static int ocfs2_validate_quota_block(struct super_block *sb,
 				      struct buffer_head *bh)
 {
-	struct ocfs2_disk_dqtrailer *dqt = ocfs2_dq_trailer(sb, bh->b_data);
+	struct ocfs2_disk_dqtrailer *dqt =
+		ocfs2_block_dqtrailer(sb->s_blocksize, bh->b_data);
 
 	mlog(0, "Validating quota block %llu\n",
 	     (unsigned long long)bh->b_blocknr);
 
-	return 0;
+	BUG_ON(!buffer_uptodate(bh));
+
+	/*
+	 * If the ecc fails, we return the error but otherwise
+	 * leave the filesystem running.  We know any error is
+	 * local to this block.
+	 */
+	return ocfs2_validate_meta_ecc(sb, bh->b_data, &dqt->dq_check);
 }
 
 int ocfs2_read_quota_block(struct inode *inode, u64 v_block,
diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
index 226fe21..7875576 100644
--- a/fs/ocfs2/suballoc.c
+++ b/fs/ocfs2/suballoc.c
@@ -35,6 +35,7 @@
 #include "ocfs2.h"
 
 #include "alloc.h"
+#include "blockcheck.h"
 #include "dlmglue.h"
 #include "inode.h"
 #include "journal.h"
@@ -250,8 +251,18 @@ int ocfs2_check_group_descriptor(struct super_block *sb,
 				 struct buffer_head *bh)
 {
 	int rc;
+	struct ocfs2_group_desc *gd = (struct ocfs2_group_desc *)bh->b_data;
+
+	BUG_ON(!buffer_uptodate(bh));
 
-	rc = ocfs2_validate_gd_self(sb, bh, 1);
+	/*
+	 * If the ecc fails, we return the error but otherwise
+	 * leave the filesystem running.  We know any error is
+	 * local to this block.
+	 */
+	rc = ocfs2_validate_meta_ecc(sb, bh->b_data, &gd->bg_check);
+	if (!rc)
+		rc = ocfs2_validate_gd_self(sb, bh, 1);
 	if (!rc)
 		rc = ocfs2_validate_gd_parent(sb, di, bh, 1);
 
@@ -261,9 +272,27 @@ int ocfs2_check_group_descriptor(struct super_block *sb,
 static int ocfs2_validate_group_descriptor(struct super_block *sb,
 					   struct buffer_head *bh)
 {
+	int rc;
+	struct ocfs2_group_desc *gd = (struct ocfs2_group_desc *)bh->b_data;
+
 	mlog(0, "Validating group descriptor %llu\n",
 	     (unsigned long long)bh->b_blocknr);
 
+	BUG_ON(!buffer_uptodate(bh));
+
+	/*
+	 * If the ecc fails, we return the error but otherwise
+	 * leave the filesystem running.  We know any error is
+	 * local to this block.
+	 */
+	rc = ocfs2_validate_meta_ecc(sb, bh->b_data, &gd->bg_check);
+	if (rc)
+		return rc;
+
+	/*
+	 * Errors after here are fatal.
+	 */
+
 	return ocfs2_validate_gd_self(sb, bh, 0);
 }
 
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index dfc51c3..bc822d6 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -42,6 +42,7 @@
 
 #include "ocfs2.h"
 #include "alloc.h"
+#include "blockcheck.h"
 #include "dlmglue.h"
 #include "file.h"
 #include "symlink.h"
@@ -322,12 +323,28 @@ static void ocfs2_xattr_bucket_copy_data(struct ocfs2_xattr_bucket *dest,
 static int ocfs2_validate_xattr_block(struct super_block *sb,
 				      struct buffer_head *bh)
 {
+	int rc;
 	struct ocfs2_xattr_block *xb =
 		(struct ocfs2_xattr_block *)bh->b_data;
 
 	mlog(0, "Validating xattr block %llu\n",
 	     (unsigned long long)bh->b_blocknr);
 
+	BUG_ON(!buffer_uptodate(bh));
+
+	/*
+	 * If the ecc fails, we return the error but otherwise
+	 * leave the filesystem running.  We know any error is
+	 * local to this block.
+	 */
+	rc = ocfs2_validate_meta_ecc(sb, bh->b_data, &xb->xb_check);
+	if (rc)
+		return rc;
+
+	/*
+	 * Errors after here are fatal
+	 */
+
 	if (!OCFS2_IS_VALID_XATTR_BLOCK(xb)) {
 		ocfs2_error(sb,
 			    "Extended attribute block #%llu has bad "
-- 
1.5.6


  parent reply	other threads:[~2008-12-25 18:06 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-25 18:04 [git patches] Ocfs2 patches for merge window, batch 3/3 Mark Fasheh
2008-12-25 18:04 ` [PATCH 01/35] jbd2: Add buffer triggers Mark Fasheh
2008-12-31 18:16   ` [Ocfs2-devel] " Mark Fasheh
2008-12-25 18:04 ` [PATCH 02/35] ocfs2: Add the on-disk structures for metadata checksums Mark Fasheh
2008-12-25 18:04 ` [PATCH 03/35] ocfs2: Add the underlying blockcheck code Mark Fasheh
2008-12-25 18:04 ` [PATCH 04/35] ocfs2: Add a validation hook for quota block reads Mark Fasheh
2008-12-25 18:04 ` Mark Fasheh [this message]
2008-12-25 18:04 ` [PATCH 06/35] ocfs2: Add journal_access functions with jbd2 triggers Mark Fasheh
2008-12-25 18:04 ` [PATCH 07/35] ocfs2: Wrap up the common use cases of ocfs2_new_path() Mark Fasheh
2008-12-25 18:04 ` [PATCH 08/35] ocfs2: Use metadata-specific ocfs2_journal_access_*() functions Mark Fasheh
2008-12-25 18:04 ` [PATCH 09/35] ocfs2: Add ecc and checksums to ocfs2 xattr buckets Mark Fasheh
2008-12-25 18:04 ` [PATCH 10/35] ocfs2: Create ocfs2_xattr_value_buf Mark Fasheh
2008-12-25 18:04 ` [PATCH 11/35] ocfs2: Pull ocfs2_xattr_value_buf up from __ocfs2_remove_xattr_range() Mark Fasheh
2008-12-25 18:04 ` [PATCH 12/35] ocfs2: Pull ocfs2_xattr_value_buf up into ocfs2_xattr_value_truncate() Mark Fasheh
2008-12-25 18:04 ` [PATCH 13/35] ocfs2: Pass ocfs2_xattr_value_buf " Mark Fasheh
2008-12-25 18:04 ` [PATCH 14/35] ocfs2: Pass value buf to ocfs2_xattr_update_entry() Mark Fasheh
2008-12-25 18:04 ` [PATCH 15/35] ocfs2: Use ocfs2_xattr_value_buf in ocfs2_xattr_set_entry() Mark Fasheh
2008-12-25 18:04 ` [PATCH 16/35] ocfs2: Pass value buf to ocfs2_remove_value_outside() Mark Fasheh
2008-12-25 18:04 ` [PATCH 17/35] ocfs2: Use proper journal_access function in xattr.c Mark Fasheh
2008-12-25 18:04 ` [PATCH 18/35] ocfs2: Add directory block trailers Mark Fasheh
2008-12-25 18:04 ` [PATCH 19/35] ocfs2: Checksum and ECC for directory blocks Mark Fasheh
2008-12-25 18:04 ` [PATCH 20/35] ocfs2: Validate superblock with checksum and ecc Mark Fasheh
2008-12-25 18:04 ` [PATCH 21/35] ocfs2: Enable metadata checksums Mark Fasheh
2008-12-25 18:04 ` [PATCH 22/35] ocfs2: Don't hand-code xor in ocfs2_hamming_encode() Mark Fasheh
2008-12-25 18:04 ` [PATCH 23/35] ocfs2: Another hamming code optimization Mark Fasheh
2008-12-25 18:04 ` [PATCH 24/35] ocfs2: One more " Mark Fasheh
2008-12-25 18:04 ` [PATCH 25/35] ocfs2/dlm: Fix a race between migrate request and exit domain Mark Fasheh
2008-12-25 18:04 ` [PATCH 26/35] ocfs2/dlm: Clean up errors in dlm_proxy_ast_handler() Mark Fasheh
2008-12-25 18:04 ` [PATCH 27/35] ocfs2/dlm: Hold off sending lockres drop ref message while lockres is migrating Mark Fasheh
2008-12-25 18:04 ` [PATCH 28/35] ocfs2/dlm: Fix race in adding/removing lockres' to/from the tracking list Mark Fasheh
2008-12-25 18:04 ` [PATCH 29/35] ocfs2/dlm: Fix race during lockres mastery Mark Fasheh
2008-12-25 18:04 ` [PATCH 30/35] ocfs2/xattr: Remove extend_trans call and add its credits from the beginning Mark Fasheh
2008-12-25 18:04 ` [PATCH 31/35] ocfs2/xattr: Always updating ctime during xattr set Mark Fasheh
2008-12-25 18:04 ` [PATCH 32/35] ocfs2/xattr: fix credits calculation during index create Mark Fasheh
2008-12-25 18:04 ` [PATCH 33/35] ocfs2: calculate and reserve credits for xattr value in mknod Mark Fasheh
2008-12-25 18:04 ` [PATCH 34/35] ocfs2: alloc xattr bucket in ocfs2_xattr_set_handle Mark Fasheh
2008-12-25 18:04 ` [PATCH 35/35] ocfs2: Add xattr support checking in init_security Mark Fasheh

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=1230228290-22803-6-git-send-email-mfasheh@suse.com \
    --to=mfasheh@suse.com \
    --cc=joel.becker@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ocfs2-devel@oss.oracle.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

all inboxes | Powered by JetHome®