aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2009-09-18 16:07:03 -0400
committerChris Mason <chris.mason@oracle.com>2009-09-18 16:08:52 -0400
commitb917b7c3be50435fa8257591b964934e917f2d45 (patch)
treeefdc2f768da474a4904dc6c065cc6e4b9a2379d3 /fs/btrfs/inode.c
parentf85d7d6c8f2ad4a86a1f4f4e3791f36dede2fa76 (diff)
Btrfs: search for an allocation hint while filling file COW
The allocator has some nice knobs for sending hints about where to try and allocate new blocks, but when we're doing file allocations we're not sending any hint at all. This commit adds a simple extent map search to see if we can quickly and easily find a hint for the allocator. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 941f1b71cd2..81ba6654c33 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -726,6 +726,15 @@ static noinline int cow_file_range(struct inode *inode,
726 BUG_ON(disk_num_bytes > 726 BUG_ON(disk_num_bytes >
727 btrfs_super_total_bytes(&root->fs_info->super_copy)); 727 btrfs_super_total_bytes(&root->fs_info->super_copy));
728 728
729
730 read_lock(&BTRFS_I(inode)->extent_tree.lock);
731 em = search_extent_mapping(&BTRFS_I(inode)->extent_tree,
732 start, num_bytes);
733 if (em) {
734 alloc_hint = em->block_start;
735 free_extent_map(em);
736 }
737 read_unlock(&BTRFS_I(inode)->extent_tree.lock);
729 btrfs_drop_extent_cache(inode, start, start + num_bytes - 1, 0); 738 btrfs_drop_extent_cache(inode, start, start + num_bytes - 1, 0);
730 739
731 while (disk_num_bytes > 0) { 740 while (disk_num_bytes > 0) {
@@ -738,7 +747,6 @@ static noinline int cow_file_range(struct inode *inode,
738 em = alloc_extent_map(GFP_NOFS); 747 em = alloc_extent_map(GFP_NOFS);
739 em->start = start; 748 em->start = start;
740 em->orig_start = em->start; 749 em->orig_start = em->start;
741
742 ram_size = ins.offset; 750 ram_size = ins.offset;
743 em->len = ins.offset; 751 em->len = ins.offset;
744 752