ext2: use ext2_group_first_block_no()
authorAkinobu Mita <akinobu.mita@gmail.com>
Mon, 28 Apr 2008 09:16:01 +0000 (02:16 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 28 Apr 2008 15:58:43 +0000 (08:58 -0700)
Use ext2_group_first_block_no() and assign the return values to
ext2_fsblk_t variables.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: <linux-ext4@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/ext2/inode.c
fs/ext2/super.c
fs/ext2/xattr.c

index 687023bdfd1e885ba5a0adad71bb6a9a3113cb1c..be0d02ac7ac4b4070f807c296313ec5d8d47d1e7 100644 (file)
@@ -275,8 +275,7 @@ static unsigned long ext2_find_near(struct inode *inode, Indirect *ind)
         * It is going to be refered from inode itself? OK, just put it into
         * the same cylinder group then.
         */
-       bg_start = (ei->i_block_group * EXT2_BLOCKS_PER_GROUP(inode->i_sb)) +
-               le32_to_cpu(EXT2_SB(inode->i_sb)->s_es->s_first_data_block);
+       bg_start = ext2_group_first_block_no(inode->i_sb, ei->i_block_group);
        colour = (current->pid % 16) *
                        (EXT2_BLOCKS_PER_GROUP(inode->i_sb) / 16);
        return bg_start + colour;
index 7e6867329220cb55cbd9069d342be37f5a2e5760..3f745fb5fff33f4d978858ba8306967b01b2d419 100644 (file)
@@ -621,13 +621,13 @@ static int ext2_check_descriptors(struct super_block *sb)
 {
        int i;
        struct ext2_sb_info *sbi = EXT2_SB(sb);
-       unsigned long first_block = le32_to_cpu(sbi->s_es->s_first_data_block);
-       unsigned long last_block;
 
        ext2_debug ("Checking group descriptors");
 
        for (i = 0; i < sbi->s_groups_count; i++) {
                struct ext2_group_desc *gdp = ext2_get_group_desc(sb, i, NULL);
+               ext2_fsblk_t first_block = ext2_group_first_block_no(sb, i);
+               ext2_fsblk_t last_block;
 
                if (i == sbi->s_groups_count - 1)
                        last_block = le32_to_cpu(sbi->s_es->s_blocks_count) - 1;
@@ -663,7 +663,6 @@ static int ext2_check_descriptors(struct super_block *sb)
                                    i, (unsigned long) le32_to_cpu(gdp->bg_inode_table));
                        return 0;
                }
-               first_block += EXT2_BLOCKS_PER_GROUP(sb);
        }
        return 1;
 }
@@ -720,10 +719,9 @@ static unsigned long descriptor_loc(struct super_block *sb,
                                    int nr)
 {
        struct ext2_sb_info *sbi = EXT2_SB(sb);
-       unsigned long bg, first_data_block, first_meta_bg;
+       unsigned long bg, first_meta_bg;
        int has_super = 0;
        
-       first_data_block = le32_to_cpu(sbi->s_es->s_first_data_block);
        first_meta_bg = le32_to_cpu(sbi->s_es->s_first_meta_bg);
 
        if (!EXT2_HAS_INCOMPAT_FEATURE(sb, EXT2_FEATURE_INCOMPAT_META_BG) ||
@@ -732,7 +730,8 @@ static unsigned long descriptor_loc(struct super_block *sb,
        bg = sbi->s_desc_per_block * nr;
        if (ext2_bg_has_super(sb, bg))
                has_super = 1;
-       return (first_data_block + has_super + (bg * sbi->s_blocks_per_group));
+
+       return ext2_group_first_block_no(sb, bg) + has_super;
 }
 
 static int ext2_fill_super(struct super_block *sb, void *data, int silent)
index b86f02747eaf9c1775e03b2dd6780d015b288ac6..987a5261cc2e8ef8a2e164c4f491b37856f14be3 100644 (file)
@@ -659,10 +659,8 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
                        ext2_xattr_cache_insert(new_bh);
                } else {
                        /* We need to allocate a new block */
-                       int goal = le32_to_cpu(EXT2_SB(sb)->s_es->
-                                                          s_first_data_block) +
-                                  EXT2_I(inode)->i_block_group *
-                                  EXT2_BLOCKS_PER_GROUP(sb);
+                       ext2_fsblk_t goal = ext2_group_first_block_no(sb,
+                                               EXT2_I(inode)->i_block_group);
                        int block = ext2_new_block(inode, goal, &error);
                        if (error)
                                goto cleanup;