ocfs2: block read meta ecc.
authorJoel Becker <joel.becker@oracle.com>
Fri, 17 Oct 2008 21:55:01 +0000 (14:55 -0700)
committerMark Fasheh <mfasheh@suse.com>
Mon, 5 Jan 2009 16:40:31 +0000 (08:40 -0800)
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
fs/ocfs2/blockcheck.c
fs/ocfs2/inode.c
fs/ocfs2/quota_global.c
fs/ocfs2/suballoc.c
fs/ocfs2/xattr.c

index 84a7bd4db5da86d83ed55588c3e518df493d3e35..6b27f74bb346baa6bb665f10eb09082728f78cd9 100644 (file)
@@ -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",
index 2bf3d7f61aec68e99c64ac85f03cb95b8bca6d35..2ce6ae5e4b8ccdd9ff69bcfc3d00aa6ccfa8cd8a 100644 (file)
@@ -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:
index 288512c9dbc27fc87c94aaf3ee4fa374e1b504cc..9370b652ab9461776adf620ad6b938eb78842902 100644 (file)
@@ -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,
index 7dbcfd7f65e611e065a9b7e06e6d566582f8814c..a0b8b14cca8f36358b1a6ff039c7b5752b966239 100644 (file)
@@ -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"
@@ -90,12 +91,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,
index 226fe21f2608f9f5efe52d50a345410b3493fbc4..78755766c3299ae9a79252d06b8921de526713c3 100644 (file)
@@ -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);
 }
 
index dfc51c305bb9e83bc8d12a2a3e3985745277f2ad..bc822d6ba5420def312f496c04ed10fccf6c19b7 100644 (file)
@@ -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 "
This page took 0.031853 seconds and 5 git commands to generate.