[PATCH v2 20/20] ext4: simplify calculation of blkoff in ext4_mb_new_blocks_simple

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We calculate blkoff for groups as following:
		ext4_get_group_no_and_offset(sb,
			max(ext4_group_first_block_no(sb, group), goal),
			NULL, &blkoff);

For first group, the blkoff is already calculated before loop, so this
is redundant.
For groups after first group which contains goal, the result of
max(...) above is always ext4_group_first_block_no(sb, group). The
blkoff of first block in group is always 0, so blkoff of groups after
the first group which contains goal is always 0.
So we can clean blkoff calculation as following:
1. Remove blkoff calculation above to remove repeat calculation of
first group.
2. Set blkoff to 0 to set blkoff for groups after first group.

Signed-off-by: Kemeng Shi <shikemeng@xxxxxxxxxxxxxxx>
---
 fs/ext4/mballoc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index f65894bfaff2..2cc655de1853 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -5769,9 +5769,6 @@ static ext4_fsblk_t ext4_mb_new_blocks_simple(handle_t *handle,
 			return 0;
 		}
 
-		ext4_get_group_no_and_offset(sb,
-			max(ext4_group_first_block_no(sb, group), goal),
-			NULL, &blkoff);
 		while (1) {
 			i = mb_find_next_zero_bit(bitmap_bh->b_data, max,
 						blkoff);
@@ -5786,6 +5783,8 @@ static ext4_fsblk_t ext4_mb_new_blocks_simple(handle_t *handle,
 		brelse(bitmap_bh);
 		if (i < max)
 			break;
+
+		blkoff = 0;
 	}
 
 	if (group >= ext4_get_groups_count(sb) || i >= max) {
-- 
2.30.0




[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux