[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <1186127051.3866.12.camel@garfield>
Date: Fri, 03 Aug 2007 13:14:11 +0530
From: Kalpak Shah <kalpak@...sterfs.com>
To: "Aneesh Kumar K.V" <aneesh.kumar@...ux.vnet.ibm.com>
Cc: cmm@...ibm.com, linux-ext4@...r.kernel.org,
Andreas Dilger <adilger@...sterfs.com>
Subject: Re: [PATCH] ext2/ext3/ext4: Add block bitmap validation
On Fri, 2007-08-03 at 12:40 +0530, Aneesh Kumar K.V wrote:
> desc = ext2_get_group_desc (sb, block_group, NULL);
> if (!desc)
> - goto error_out;
> - bh = sb_bread(sb, le32_to_cpu(desc->bg_block_bitmap));
> + return NULL;
> + bitmap_blk = le32_to_cpu(desc->bg_block_bitmap);
> + bh = sb_bread(sb, bitmap_blk);
> if (!bh)
> - ext2_error (sb, "read_block_bitmap",
> + ext2_error (sb, __FUNCTION__,
> "Cannot read block bitmap - "
> "block_group = %d, block_bitmap = %u",
> block_group, le32_to_cpu(desc->bg_block_bitmap));
bitmap_blk should be used here instead of
le32_to_cpu(desc->bg_block_bitmap). It reduces one endianness
conversion.
> -error_out:
> +
> + /* check whether block bitmap block number is set */
> + if (!block_in_use(bitmap_blk, sb, bh->b_data)) {
> + /* bad block bitmap */
> + goto error_out;
> + }
> + /* check whether the inode bitmap block number is set */
> + bitmap_blk = le32_to_cpu(desc->bg_inode_bitmap);
> + if (!block_in_use(bitmap_blk, sb, bh->b_data)) {
> + /* bad block bitmap */
> + goto error_out;
> + }
> + /* check whether the inode table block number is set */
> + bitmap_blk = le32_to_cpu(desc->bg_inode_table);
> + for (i = 0; i < EXT2_SB(sb)->s_itb_per_group; i++, bitmap_blk++) {
> + if (!block_in_use(bitmap_blk, sb, bh->b_data)) {
> + /* bad block bitmap */
> + goto error_out;
> + }
> + }
Why not reduce a lot of this code by having:
int block_range_in_use(ext4_fsblk_t start_blk, ext4_fsblk_t num_blks,
struct super_block *sb, unsigned char *map)?
It will also help to do away with a lot of repetitive calculations in
block_in_use().
> + ext3_error(sb, __FUNCTION__,
> + "Invalid block bitmap - "
> + "block_group = %d, block = %lu",
> + block_group, bitmap_blk);
Please align this according to kernel coding style.
Thanks,
Kalpak.
-
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists