aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/refcounttree.c
diff options
context:
space:
mode:
authorTao Ma <tao.ma@oracle.com>2010-08-11 22:31:34 -0400
committerTao Ma <tao.ma@oracle.com>2010-08-11 22:40:05 -0400
commit6ea4843f53282465f2bdbe5eedde7d8c3081dfdf (patch)
tree60786d137b206cabb5731e3b2903cb5d9d902ab9 /fs/ocfs2/refcounttree.c
parent7b61cf54a2445ad21df9dd44f0c8bb90154ddea8 (diff)
ocfs2: Add readhead during CoW.
In CoW, when we meet with a readahead page, we know it is time to move the readahead window. So carry out a new readahead. Signed-off-by: Tao Ma <tao.ma@oracle.com>
Diffstat (limited to 'fs/ocfs2/refcounttree.c')
-rw-r--r--fs/ocfs2/refcounttree.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
index ad08c1134baa..47549f64224c 100644
--- a/fs/ocfs2/refcounttree.c
+++ b/fs/ocfs2/refcounttree.c
@@ -49,6 +49,7 @@
49 49
50struct ocfs2_cow_context { 50struct ocfs2_cow_context {
51 struct inode *inode; 51 struct inode *inode;
52 struct file *file;
52 u32 cow_start; 53 u32 cow_start;
53 u32 cow_len; 54 u32 cow_len;
54 struct ocfs2_extent_tree data_et; 55 struct ocfs2_extent_tree data_et;
@@ -2922,13 +2923,16 @@ static int ocfs2_duplicate_clusters_by_page(handle_t *handle,
2922 u64 new_block = ocfs2_clusters_to_blocks(sb, new_cluster); 2923 u64 new_block = ocfs2_clusters_to_blocks(sb, new_cluster);
2923 struct page *page; 2924 struct page *page;
2924 pgoff_t page_index; 2925 pgoff_t page_index;
2925 unsigned int from, to; 2926 unsigned int from, to, readahead_pages;
2926 loff_t offset, end, map_end; 2927 loff_t offset, end, map_end;
2927 struct address_space *mapping = context->inode->i_mapping; 2928 struct address_space *mapping = context->inode->i_mapping;
2928 2929
2929 mlog(0, "old_cluster %u, new %u, len %u at offset %u\n", old_cluster, 2930 mlog(0, "old_cluster %u, new %u, len %u at offset %u\n", old_cluster,
2930 new_cluster, new_len, cpos); 2931 new_cluster, new_len, cpos);
2931 2932
2933 readahead_pages =
2934 (ocfs2_cow_contig_clusters(sb) <<
2935 OCFS2_SB(sb)->s_clustersize_bits) >> PAGE_CACHE_SHIFT;
2932 offset = ((loff_t)cpos) << OCFS2_SB(sb)->s_clustersize_bits; 2936 offset = ((loff_t)cpos) << OCFS2_SB(sb)->s_clustersize_bits;
2933 end = offset + (new_len << OCFS2_SB(sb)->s_clustersize_bits); 2937 end = offset + (new_len << OCFS2_SB(sb)->s_clustersize_bits);
2934 /* 2938 /*
@@ -2959,6 +2963,14 @@ static int ocfs2_duplicate_clusters_by_page(handle_t *handle,
2959 if (PAGE_CACHE_SIZE <= OCFS2_SB(sb)->s_clustersize) 2963 if (PAGE_CACHE_SIZE <= OCFS2_SB(sb)->s_clustersize)
2960 BUG_ON(PageDirty(page)); 2964 BUG_ON(PageDirty(page));
2961 2965
2966 if (PageReadahead(page) && context->file) {
2967 page_cache_async_readahead(mapping,
2968 &context->file->f_ra,
2969 context->file,
2970 page, page_index,
2971 readahead_pages);
2972 }
2973
2962 if (!PageUptodate(page)) { 2974 if (!PageUptodate(page)) {
2963 ret = block_read_full_page(page, ocfs2_get_block); 2975 ret = block_read_full_page(page, ocfs2_get_block);
2964 if (ret) { 2976 if (ret) {
@@ -3478,6 +3490,7 @@ static int ocfs2_refcount_cow_hunk(struct inode *inode,
3478 context->ref_root_bh = ref_root_bh; 3490 context->ref_root_bh = ref_root_bh;
3479 context->cow_duplicate_clusters = ocfs2_duplicate_clusters_by_page; 3491 context->cow_duplicate_clusters = ocfs2_duplicate_clusters_by_page;
3480 context->get_clusters = ocfs2_di_get_clusters; 3492 context->get_clusters = ocfs2_di_get_clusters;
3493 context->file = file;
3481 3494
3482 ocfs2_init_dinode_extent_tree(&context->data_et, 3495 ocfs2_init_dinode_extent_tree(&context->data_et,
3483 INODE_CACHE(inode), di_bh); 3496 INODE_CACHE(inode), di_bh);