diff options
author | Akinobu Mita <akinobu.mita@gmail.com> | 2010-03-03 23:53:39 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2010-03-03 23:53:39 -0500 |
commit | 5661bd6861b7490394e29aaf74dca812188272e4 (patch) | |
tree | 34d4e626b9c4abaf98e79fb705ba1e4a21f9e7f9 /fs/ext4 | |
parent | 9b1d0998d24f9c207d5fbdd0b8bac07284e0eda7 (diff) |
ext4: cleanup to use ext4_group_first_block_no()
This is a cleanup and simplification patch which takes some open-coded
calculations to calculate the first block number of a group and
converts them to use the (already defined) ext4_group_first_block_no()
function.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: Andreas Dilger <adilger@sun.com>
Diffstat (limited to 'fs/ext4')
-rw-r--r-- | fs/ext4/balloc.c | 3 | ||||
-rw-r--r-- | fs/ext4/extents.c | 3 | ||||
-rw-r--r-- | fs/ext4/mballoc.c | 29 | ||||
-rw-r--r-- | fs/ext4/mballoc.h | 7 |
4 files changed, 14 insertions, 28 deletions
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c index 720061a0ee53..fadbc4d3a202 100644 --- a/fs/ext4/balloc.c +++ b/fs/ext4/balloc.c | |||
@@ -130,8 +130,7 @@ unsigned ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh, | |||
130 | * to make sure we calculate the right free blocks | 130 | * to make sure we calculate the right free blocks |
131 | */ | 131 | */ |
132 | group_blocks = ext4_blocks_count(sbi->s_es) - | 132 | group_blocks = ext4_blocks_count(sbi->s_es) - |
133 | le32_to_cpu(sbi->s_es->s_first_data_block) - | 133 | ext4_group_first_block_no(sb, ngroups - 1); |
134 | (EXT4_BLOCKS_PER_GROUP(sb) * (ngroups - 1)); | ||
135 | } else { | 134 | } else { |
136 | group_blocks = EXT4_BLOCKS_PER_GROUP(sb); | 135 | group_blocks = EXT4_BLOCKS_PER_GROUP(sb); |
137 | } | 136 | } |
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 4bb69206f175..3c0bae11a097 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c | |||
@@ -195,8 +195,7 @@ static ext4_fsblk_t ext4_ext_find_goal(struct inode *inode, | |||
195 | if (S_ISREG(inode->i_mode)) | 195 | if (S_ISREG(inode->i_mode)) |
196 | block_group++; | 196 | block_group++; |
197 | } | 197 | } |
198 | bg_start = (block_group * EXT4_BLOCKS_PER_GROUP(inode->i_sb)) + | 198 | bg_start = ext4_group_first_block_no(inode->i_sb, block_group); |
199 | le32_to_cpu(EXT4_SB(inode->i_sb)->s_es->s_first_data_block); | ||
200 | last_block = ext4_blocks_count(EXT4_SB(inode->i_sb)->s_es) - 1; | 199 | last_block = ext4_blocks_count(EXT4_SB(inode->i_sb)->s_es) - 1; |
201 | 200 | ||
202 | /* | 201 | /* |
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 72d5ceb18523..11568697b192 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c | |||
@@ -441,10 +441,9 @@ static void mb_free_blocks_double(struct inode *inode, struct ext4_buddy *e4b, | |||
441 | for (i = 0; i < count; i++) { | 441 | for (i = 0; i < count; i++) { |
442 | if (!mb_test_bit(first + i, e4b->bd_info->bb_bitmap)) { | 442 | if (!mb_test_bit(first + i, e4b->bd_info->bb_bitmap)) { |
443 | ext4_fsblk_t blocknr; | 443 | ext4_fsblk_t blocknr; |
444 | blocknr = e4b->bd_group * EXT4_BLOCKS_PER_GROUP(sb); | 444 | |
445 | blocknr = ext4_group_first_block_no(sb, e4b->bd_group); | ||
445 | blocknr += first + i; | 446 | blocknr += first + i; |
446 | blocknr += | ||
447 | le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block); | ||
448 | ext4_grp_locked_error(sb, e4b->bd_group, | 447 | ext4_grp_locked_error(sb, e4b->bd_group, |
449 | __func__, "double-free of inode" | 448 | __func__, "double-free of inode" |
450 | " %lu's block %llu(bit %u in group %u)", | 449 | " %lu's block %llu(bit %u in group %u)", |
@@ -1255,10 +1254,9 @@ static void mb_free_blocks(struct inode *inode, struct ext4_buddy *e4b, | |||
1255 | 1254 | ||
1256 | if (!mb_test_bit(block, EXT4_MB_BITMAP(e4b))) { | 1255 | if (!mb_test_bit(block, EXT4_MB_BITMAP(e4b))) { |
1257 | ext4_fsblk_t blocknr; | 1256 | ext4_fsblk_t blocknr; |
1258 | blocknr = e4b->bd_group * EXT4_BLOCKS_PER_GROUP(sb); | 1257 | |
1258 | blocknr = ext4_group_first_block_no(sb, e4b->bd_group); | ||
1259 | blocknr += block; | 1259 | blocknr += block; |
1260 | blocknr += | ||
1261 | le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block); | ||
1262 | ext4_grp_locked_error(sb, e4b->bd_group, | 1260 | ext4_grp_locked_error(sb, e4b->bd_group, |
1263 | __func__, "double-free of inode" | 1261 | __func__, "double-free of inode" |
1264 | " %lu's block %llu(bit %u in group %u)", | 1262 | " %lu's block %llu(bit %u in group %u)", |
@@ -1631,7 +1629,6 @@ int ext4_mb_find_by_goal(struct ext4_allocation_context *ac, | |||
1631 | int max; | 1629 | int max; |
1632 | int err; | 1630 | int err; |
1633 | struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb); | 1631 | struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb); |
1634 | struct ext4_super_block *es = sbi->s_es; | ||
1635 | struct ext4_free_extent ex; | 1632 | struct ext4_free_extent ex; |
1636 | 1633 | ||
1637 | if (!(ac->ac_flags & EXT4_MB_HINT_TRY_GOAL)) | 1634 | if (!(ac->ac_flags & EXT4_MB_HINT_TRY_GOAL)) |
@@ -1648,8 +1645,8 @@ int ext4_mb_find_by_goal(struct ext4_allocation_context *ac, | |||
1648 | if (max >= ac->ac_g_ex.fe_len && ac->ac_g_ex.fe_len == sbi->s_stripe) { | 1645 | if (max >= ac->ac_g_ex.fe_len && ac->ac_g_ex.fe_len == sbi->s_stripe) { |
1649 | ext4_fsblk_t start; | 1646 | ext4_fsblk_t start; |
1650 | 1647 | ||
1651 | start = (e4b->bd_group * EXT4_BLOCKS_PER_GROUP(ac->ac_sb)) + | 1648 | start = ext4_group_first_block_no(ac->ac_sb, e4b->bd_group) + |
1652 | ex.fe_start + le32_to_cpu(es->s_first_data_block); | 1649 | ex.fe_start; |
1653 | /* use do_div to get remainder (would be 64-bit modulo) */ | 1650 | /* use do_div to get remainder (would be 64-bit modulo) */ |
1654 | if (do_div(start, sbi->s_stripe) == 0) { | 1651 | if (do_div(start, sbi->s_stripe) == 0) { |
1655 | ac->ac_found++; | 1652 | ac->ac_found++; |
@@ -1803,8 +1800,8 @@ void ext4_mb_scan_aligned(struct ext4_allocation_context *ac, | |||
1803 | BUG_ON(sbi->s_stripe == 0); | 1800 | BUG_ON(sbi->s_stripe == 0); |
1804 | 1801 | ||
1805 | /* find first stripe-aligned block in group */ | 1802 | /* find first stripe-aligned block in group */ |
1806 | first_group_block = e4b->bd_group * EXT4_BLOCKS_PER_GROUP(sb) | 1803 | first_group_block = ext4_group_first_block_no(sb, e4b->bd_group); |
1807 | + le32_to_cpu(sbi->s_es->s_first_data_block); | 1804 | |
1808 | a = first_group_block + sbi->s_stripe - 1; | 1805 | a = first_group_block + sbi->s_stripe - 1; |
1809 | do_div(a, sbi->s_stripe); | 1806 | do_div(a, sbi->s_stripe); |
1810 | i = (a * sbi->s_stripe) - first_group_block; | 1807 | i = (a * sbi->s_stripe) - first_group_block; |
@@ -2560,12 +2557,9 @@ static void release_blocks_on_commit(journal_t *journal, transaction_t *txn) | |||
2560 | ext4_unlock_group(sb, entry->group); | 2557 | ext4_unlock_group(sb, entry->group); |
2561 | if (test_opt(sb, DISCARD)) { | 2558 | if (test_opt(sb, DISCARD)) { |
2562 | ext4_fsblk_t discard_block; | 2559 | ext4_fsblk_t discard_block; |
2563 | struct ext4_super_block *es = EXT4_SB(sb)->s_es; | ||
2564 | 2560 | ||
2565 | discard_block = (ext4_fsblk_t)entry->group * | 2561 | discard_block = entry->start_blk + |
2566 | EXT4_BLOCKS_PER_GROUP(sb) | 2562 | ext4_group_first_block_no(sb, entry->group); |
2567 | + entry->start_blk | ||
2568 | + le32_to_cpu(es->s_first_data_block); | ||
2569 | trace_ext4_discard_blocks(sb, | 2563 | trace_ext4_discard_blocks(sb, |
2570 | (unsigned long long)discard_block, | 2564 | (unsigned long long)discard_block, |
2571 | entry->count); | 2565 | entry->count); |
@@ -3525,8 +3519,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh, | |||
3525 | if (bit >= end) | 3519 | if (bit >= end) |
3526 | break; | 3520 | break; |
3527 | next = mb_find_next_bit(bitmap_bh->b_data, end, bit); | 3521 | next = mb_find_next_bit(bitmap_bh->b_data, end, bit); |
3528 | start = group * EXT4_BLOCKS_PER_GROUP(sb) + bit + | 3522 | start = ext4_group_first_block_no(sb, group) + bit; |
3529 | le32_to_cpu(sbi->s_es->s_first_data_block); | ||
3530 | mb_debug(1, " free preallocated %u/%u in group %u\n", | 3523 | mb_debug(1, " free preallocated %u/%u in group %u\n", |
3531 | (unsigned) start, (unsigned) next - bit, | 3524 | (unsigned) start, (unsigned) next - bit, |
3532 | (unsigned) group); | 3525 | (unsigned) group); |
diff --git a/fs/ext4/mballoc.h b/fs/ext4/mballoc.h index 436521cae456..9b2deed652b7 100644 --- a/fs/ext4/mballoc.h +++ b/fs/ext4/mballoc.h | |||
@@ -225,11 +225,6 @@ struct ext4_buddy { | |||
225 | static inline ext4_fsblk_t ext4_grp_offs_to_block(struct super_block *sb, | 225 | static inline ext4_fsblk_t ext4_grp_offs_to_block(struct super_block *sb, |
226 | struct ext4_free_extent *fex) | 226 | struct ext4_free_extent *fex) |
227 | { | 227 | { |
228 | ext4_fsblk_t block; | 228 | return ext4_group_first_block_no(sb, fex->fe_group) + fex->fe_start; |
229 | |||
230 | block = (ext4_fsblk_t) fex->fe_group * EXT4_BLOCKS_PER_GROUP(sb) | ||
231 | + fex->fe_start | ||
232 | + le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block); | ||
233 | return block; | ||
234 | } | 229 | } |
235 | #endif | 230 | #endif |