summaryrefslogtreecommitdiffstats
path: root/fs/ext4/balloc.c
diff options
context:
space:
mode:
authorLukas Czerner <lczerner@redhat.com>2013-04-04 05:32:34 +0200
committerTheodore Ts'o <tytso@mit.edu>2013-04-04 05:32:34 +0200
commitbd86298e60b84b5e6d2da3e75c4ce2f6b70bdeed (patch)
tree8da632bbc3acfcc7e7416da820de87d56f2168a4 /fs/ext4/balloc.c
parentext4: make ext4_block_in_group() much more efficient (diff)
downloadlinux-bd86298e60b84b5e6d2da3e75c4ce2f6b70bdeed.tar.xz
linux-bd86298e60b84b5e6d2da3e75c4ce2f6b70bdeed.zip
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/balloc.c')
-rw-r--r--fs/ext4/balloc.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
index d6babf94907e..9e8d8ffb063f 100644
--- a/fs/ext4/balloc.c
+++ b/fs/ext4/balloc.c
@@ -30,6 +30,23 @@ static unsigned ext4_num_base_meta_clusters(struct super_block *sb,
*/
/*
+ * Calculate block group number for a given block number
+ */
+ext4_group_t ext4_get_group_number(struct super_block *sb,
+ ext4_fsblk_t block)
+{
+ ext4_group_t group;
+
+ if (test_opt2(sb, STD_GROUP_SIZE))
+ group = (le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block) +
+ block) >>
+ (EXT4_BLOCK_SIZE_BITS(sb) + EXT4_CLUSTER_BITS(sb) + 3);
+ else
+ ext4_get_group_no_and_offset(sb, block, &group, NULL);
+ return group;
+}
+
+/*
* Calculate the block group number and offset into the block/cluster
* allocation bitmap, given a block number
*/
@@ -59,13 +76,7 @@ static inline int ext4_block_in_group(struct super_block *sb,
{
ext4_group_t actual_group;
- if (test_opt2(sb, STD_GROUP_SIZE))
- actual_group =
- (le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block) +
- block) >>
- (EXT4_BLOCK_SIZE_BITS(sb) + EXT4_CLUSTER_BITS(sb) + 3);
- else
- ext4_get_group_no_and_offset(sb, block, &actual_group, NULL);
+ actual_group = ext4_get_group_number(sb, block);
return (actual_group == block_group) ? 1 : 0;
}