summaryrefslogtreecommitdiffstats
path: root/fs/ext4/indirect.c
diff options
context:
space:
mode:
authorEric Sandeen <sandeen@redhat.com>2011-06-28 10:01:31 -0400
committerTheodore Ts'o <tytso@mit.edu>2011-06-28 10:01:31 -0400
commitf86186b44b4164600cce03d0d93ad48ec21fa429 (patch)
tree48aafabbbe46d22de84e4e9b3ebf7c5b35fd6d1e /fs/ext4/indirect.c
parentdae1e52cb1267bf8f52e5e47a80fab566d7e8aa4 (diff)
downloadop-kernel-dev-f86186b44b4164600cce03d0d93ad48ec21fa429.zip
op-kernel-dev-f86186b44b4164600cce03d0d93ad48ec21fa429.tar.gz
ext4: refactor duplicated block placement code
I found that ext4_ext_find_goal() and ext4_find_near() share the same code for returning a coloured start block based on i_block_group. We can refactor this into a common function so that they don't diverge in the future. Thanks to adilger for suggesting the new function name. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/indirect.c')
-rw-r--r--fs/ext4/indirect.c28
1 files changed, 1 insertions, 27 deletions
diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c
index c3e85a8..6c27111 100644
--- a/fs/ext4/indirect.c
+++ b/fs/ext4/indirect.c
@@ -207,11 +207,6 @@ static ext4_fsblk_t ext4_find_near(struct inode *inode, Indirect *ind)
struct ext4_inode_info *ei = EXT4_I(inode);
__le32 *start = ind->bh ? (__le32 *) ind->bh->b_data : ei->i_data;
__le32 *p;
- ext4_fsblk_t bg_start;
- ext4_fsblk_t last_block;
- ext4_grpblk_t colour;
- ext4_group_t block_group;
- int flex_size = ext4_flex_bg_size(EXT4_SB(inode->i_sb));
/* Try to find previous block */
for (p = ind->p - 1; p >= start; p--) {
@@ -227,28 +222,7 @@ static ext4_fsblk_t ext4_find_near(struct inode *inode, Indirect *ind)
* It is going to be referred to from the inode itself? OK, just put it
* into the same cylinder group then.
*/
- block_group = ei->i_block_group;
- if (flex_size >= EXT4_FLEX_SIZE_DIR_ALLOC_SCHEME) {
- block_group &= ~(flex_size-1);
- if (S_ISREG(inode->i_mode))
- block_group++;
- }
- bg_start = ext4_group_first_block_no(inode->i_sb, block_group);
- last_block = ext4_blocks_count(EXT4_SB(inode->i_sb)->s_es) - 1;
-
- /*
- * If we are doing delayed allocation, we don't need take
- * colour into account.
- */
- if (test_opt(inode->i_sb, DELALLOC))
- return bg_start;
-
- if (bg_start + EXT4_BLOCKS_PER_GROUP(inode->i_sb) <= last_block)
- colour = (current->pid % 16) *
- (EXT4_BLOCKS_PER_GROUP(inode->i_sb) / 16);
- else
- colour = (current->pid % 16) * ((last_block - bg_start) / 16);
- return bg_start + colour;
+ return ext4_inode_to_goal_block(inode);
}
/**
OpenPOWER on IntegriCloud