aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/mballoc.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2011-09-09 18:38:51 -0400
committerTheodore Ts'o <tytso@mit.edu>2011-09-09 18:38:51 -0400
commit7137d7a48e2213eb1f6d6529da14c2ed3706b795 (patch)
tree7c5c164dc1e505129fefcac5c61b208fa1180a90 /fs/ext4/mballoc.c
parentbab08ab9646288f1b0b72a7aaeecdff94bd62c18 (diff)
ext4: convert instances of EXT4_BLOCKS_PER_GROUP to EXT4_CLUSTERS_PER_GROUP
Change the places in fs/ext4/mballoc.c where EXT4_BLOCKS_PER_GROUP are used to indicate the number of bits in a block bitmap (which is really a cluster allocation bitmap in bigalloc file systems). There are still some places in the ext4 codebase where usage of EXT4_BLOCKS_PER_GROUP needs to be audited/fixed, in code paths that aren't used given the initial restricted assumptions for bigalloc. These will need to be fixed before we can relax those restrictions. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/mballoc.c')
-rw-r--r--fs/ext4/mballoc.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 17a5a57c415a..81e28657a3c2 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -653,7 +653,7 @@ static void ext4_mb_mark_free_simple(struct super_block *sb,
653 ext4_grpblk_t chunk; 653 ext4_grpblk_t chunk;
654 unsigned short border; 654 unsigned short border;
655 655
656 BUG_ON(len > EXT4_BLOCKS_PER_GROUP(sb)); 656 BUG_ON(len > EXT4_CLUSTERS_PER_GROUP(sb));
657 657
658 border = 2 << sb->s_blocksize_bits; 658 border = 2 << sb->s_blocksize_bits;
659 659
@@ -705,7 +705,7 @@ void ext4_mb_generate_buddy(struct super_block *sb,
705 void *buddy, void *bitmap, ext4_group_t group) 705 void *buddy, void *bitmap, ext4_group_t group)
706{ 706{
707 struct ext4_group_info *grp = ext4_get_group_info(sb, group); 707 struct ext4_group_info *grp = ext4_get_group_info(sb, group);
708 ext4_grpblk_t max = EXT4_BLOCKS_PER_GROUP(sb); 708 ext4_grpblk_t max = EXT4_CLUSTERS_PER_GROUP(sb);
709 ext4_grpblk_t i = 0; 709 ext4_grpblk_t i = 0;
710 ext4_grpblk_t first; 710 ext4_grpblk_t first;
711 ext4_grpblk_t len; 711 ext4_grpblk_t len;
@@ -1624,8 +1624,8 @@ static void ext4_mb_measure_extent(struct ext4_allocation_context *ac,
1624 struct ext4_free_extent *gex = &ac->ac_g_ex; 1624 struct ext4_free_extent *gex = &ac->ac_g_ex;
1625 1625
1626 BUG_ON(ex->fe_len <= 0); 1626 BUG_ON(ex->fe_len <= 0);
1627 BUG_ON(ex->fe_len > EXT4_BLOCKS_PER_GROUP(ac->ac_sb)); 1627 BUG_ON(ex->fe_len > EXT4_CLUSTERS_PER_GROUP(ac->ac_sb));
1628 BUG_ON(ex->fe_start >= EXT4_BLOCKS_PER_GROUP(ac->ac_sb)); 1628 BUG_ON(ex->fe_start >= EXT4_CLUSTERS_PER_GROUP(ac->ac_sb));
1629 BUG_ON(ac->ac_status != AC_STATUS_CONTINUE); 1629 BUG_ON(ac->ac_status != AC_STATUS_CONTINUE);
1630 1630
1631 ac->ac_found++; 1631 ac->ac_found++;
@@ -1823,8 +1823,8 @@ void ext4_mb_complex_scan_group(struct ext4_allocation_context *ac,
1823 1823
1824 while (free && ac->ac_status == AC_STATUS_CONTINUE) { 1824 while (free && ac->ac_status == AC_STATUS_CONTINUE) {
1825 i = mb_find_next_zero_bit(bitmap, 1825 i = mb_find_next_zero_bit(bitmap,
1826 EXT4_BLOCKS_PER_GROUP(sb), i); 1826 EXT4_CLUSTERS_PER_GROUP(sb), i);
1827 if (i >= EXT4_BLOCKS_PER_GROUP(sb)) { 1827 if (i >= EXT4_CLUSTERS_PER_GROUP(sb)) {
1828 /* 1828 /*
1829 * IF we have corrupt bitmap, we won't find any 1829 * IF we have corrupt bitmap, we won't find any
1830 * free blocks even though group info says we 1830 * free blocks even though group info says we
@@ -1887,7 +1887,7 @@ void ext4_mb_scan_aligned(struct ext4_allocation_context *ac,
1887 do_div(a, sbi->s_stripe); 1887 do_div(a, sbi->s_stripe);
1888 i = (a * sbi->s_stripe) - first_group_block; 1888 i = (a * sbi->s_stripe) - first_group_block;
1889 1889
1890 while (i < EXT4_BLOCKS_PER_GROUP(sb)) { 1890 while (i < EXT4_CLUSTERS_PER_GROUP(sb)) {
1891 if (!mb_test_bit(i, bitmap)) { 1891 if (!mb_test_bit(i, bitmap)) {
1892 max = mb_find_extent(e4b, 0, i, sbi->s_stripe, &ex); 1892 max = mb_find_extent(e4b, 0, i, sbi->s_stripe, &ex);
1893 if (max >= sbi->s_stripe) { 1893 if (max >= sbi->s_stripe) {
@@ -3036,7 +3036,7 @@ ext4_mb_normalize_request(struct ext4_allocation_context *ac,
3036 } 3036 }
3037 BUG_ON(start + size <= ac->ac_o_ex.fe_logical && 3037 BUG_ON(start + size <= ac->ac_o_ex.fe_logical &&
3038 start > ac->ac_o_ex.fe_logical); 3038 start > ac->ac_o_ex.fe_logical);
3039 BUG_ON(size <= 0 || size > EXT4_BLOCKS_PER_GROUP(ac->ac_sb)); 3039 BUG_ON(size <= 0 || size > EXT4_CLUSTERS_PER_GROUP(ac->ac_sb));
3040 3040
3041 /* now prepare goal request */ 3041 /* now prepare goal request */
3042 3042
@@ -3690,7 +3690,7 @@ ext4_mb_discard_group_preallocations(struct super_block *sb,
3690 } 3690 }
3691 3691
3692 if (needed == 0) 3692 if (needed == 0)
3693 needed = EXT4_BLOCKS_PER_GROUP(sb) + 1; 3693 needed = EXT4_CLUSTERS_PER_GROUP(sb) + 1;
3694 3694
3695 INIT_LIST_HEAD(&list); 3695 INIT_LIST_HEAD(&list);
3696repeat: 3696repeat:
@@ -4007,8 +4007,8 @@ ext4_mb_initialize_context(struct ext4_allocation_context *ac,
4007 len = ar->len; 4007 len = ar->len;
4008 4008
4009 /* just a dirty hack to filter too big requests */ 4009 /* just a dirty hack to filter too big requests */
4010 if (len >= EXT4_BLOCKS_PER_GROUP(sb) - 10) 4010 if (len >= EXT4_CLUSTERS_PER_GROUP(sb) - 10)
4011 len = EXT4_BLOCKS_PER_GROUP(sb) - 10; 4011 len = EXT4_CLUSTERS_PER_GROUP(sb) - 10;
4012 4012
4013 /* start searching from the goal */ 4013 /* start searching from the goal */
4014 goal = ar->goal; 4014 goal = ar->goal;
@@ -4552,8 +4552,8 @@ do_more:
4552 * Check to see if we are freeing blocks across a group 4552 * Check to see if we are freeing blocks across a group
4553 * boundary. 4553 * boundary.
4554 */ 4554 */
4555 if (bit + count > EXT4_BLOCKS_PER_GROUP(sb)) { 4555 if (bit + count > EXT4_CLUSTERS_PER_GROUP(sb)) {
4556 overflow = bit + count - EXT4_BLOCKS_PER_GROUP(sb); 4556 overflow = bit + count - EXT4_CLUSTERS_PER_GROUP(sb);
4557 count -= overflow; 4557 count -= overflow;
4558 } 4558 }
4559 bitmap_bh = ext4_read_block_bitmap(sb, block_group); 4559 bitmap_bh = ext4_read_block_bitmap(sb, block_group);
@@ -4948,7 +4948,7 @@ int ext4_trim_fs(struct super_block *sb, struct fstrim_range *range)
4948 struct ext4_group_info *grp; 4948 struct ext4_group_info *grp;
4949 ext4_group_t first_group, last_group; 4949 ext4_group_t first_group, last_group;
4950 ext4_group_t group, ngroups = ext4_get_groups_count(sb); 4950 ext4_group_t group, ngroups = ext4_get_groups_count(sb);
4951 ext4_grpblk_t cnt = 0, first_block, last_block; 4951 ext4_grpblk_t cnt = 0, first_cluster, last_cluster;
4952 uint64_t start, len, minlen, trimmed = 0; 4952 uint64_t start, len, minlen, trimmed = 0;
4953 ext4_fsblk_t first_data_blk = 4953 ext4_fsblk_t first_data_blk =
4954 le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block); 4954 le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block);
@@ -4958,7 +4958,7 @@ int ext4_trim_fs(struct super_block *sb, struct fstrim_range *range)
4958 len = range->len >> sb->s_blocksize_bits; 4958 len = range->len >> sb->s_blocksize_bits;
4959 minlen = range->minlen >> sb->s_blocksize_bits; 4959 minlen = range->minlen >> sb->s_blocksize_bits;
4960 4960
4961 if (unlikely(minlen > EXT4_BLOCKS_PER_GROUP(sb))) 4961 if (unlikely(minlen > EXT4_CLUSTERS_PER_GROUP(sb)))
4962 return -EINVAL; 4962 return -EINVAL;
4963 if (start + len <= first_data_blk) 4963 if (start + len <= first_data_blk)
4964 goto out; 4964 goto out;
@@ -4969,11 +4969,11 @@ int ext4_trim_fs(struct super_block *sb, struct fstrim_range *range)
4969 4969
4970 /* Determine first and last group to examine based on start and len */ 4970 /* Determine first and last group to examine based on start and len */
4971 ext4_get_group_no_and_offset(sb, (ext4_fsblk_t) start, 4971 ext4_get_group_no_and_offset(sb, (ext4_fsblk_t) start,
4972 &first_group, &first_block); 4972 &first_group, &first_cluster);
4973 ext4_get_group_no_and_offset(sb, (ext4_fsblk_t) (start + len), 4973 ext4_get_group_no_and_offset(sb, (ext4_fsblk_t) (start + len),
4974 &last_group, &last_block); 4974 &last_group, &last_cluster);
4975 last_group = (last_group > ngroups - 1) ? ngroups - 1 : last_group; 4975 last_group = (last_group > ngroups - 1) ? ngroups - 1 : last_group;
4976 last_block = EXT4_BLOCKS_PER_GROUP(sb); 4976 last_cluster = EXT4_CLUSTERS_PER_GROUP(sb);
4977 4977
4978 if (first_group > last_group) 4978 if (first_group > last_group)
4979 return -EINVAL; 4979 return -EINVAL;
@@ -4993,20 +4993,20 @@ int ext4_trim_fs(struct super_block *sb, struct fstrim_range *range)
4993 * change it for the last group in which case start + 4993 * change it for the last group in which case start +
4994 * len < EXT4_BLOCKS_PER_GROUP(sb). 4994 * len < EXT4_BLOCKS_PER_GROUP(sb).
4995 */ 4995 */
4996 if (first_block + len < EXT4_BLOCKS_PER_GROUP(sb)) 4996 if (first_cluster + len < EXT4_CLUSTERS_PER_GROUP(sb))
4997 last_block = first_block + len; 4997 last_cluster = first_cluster + len;
4998 len -= last_block - first_block; 4998 len -= last_cluster - first_cluster;
4999 4999
5000 if (grp->bb_free >= minlen) { 5000 if (grp->bb_free >= minlen) {
5001 cnt = ext4_trim_all_free(sb, group, first_block, 5001 cnt = ext4_trim_all_free(sb, group, first_cluster,
5002 last_block, minlen); 5002 last_cluster, minlen);
5003 if (cnt < 0) { 5003 if (cnt < 0) {
5004 ret = cnt; 5004 ret = cnt;
5005 break; 5005 break;
5006 } 5006 }
5007 } 5007 }
5008 trimmed += cnt; 5008 trimmed += cnt;
5009 first_block = 0; 5009 first_cluster = 0;
5010 } 5010 }
5011 range->len = trimmed * sb->s_blocksize; 5011 range->len = trimmed * sb->s_blocksize;
5012 5012