aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/resize.c
diff options
context:
space:
mode:
authorLukas Czerner <lczerner@redhat.com>2013-04-03 23:32:34 -0400
committerTheodore Ts'o <tytso@mit.edu>2013-04-03 23:32:34 -0400
commitbd86298e60b84b5e6d2da3e75c4ce2f6b70bdeed (patch)
tree8da632bbc3acfcc7e7416da820de87d56f2168a4 /fs/ext4/resize.c
parent689110098c7df10fab8800d3bf8e727c21f426fb (diff)
ext4: introduce ext4_get_group_number()
Currently on many places in ext4 we're using ext4_get_group_no_and_offset() even though we're only interested in knowing the block group of the particular block, not the offset within the block group so we can use more efficient way to compute block group. This patch introduces ext4_get_group_number() which computes block group for a given block much more efficiently. Use this function instead of ext4_get_group_no_and_offset() everywhere where we're only interested in knowing the block group. Signed-off-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/resize.c')
-rw-r--r--fs/ext4/resize.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
index c169477a62c9..e3498534a2c1 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -272,7 +272,7 @@ next_group:
272 if (start_blk >= last_blk) 272 if (start_blk >= last_blk)
273 goto next_group; 273 goto next_group;
274 group_data[bb_index].block_bitmap = start_blk++; 274 group_data[bb_index].block_bitmap = start_blk++;
275 ext4_get_group_no_and_offset(sb, start_blk - 1, &group, NULL); 275 group = ext4_get_group_number(sb, start_blk - 1);
276 group -= group_data[0].group; 276 group -= group_data[0].group;
277 group_data[group].free_blocks_count--; 277 group_data[group].free_blocks_count--;
278 if (flexbg_size > 1) 278 if (flexbg_size > 1)
@@ -284,7 +284,7 @@ next_group:
284 if (start_blk >= last_blk) 284 if (start_blk >= last_blk)
285 goto next_group; 285 goto next_group;
286 group_data[ib_index].inode_bitmap = start_blk++; 286 group_data[ib_index].inode_bitmap = start_blk++;
287 ext4_get_group_no_and_offset(sb, start_blk - 1, &group, NULL); 287 group = ext4_get_group_number(sb, start_blk - 1);
288 group -= group_data[0].group; 288 group -= group_data[0].group;
289 group_data[group].free_blocks_count--; 289 group_data[group].free_blocks_count--;
290 if (flexbg_size > 1) 290 if (flexbg_size > 1)
@@ -296,7 +296,7 @@ next_group:
296 if (start_blk + EXT4_SB(sb)->s_itb_per_group > last_blk) 296 if (start_blk + EXT4_SB(sb)->s_itb_per_group > last_blk)
297 goto next_group; 297 goto next_group;
298 group_data[it_index].inode_table = start_blk; 298 group_data[it_index].inode_table = start_blk;
299 ext4_get_group_no_and_offset(sb, start_blk, &group, NULL); 299 group = ext4_get_group_number(sb, start_blk - 1);
300 group -= group_data[0].group; 300 group -= group_data[0].group;
301 group_data[group].free_blocks_count -= 301 group_data[group].free_blocks_count -=
302 EXT4_SB(sb)->s_itb_per_group; 302 EXT4_SB(sb)->s_itb_per_group;
@@ -392,7 +392,7 @@ static int set_flexbg_block_bitmap(struct super_block *sb, handle_t *handle,
392 ext4_group_t group; 392 ext4_group_t group;
393 int err; 393 int err;
394 394
395 ext4_get_group_no_and_offset(sb, block, &group, NULL); 395 group = ext4_get_group_number(sb, block);
396 start = ext4_group_first_block_no(sb, group); 396 start = ext4_group_first_block_no(sb, group);
397 group -= flex_gd->groups[0].group; 397 group -= flex_gd->groups[0].group;
398 398
@@ -1879,7 +1879,7 @@ retry:
1879 /* Nothing need to do */ 1879 /* Nothing need to do */
1880 return 0; 1880 return 0;
1881 1881
1882 ext4_get_group_no_and_offset(sb, n_blocks_count - 1, &n_group, &offset); 1882 n_group = ext4_get_group_number(sb, n_blocks_count - 1);
1883 ext4_get_group_no_and_offset(sb, o_blocks_count - 1, &o_group, &offset); 1883 ext4_get_group_no_and_offset(sb, o_blocks_count - 1, &o_group, &offset);
1884 1884
1885 n_desc_blocks = num_desc_blocks(sb, n_group + 1); 1885 n_desc_blocks = num_desc_blocks(sb, n_group + 1);