aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/alloc.c
diff options
context:
space:
mode:
authorJoel Becker <joel.becker@oracle.com>2008-11-13 17:49:19 -0500
committerMark Fasheh <mfasheh@suse.com>2009-01-05 11:36:53 -0500
commit970e4936d7d15f35d00fd15a14f5343ba78b2fc8 (patch)
tree92057c7deab6b9d8e5c3889d6a354b5989a3b68d /fs/ocfs2/alloc.c
parent4ae1d69bedc8d174cb8a558694607e013157cde1 (diff)
ocfs2: Validate metadata only when it's read from disk.
Add an optional validation hook to ocfs2_read_blocks(). Now the validation function is only called when a block was actually read off of disk. It is not called when the buffer was in cache. We add a buffer state bit BH_NeedsValidate to flag these buffers. It must always be one higher than the last JBD2 buffer state bit. The dinode, dirblock, extent_block, and xattr_block validators are lifted to this scheme directly. The group_descriptor validator needs to be split into two pieces. The first part only needs the gd buffer and is passed to ocfs2_read_block(). The second part requires the dinode as well, and is called every time. It's only 3 compares, so it's tiny. This also allows us to clean up the non-fatal gd check used by resize.c. It now has no magic argument. Signed-off-by: Joel Becker <joel.becker@oracle.com> Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs/ocfs2/alloc.c')
-rw-r--r--fs/ocfs2/alloc.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index f430cc6e0f35..e823a27ba340 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -684,6 +684,9 @@ static int ocfs2_validate_extent_block(struct super_block *sb,
684 struct ocfs2_extent_block *eb = 684 struct ocfs2_extent_block *eb =
685 (struct ocfs2_extent_block *)bh->b_data; 685 (struct ocfs2_extent_block *)bh->b_data;
686 686
687 mlog(0, "Validating extent block %llu\n",
688 (unsigned long long)bh->b_blocknr);
689
687 if (!OCFS2_IS_VALID_EXTENT_BLOCK(eb)) { 690 if (!OCFS2_IS_VALID_EXTENT_BLOCK(eb)) {
688 ocfs2_error(sb, 691 ocfs2_error(sb,
689 "Extent block #%llu has bad signature %.*s", 692 "Extent block #%llu has bad signature %.*s",
@@ -719,21 +722,13 @@ int ocfs2_read_extent_block(struct inode *inode, u64 eb_blkno,
719 int rc; 722 int rc;
720 struct buffer_head *tmp = *bh; 723 struct buffer_head *tmp = *bh;
721 724
722 rc = ocfs2_read_block(inode, eb_blkno, &tmp); 725 rc = ocfs2_read_block(inode, eb_blkno, &tmp,
723 if (rc) 726 ocfs2_validate_extent_block);
724 goto out;
725
726 rc = ocfs2_validate_extent_block(inode->i_sb, tmp);
727 if (rc) {
728 brelse(tmp);
729 goto out;
730 }
731 727
732 /* If ocfs2_read_block() got us a new bh, pass it up. */ 728 /* If ocfs2_read_block() got us a new bh, pass it up. */
733 if (!*bh) 729 if (!rc && !*bh)
734 *bh = tmp; 730 *bh = tmp;
735 731
736out:
737 return rc; 732 return rc;
738} 733}
739 734