Commit c5e8f3f3 authored by Theodore Ts'o's avatar Theodore Ts'o

ext4: remove EXT4_MB_{BITMAP,BUDDY} macros

The EXT4_MB_BITMAP and EXT4_MB_BUDDY macros obfuscate more than they
provide any abstraction.   So remove them.
Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
parent a0cc910f
...@@ -427,7 +427,7 @@ static void *mb_find_buddy(struct ext4_buddy *e4b, int order, int *max) ...@@ -427,7 +427,7 @@ static void *mb_find_buddy(struct ext4_buddy *e4b, int order, int *max)
{ {
char *bb; char *bb;
BUG_ON(EXT4_MB_BITMAP(e4b) == EXT4_MB_BUDDY(e4b)); BUG_ON(e4b->bd_bitmap == e4b->bd_buddy);
BUG_ON(max == NULL); BUG_ON(max == NULL);
if (order > e4b->bd_blkbits + 1) { if (order > e4b->bd_blkbits + 1) {
...@@ -438,10 +438,10 @@ static void *mb_find_buddy(struct ext4_buddy *e4b, int order, int *max) ...@@ -438,10 +438,10 @@ static void *mb_find_buddy(struct ext4_buddy *e4b, int order, int *max)
/* at order 0 we see each particular block */ /* at order 0 we see each particular block */
if (order == 0) { if (order == 0) {
*max = 1 << (e4b->bd_blkbits + 3); *max = 1 << (e4b->bd_blkbits + 3);
return EXT4_MB_BITMAP(e4b); return e4b->bd_bitmap;
} }
bb = EXT4_MB_BUDDY(e4b) + EXT4_SB(e4b->bd_sb)->s_mb_offsets[order]; bb = e4b->bd_buddy + EXT4_SB(e4b->bd_sb)->s_mb_offsets[order];
*max = EXT4_SB(e4b->bd_sb)->s_mb_maxs[order]; *max = EXT4_SB(e4b->bd_sb)->s_mb_maxs[order];
return bb; return bb;
...@@ -590,7 +590,7 @@ static int __mb_check_buddy(struct ext4_buddy *e4b, char *file, ...@@ -590,7 +590,7 @@ static int __mb_check_buddy(struct ext4_buddy *e4b, char *file,
for (j = 0; j < (1 << order); j++) { for (j = 0; j < (1 << order); j++) {
k = (i * (1 << order)) + j; k = (i * (1 << order)) + j;
MB_CHECK_ASSERT( MB_CHECK_ASSERT(
!mb_test_bit(k, EXT4_MB_BITMAP(e4b))); !mb_test_bit(k, e4b->bd_bitmap));
} }
count++; count++;
} }
...@@ -1203,10 +1203,10 @@ static int mb_find_order_for_block(struct ext4_buddy *e4b, int block) ...@@ -1203,10 +1203,10 @@ static int mb_find_order_for_block(struct ext4_buddy *e4b, int block)
int order = 1; int order = 1;
void *bb; void *bb;
BUG_ON(EXT4_MB_BITMAP(e4b) == EXT4_MB_BUDDY(e4b)); BUG_ON(e4b->bd_bitmap == e4b->bd_buddy);
BUG_ON(block >= (1 << (e4b->bd_blkbits + 3))); BUG_ON(block >= (1 << (e4b->bd_blkbits + 3)));
bb = EXT4_MB_BUDDY(e4b); bb = e4b->bd_buddy;
while (order <= e4b->bd_blkbits + 1) { while (order <= e4b->bd_blkbits + 1) {
block = block >> 1; block = block >> 1;
if (!mb_test_bit(block, bb)) { if (!mb_test_bit(block, bb)) {
...@@ -1276,9 +1276,9 @@ static void mb_free_blocks(struct inode *inode, struct ext4_buddy *e4b, ...@@ -1276,9 +1276,9 @@ static void mb_free_blocks(struct inode *inode, struct ext4_buddy *e4b,
/* let's maintain fragments counter */ /* let's maintain fragments counter */
if (first != 0) if (first != 0)
block = !mb_test_bit(first - 1, EXT4_MB_BITMAP(e4b)); block = !mb_test_bit(first - 1, e4b->bd_bitmap);
if (first + count < EXT4_SB(sb)->s_mb_maxs[0]) if (first + count < EXT4_SB(sb)->s_mb_maxs[0])
max = !mb_test_bit(first + count, EXT4_MB_BITMAP(e4b)); max = !mb_test_bit(first + count, e4b->bd_bitmap);
if (block && max) if (block && max)
e4b->bd_info->bb_fragments--; e4b->bd_info->bb_fragments--;
else if (!block && !max) else if (!block && !max)
...@@ -1289,7 +1289,7 @@ static void mb_free_blocks(struct inode *inode, struct ext4_buddy *e4b, ...@@ -1289,7 +1289,7 @@ static void mb_free_blocks(struct inode *inode, struct ext4_buddy *e4b,
block = first++; block = first++;
order = 0; order = 0;
if (!mb_test_bit(block, EXT4_MB_BITMAP(e4b))) { if (!mb_test_bit(block, e4b->bd_bitmap)) {
ext4_fsblk_t blocknr; ext4_fsblk_t blocknr;
blocknr = ext4_group_first_block_no(sb, e4b->bd_group); blocknr = ext4_group_first_block_no(sb, e4b->bd_group);
...@@ -1300,7 +1300,7 @@ static void mb_free_blocks(struct inode *inode, struct ext4_buddy *e4b, ...@@ -1300,7 +1300,7 @@ static void mb_free_blocks(struct inode *inode, struct ext4_buddy *e4b,
"freeing already freed block " "freeing already freed block "
"(bit %u)", block); "(bit %u)", block);
} }
mb_clear_bit(block, EXT4_MB_BITMAP(e4b)); mb_clear_bit(block, e4b->bd_bitmap);
e4b->bd_info->bb_counters[order]++; e4b->bd_info->bb_counters[order]++;
/* start of the buddy */ /* start of the buddy */
...@@ -1382,7 +1382,7 @@ static int mb_find_extent(struct ext4_buddy *e4b, int order, int block, ...@@ -1382,7 +1382,7 @@ static int mb_find_extent(struct ext4_buddy *e4b, int order, int block,
break; break;
next = (block + 1) * (1 << order); next = (block + 1) * (1 << order);
if (mb_test_bit(next, EXT4_MB_BITMAP(e4b))) if (mb_test_bit(next, e4b->bd_bitmap))
break; break;
order = mb_find_order_for_block(e4b, next); order = mb_find_order_for_block(e4b, next);
...@@ -1419,9 +1419,9 @@ static int mb_mark_used(struct ext4_buddy *e4b, struct ext4_free_extent *ex) ...@@ -1419,9 +1419,9 @@ static int mb_mark_used(struct ext4_buddy *e4b, struct ext4_free_extent *ex)
/* let's maintain fragments counter */ /* let's maintain fragments counter */
if (start != 0) if (start != 0)
mlen = !mb_test_bit(start - 1, EXT4_MB_BITMAP(e4b)); mlen = !mb_test_bit(start - 1, e4b->bd_bitmap);
if (start + len < EXT4_SB(e4b->bd_sb)->s_mb_maxs[0]) if (start + len < EXT4_SB(e4b->bd_sb)->s_mb_maxs[0])
max = !mb_test_bit(start + len, EXT4_MB_BITMAP(e4b)); max = !mb_test_bit(start + len, e4b->bd_bitmap);
if (mlen && max) if (mlen && max)
e4b->bd_info->bb_fragments++; e4b->bd_info->bb_fragments++;
else if (!mlen && !max) else if (!mlen && !max)
...@@ -1464,7 +1464,7 @@ static int mb_mark_used(struct ext4_buddy *e4b, struct ext4_free_extent *ex) ...@@ -1464,7 +1464,7 @@ static int mb_mark_used(struct ext4_buddy *e4b, struct ext4_free_extent *ex)
} }
mb_set_largest_free_order(e4b->bd_sb, e4b->bd_info); mb_set_largest_free_order(e4b->bd_sb, e4b->bd_info);
ext4_set_bits(EXT4_MB_BITMAP(e4b), ex->fe_start, len0); ext4_set_bits(e4b->bd_bitmap, ex->fe_start, len0);
mb_check_buddy(e4b); mb_check_buddy(e4b);
return ret; return ret;
...@@ -1763,7 +1763,7 @@ void ext4_mb_complex_scan_group(struct ext4_allocation_context *ac, ...@@ -1763,7 +1763,7 @@ void ext4_mb_complex_scan_group(struct ext4_allocation_context *ac,
struct ext4_buddy *e4b) struct ext4_buddy *e4b)
{ {
struct super_block *sb = ac->ac_sb; struct super_block *sb = ac->ac_sb;
void *bitmap = EXT4_MB_BITMAP(e4b); void *bitmap = e4b->bd_bitmap;
struct ext4_free_extent ex; struct ext4_free_extent ex;
int i; int i;
int free; int free;
...@@ -1823,7 +1823,7 @@ void ext4_mb_scan_aligned(struct ext4_allocation_context *ac, ...@@ -1823,7 +1823,7 @@ void ext4_mb_scan_aligned(struct ext4_allocation_context *ac,
{ {
struct super_block *sb = ac->ac_sb; struct super_block *sb = ac->ac_sb;
struct ext4_sb_info *sbi = EXT4_SB(sb); struct ext4_sb_info *sbi = EXT4_SB(sb);
void *bitmap = EXT4_MB_BITMAP(e4b); void *bitmap = e4b->bd_bitmap;
struct ext4_free_extent ex; struct ext4_free_extent ex;
ext4_fsblk_t first_group_block; ext4_fsblk_t first_group_block;
ext4_fsblk_t a; ext4_fsblk_t a;
......
...@@ -212,8 +212,6 @@ struct ext4_buddy { ...@@ -212,8 +212,6 @@ struct ext4_buddy {
__u16 bd_blkbits; __u16 bd_blkbits;
ext4_group_t bd_group; ext4_group_t bd_group;
}; };
#define EXT4_MB_BITMAP(e4b) ((e4b)->bd_bitmap)
#define EXT4_MB_BUDDY(e4b) ((e4b)->bd_buddy)
static inline ext4_fsblk_t ext4_grp_offs_to_block(struct super_block *sb, static inline ext4_fsblk_t ext4_grp_offs_to_block(struct super_block *sb,
struct ext4_free_extent *fex) struct ext4_free_extent *fex)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment