aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLi Zefan <lizf@cn.fujitsu.com>2011-07-19 23:46:35 -0400
committerChris Mason <chris.mason@oracle.com>2011-08-01 14:30:42 -0400
commitb6973aa62253f3791ef6fa5e9f9de099645fc2bd (patch)
treeeb4fe689723dc89e803a139d0d873dc4c9cd205d
parentb532402e4d147e4f409c4e7f50d4413e8450101d (diff)
Btrfs: fix readahead in file defrag
We passed the wrong value to btrfs_force_ra(). Fix this by changing the argument of btrfs_force_ra() from last_index to nr_page. Signed-off-by: Li Zefan <lizf@cn.fujitsu.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
-rw-r--r--fs/btrfs/ctree.h11
-rw-r--r--fs/btrfs/inode.c13
2 files changed, 8 insertions, 16 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 3be57c611040..7ac4d25fd4f8 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2520,6 +2520,14 @@ int btrfs_lookup_csums_range(struct btrfs_root *root, u64 start, u64 end,
2520#define PageChecked PageFsMisc 2520#define PageChecked PageFsMisc
2521#endif 2521#endif
2522 2522
2523/* This forces readahead on a given range of bytes in an inode */
2524static inline void btrfs_force_ra(struct address_space *mapping,
2525 struct file_ra_state *ra, struct file *file,
2526 pgoff_t offset, unsigned long req_size)
2527{
2528 page_cache_sync_readahead(mapping, ra, file, offset, req_size);
2529}
2530
2523struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry); 2531struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry);
2524int btrfs_set_inode_index(struct inode *dir, u64 *index); 2532int btrfs_set_inode_index(struct inode *dir, u64 *index);
2525int btrfs_unlink_inode(struct btrfs_trans_handle *trans, 2533int btrfs_unlink_inode(struct btrfs_trans_handle *trans,
@@ -2548,9 +2556,6 @@ int btrfs_create_subvol_root(struct btrfs_trans_handle *trans,
2548int btrfs_merge_bio_hook(struct page *page, unsigned long offset, 2556int btrfs_merge_bio_hook(struct page *page, unsigned long offset,
2549 size_t size, struct bio *bio, unsigned long bio_flags); 2557 size_t size, struct bio *bio, unsigned long bio_flags);
2550 2558
2551unsigned long btrfs_force_ra(struct address_space *mapping,
2552 struct file_ra_state *ra, struct file *file,
2553 pgoff_t offset, pgoff_t last_index);
2554int btrfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf); 2559int btrfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf);
2555int btrfs_readpage(struct file *file, struct page *page); 2560int btrfs_readpage(struct file *file, struct page *page);
2556void btrfs_evict_inode(struct inode *inode); 2561void btrfs_evict_inode(struct inode *inode);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 5da43aea205f..69e448eddf09 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -6697,19 +6697,6 @@ int btrfs_create_subvol_root(struct btrfs_trans_handle *trans,
6697 return 0; 6697 return 0;
6698} 6698}
6699 6699
6700/* helper function for file defrag and space balancing. This
6701 * forces readahead on a given range of bytes in an inode
6702 */
6703unsigned long btrfs_force_ra(struct address_space *mapping,
6704 struct file_ra_state *ra, struct file *file,
6705 pgoff_t offset, pgoff_t last_index)
6706{
6707 pgoff_t req_size = last_index - offset + 1;
6708
6709 page_cache_sync_readahead(mapping, ra, file, offset, req_size);
6710 return offset + req_size;
6711}
6712
6713struct inode *btrfs_alloc_inode(struct super_block *sb) 6700struct inode *btrfs_alloc_inode(struct super_block *sb)
6714{ 6701{
6715 struct btrfs_inode *ei; 6702 struct btrfs_inode *ei;