aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/ext4/extents.c8
-rw-r--r--fs/ext4/inode.c8
2 files changed, 14 insertions, 2 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index c4d6f19faf37..8a59f7ba30e6 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -148,6 +148,7 @@ static ext4_fsblk_t ext4_ext_find_goal(struct inode *inode,
148{ 148{
149 struct ext4_inode_info *ei = EXT4_I(inode); 149 struct ext4_inode_info *ei = EXT4_I(inode);
150 ext4_fsblk_t bg_start; 150 ext4_fsblk_t bg_start;
151 ext4_fsblk_t last_block;
151 ext4_grpblk_t colour; 152 ext4_grpblk_t colour;
152 int depth; 153 int depth;
153 154
@@ -169,8 +170,13 @@ static ext4_fsblk_t ext4_ext_find_goal(struct inode *inode,
169 /* OK. use inode's group */ 170 /* OK. use inode's group */
170 bg_start = (ei->i_block_group * EXT4_BLOCKS_PER_GROUP(inode->i_sb)) + 171 bg_start = (ei->i_block_group * EXT4_BLOCKS_PER_GROUP(inode->i_sb)) +
171 le32_to_cpu(EXT4_SB(inode->i_sb)->s_es->s_first_data_block); 172 le32_to_cpu(EXT4_SB(inode->i_sb)->s_es->s_first_data_block);
172 colour = (current->pid % 16) * 173 last_block = ext4_blocks_count(EXT4_SB(inode->i_sb)->s_es) - 1;
174
175 if (bg_start + EXT4_BLOCKS_PER_GROUP(inode->i_sb) <= last_block)
176 colour = (current->pid % 16) *
173 (EXT4_BLOCKS_PER_GROUP(inode->i_sb) / 16); 177 (EXT4_BLOCKS_PER_GROUP(inode->i_sb) / 16);
178 else
179 colour = (current->pid % 16) * ((last_block - bg_start) / 16);
174 return bg_start + colour + block; 180 return bg_start + colour + block;
175} 181}
176 182
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index d3c6f58a9def..34f3eb615fd5 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -403,6 +403,7 @@ static ext4_fsblk_t ext4_find_near(struct inode *inode, Indirect *ind)
403 __le32 *start = ind->bh ? (__le32*) ind->bh->b_data : ei->i_data; 403 __le32 *start = ind->bh ? (__le32*) ind->bh->b_data : ei->i_data;
404 __le32 *p; 404 __le32 *p;
405 ext4_fsblk_t bg_start; 405 ext4_fsblk_t bg_start;
406 ext4_fsblk_t last_block;
406 ext4_grpblk_t colour; 407 ext4_grpblk_t colour;
407 408
408 /* Try to find previous block */ 409 /* Try to find previous block */
@@ -420,8 +421,13 @@ static ext4_fsblk_t ext4_find_near(struct inode *inode, Indirect *ind)
420 * into the same cylinder group then. 421 * into the same cylinder group then.
421 */ 422 */
422 bg_start = ext4_group_first_block_no(inode->i_sb, ei->i_block_group); 423 bg_start = ext4_group_first_block_no(inode->i_sb, ei->i_block_group);
423 colour = (current->pid % 16) * 424 last_block = ext4_blocks_count(EXT4_SB(inode->i_sb)->s_es) - 1;
425
426 if (bg_start + EXT4_BLOCKS_PER_GROUP(inode->i_sb) <= last_block)
427 colour = (current->pid % 16) *
424 (EXT4_BLOCKS_PER_GROUP(inode->i_sb) / 16); 428 (EXT4_BLOCKS_PER_GROUP(inode->i_sb) / 16);
429 else
430 colour = (current->pid % 16) * ((last_block - bg_start) / 16);
425 return bg_start + colour; 431 return bg_start + colour;
426} 432}
427 433