aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
authorChris Mason <clm@fb.com>2015-10-21 22:00:38 -0400
committerChris Mason <clm@fb.com>2015-10-21 22:00:38 -0400
commita9e6d153563d2ed69c6cd7fb4fa5ce4ca7c712eb (patch)
tree43fab2a259934e1f1dde9607610424d6089dba5e /fs/btrfs/inode.c
parent56fa9d0762ed17153c1bdff3c0aeeecbe522b504 (diff)
parent0584f718ed1f351fca5047a4b1ebba9b5ea41215 (diff)
Merge branch 'allocator-fixes' into for-linus-4.4
Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index df6b93f6b393..a018e4707dac 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -9745,6 +9745,7 @@ static int __btrfs_prealloc_file_range(struct inode *inode, int mode,
9745 u64 cur_offset = start; 9745 u64 cur_offset = start;
9746 u64 i_size; 9746 u64 i_size;
9747 u64 cur_bytes; 9747 u64 cur_bytes;
9748 u64 last_alloc = (u64)-1;
9748 int ret = 0; 9749 int ret = 0;
9749 bool own_trans = true; 9750 bool own_trans = true;
9750 9751
@@ -9761,6 +9762,13 @@ static int __btrfs_prealloc_file_range(struct inode *inode, int mode,
9761 9762
9762 cur_bytes = min(num_bytes, 256ULL * 1024 * 1024); 9763 cur_bytes = min(num_bytes, 256ULL * 1024 * 1024);
9763 cur_bytes = max(cur_bytes, min_size); 9764 cur_bytes = max(cur_bytes, min_size);
9765 /*
9766 * If we are severely fragmented we could end up with really
9767 * small allocations, so if the allocator is returning small
9768 * chunks lets make its job easier by only searching for those
9769 * sized chunks.
9770 */
9771 cur_bytes = min(cur_bytes, last_alloc);
9764 ret = btrfs_reserve_extent(root, cur_bytes, min_size, 0, 9772 ret = btrfs_reserve_extent(root, cur_bytes, min_size, 0,
9765 *alloc_hint, &ins, 1, 0); 9773 *alloc_hint, &ins, 1, 0);
9766 if (ret) { 9774 if (ret) {
@@ -9769,6 +9777,7 @@ static int __btrfs_prealloc_file_range(struct inode *inode, int mode,
9769 break; 9777 break;
9770 } 9778 }
9771 9779
9780 last_alloc = ins.offset;
9772 ret = insert_reserved_file_extent(trans, inode, 9781 ret = insert_reserved_file_extent(trans, inode,
9773 cur_offset, ins.objectid, 9782 cur_offset, ins.objectid,
9774 ins.offset, ins.offset, 9783 ins.offset, ins.offset,