diff options
author | Chris Mason <chris.mason@oracle.com> | 2008-04-28 09:02:36 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-09-25 11:04:02 -0400 |
commit | 8e7bf94fd5f44fa585e29fbe6a1bfabc04aea7cf (patch) | |
tree | cf7ff2d942c5af49c43a8a7701b32267815c839f /fs/btrfs/inode.c | |
parent | 3bf3d9e9c256e1a249a47bb8ceff682e6430aeff (diff) |
Btrfs: Do more optimal file RA during shrinking and defrag
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 4d12aa532c5b..ab707c0930df 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -2814,14 +2814,12 @@ unsigned long btrfs_force_ra(struct address_space *mapping, | |||
2814 | struct file_ra_state *ra, struct file *file, | 2814 | struct file_ra_state *ra, struct file *file, |
2815 | pgoff_t offset, pgoff_t last_index) | 2815 | pgoff_t offset, pgoff_t last_index) |
2816 | { | 2816 | { |
2817 | pgoff_t req_size; | 2817 | pgoff_t req_size = last_index - offset + 1; |
2818 | 2818 | ||
2819 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23) | 2819 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23) |
2820 | req_size = last_index - offset + 1; | ||
2821 | offset = page_cache_readahead(mapping, ra, file, offset, req_size); | 2820 | offset = page_cache_readahead(mapping, ra, file, offset, req_size); |
2822 | return offset; | 2821 | return offset; |
2823 | #else | 2822 | #else |
2824 | req_size = min(last_index - offset + 1, (pgoff_t)128); | ||
2825 | page_cache_sync_readahead(mapping, ra, file, offset, req_size); | 2823 | page_cache_sync_readahead(mapping, ra, file, offset, req_size); |
2826 | return offset + req_size; | 2824 | return offset + req_size; |
2827 | #endif | 2825 | #endif |
@@ -2833,7 +2831,8 @@ int btrfs_defrag_file(struct file *file) { | |||
2833 | struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree; | 2831 | struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree; |
2834 | struct page *page; | 2832 | struct page *page; |
2835 | unsigned long last_index; | 2833 | unsigned long last_index; |
2836 | unsigned long ra_index = 0; | 2834 | unsigned long ra_pages = root->fs_info->bdi.ra_pages; |
2835 | unsigned long total_read = 0; | ||
2837 | u64 page_start; | 2836 | u64 page_start; |
2838 | u64 page_end; | 2837 | u64 page_end; |
2839 | unsigned long i; | 2838 | unsigned long i; |
@@ -2848,11 +2847,11 @@ int btrfs_defrag_file(struct file *file) { | |||
2848 | mutex_lock(&inode->i_mutex); | 2847 | mutex_lock(&inode->i_mutex); |
2849 | last_index = inode->i_size >> PAGE_CACHE_SHIFT; | 2848 | last_index = inode->i_size >> PAGE_CACHE_SHIFT; |
2850 | for (i = 0; i <= last_index; i++) { | 2849 | for (i = 0; i <= last_index; i++) { |
2851 | if (i == ra_index) { | 2850 | if (total_read % ra_pages == 0) { |
2852 | ra_index = btrfs_force_ra(inode->i_mapping, | 2851 | btrfs_force_ra(inode->i_mapping, &file->f_ra, file, i, |
2853 | &file->f_ra, | 2852 | min(last_index, i + ra_pages - 1)); |
2854 | file, ra_index, last_index); | ||
2855 | } | 2853 | } |
2854 | total_read++; | ||
2856 | page = grab_cache_page(inode->i_mapping, i); | 2855 | page = grab_cache_page(inode->i_mapping, i); |
2857 | if (!page) | 2856 | if (!page) |
2858 | goto out_unlock; | 2857 | goto out_unlock; |