ext4: convert number of blocks to clusters properly
authorLukas Czerner <lczerner@redhat.com>
Sat, 2 Mar 2013 22:18:58 +0000 (17:18 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 2 Mar 2013 22:18:58 +0000 (17:18 -0500)
We're using macro EXT4_B2C() to convert number of blocks to number of
clusters for bigalloc file systems.  However, we should be using
EXT4_NUM_B2C().

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: stable@vger.kernel.org
fs/ext4/balloc.c
fs/ext4/mballoc.c
fs/ext4/resize.c
fs/ext4/super.c

index 2f2e0da1a6b7774d45e1886c4d22d5a48cc00032..92e68b33fffde26bd98c899010589ffaea70f699 100644 (file)
@@ -635,7 +635,7 @@ ext4_fsblk_t ext4_count_free_clusters(struct super_block *sb)
        brelse(bitmap_bh);
        printk(KERN_DEBUG "ext4_count_free_clusters: stored = %llu"
               ", computed = %llu, %llu\n",
-              EXT4_B2C(EXT4_SB(sb), ext4_free_blocks_count(es)),
+              EXT4_NUM_B2C(EXT4_SB(sb), ext4_free_blocks_count(es)),
               desc_count, bitmap_count);
        return bitmap_count;
 #else
index 6540ebe058e37da9b7dca868bb4c41daee4ea2ad..7bb713a46fe4c3f85ae9d35bd15bea73aa7957f5 100644 (file)
@@ -3419,7 +3419,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
                        win = offs;
 
                ac->ac_b_ex.fe_logical = ac->ac_o_ex.fe_logical -
-                       EXT4_B2C(sbi, win);
+                       EXT4_NUM_B2C(sbi, win);
                BUG_ON(ac->ac_o_ex.fe_logical < ac->ac_b_ex.fe_logical);
                BUG_ON(ac->ac_o_ex.fe_len > ac->ac_b_ex.fe_len);
        }
@@ -4565,7 +4565,7 @@ do_more:
                        EXT4_BLOCKS_PER_GROUP(sb);
                count -= overflow;
        }
-       count_clusters = EXT4_B2C(sbi, count);
+       count_clusters = EXT4_NUM_B2C(sbi, count);
        bitmap_bh = ext4_read_block_bitmap(sb, block_group);
        if (!bitmap_bh) {
                err = -EIO;
@@ -4807,11 +4807,11 @@ int ext4_group_add_blocks(handle_t *handle, struct super_block *sb,
        ext4_group_desc_csum_set(sb, block_group, desc);
        ext4_unlock_group(sb, block_group);
        percpu_counter_add(&sbi->s_freeclusters_counter,
-                          EXT4_B2C(sbi, blocks_freed));
+                          EXT4_NUM_B2C(sbi, blocks_freed));
 
        if (sbi->s_log_groups_per_flex) {
                ext4_group_t flex_group = ext4_flex_group(sbi, block_group);
-               atomic_add(EXT4_B2C(sbi, blocks_freed),
+               atomic_add(EXT4_NUM_B2C(sbi, blocks_freed),
                           &sbi->s_flex_groups[flex_group].free_clusters);
        }
 
index c7f4d758466947e0bdc0f6da16e1da631b6ea595..b2c8ee56eb98744ab7481e4d0849e2fb5ca71365 100644 (file)
@@ -1247,7 +1247,7 @@ static int ext4_setup_new_descs(handle_t *handle, struct super_block *sb,
 
                ext4_inode_table_set(sb, gdp, group_data->inode_table);
                ext4_free_group_clusters_set(sb, gdp,
-                                            EXT4_B2C(sbi, group_data->free_blocks_count));
+                       EXT4_NUM_B2C(sbi, group_data->free_blocks_count));
                ext4_free_inodes_set(sb, gdp, EXT4_INODES_PER_GROUP(sb));
                if (ext4_has_group_desc_csum(sb))
                        ext4_itable_unused_set(sb, gdp,
@@ -1349,7 +1349,7 @@ static void ext4_update_super(struct super_block *sb,
 
        /* Update the free space counts */
        percpu_counter_add(&sbi->s_freeclusters_counter,
-                          EXT4_B2C(sbi, free_blocks));
+                          EXT4_NUM_B2C(sbi, free_blocks));
        percpu_counter_add(&sbi->s_freeinodes_counter,
                           EXT4_INODES_PER_GROUP(sb) * flex_gd->count);
 
@@ -1360,7 +1360,7 @@ static void ext4_update_super(struct super_block *sb,
            sbi->s_log_groups_per_flex) {
                ext4_group_t flex_group;
                flex_group = ext4_flex_group(sbi, group_data[0].group);
-               atomic_add(EXT4_B2C(sbi, free_blocks),
+               atomic_add(EXT4_NUM_B2C(sbi, free_blocks),
                           &sbi->s_flex_groups[flex_group].free_clusters);
                atomic_add(EXT4_INODES_PER_GROUP(sb) * flex_gd->count,
                           &sbi->s_flex_groups[flex_group].free_inodes);
index 6ac9c8a3eb08b827fc904ebc3960f50260e9bcac..990ceab2e2bcab59cc5fdeab28987c4d9f1cc945 100644 (file)
@@ -3162,7 +3162,7 @@ int ext4_calculate_overhead(struct super_block *sb)
        }
        /* Add the journal blocks as well */
        if (sbi->s_journal)
-               overhead += EXT4_B2C(sbi, sbi->s_journal->j_maxlen);
+               overhead += EXT4_NUM_B2C(sbi, sbi->s_journal->j_maxlen);
 
        sbi->s_overhead = overhead;
        smp_wmb();