Re: [PATCH] ext4: add block bitmap validation
From: Andreas Dilger <hidden>
Date: 2007-11-21 21:43:29
On Nov 19, 2007 20:26 +0530, Aneesh Kumar K.V wrote:
+static int ext4_valid_block_bitmap(struct super_block *sb,
+ struct ext4_group_desc *desc,
+ unsigned int block_group,
+ struct buffer_head *bh)
+{
+ if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FLEX_BG)) {
+ /* with FLEX_BG, the inode/block bitmaps and itable
+ * blocks may not be in the group at all
+ * so the bitmap validation will be skipped for those groups
+ * or it has to also read the block group where the bitmaps
+ * are located to verify they are set.
+ */
+ return 1;
+ }Rather than skipping the bitmap check entirely when FLEX_BG is enabled, it is probably better to just validate whether each of the bitmap/itable offsets are within the bitmap being read, like: offset = ... if (offset < EXT4_BLOCKS_PER_GROUP(sb) && ext4_test_bit(offset, bh->b_data)) /* bad block bitmap */ goto err_out; Cheers, Andreas -- Andreas Dilger Sr. Software Engineer, Lustre Group Sun Microsystems of Canada, Inc.