aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext4/inode.c')
-rw-r--r--fs/ext4/inode.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 5b088121686a..5120243024fb 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -547,6 +547,7 @@ static int ext4_alloc_blocks(handle_t *handle, struct inode *inode,
547 int indirect_blks, int blks, 547 int indirect_blks, int blks,
548 ext4_fsblk_t new_blocks[4], int *err) 548 ext4_fsblk_t new_blocks[4], int *err)
549{ 549{
550 struct ext4_allocation_request ar;
550 int target, i; 551 int target, i;
551 unsigned long count = 0, blk_allocated = 0; 552 unsigned long count = 0, blk_allocated = 0;
552 int index = 0; 553 int index = 0;
@@ -595,10 +596,17 @@ static int ext4_alloc_blocks(handle_t *handle, struct inode *inode,
595 if (!target) 596 if (!target)
596 goto allocated; 597 goto allocated;
597 /* Now allocate data blocks */ 598 /* Now allocate data blocks */
598 count = target; 599 memset(&ar, 0, sizeof(ar));
599 /* allocating blocks for data blocks */ 600 ar.inode = inode;
600 current_block = ext4_new_blocks(handle, inode, iblock, 601 ar.goal = goal;
601 goal, &count, err); 602 ar.len = target;
603 ar.logical = iblock;
604 if (S_ISREG(inode->i_mode))
605 /* enable in-core preallocation only for regular files */
606 ar.flags = EXT4_MB_HINT_DATA;
607
608 current_block = ext4_mb_new_blocks(handle, &ar, err);
609
602 if (*err && (target == blks)) { 610 if (*err && (target == blks)) {
603 /* 611 /*
604 * if the allocation failed and we didn't allocate 612 * if the allocation failed and we didn't allocate
@@ -614,7 +622,7 @@ static int ext4_alloc_blocks(handle_t *handle, struct inode *inode,
614 */ 622 */
615 new_blocks[index] = current_block; 623 new_blocks[index] = current_block;
616 } 624 }
617 blk_allocated += count; 625 blk_allocated += ar.len;
618 } 626 }
619allocated: 627allocated:
620 /* total number of blocks allocated for direct blocks */ 628 /* total number of blocks allocated for direct blocks */