|
49 | 49 |
|
50 | 50 | struct ocfs2_cow_context { |
51 | 51 | struct inode *inode; |
| 52 | + struct file *file; |
52 | 53 | u32 cow_start; |
53 | 54 | u32 cow_len; |
54 | 55 | struct ocfs2_extent_tree data_et; |
@@ -2922,13 +2923,16 @@ static int ocfs2_duplicate_clusters_by_page(handle_t *handle, |
2922 | 2923 | u64 new_block = ocfs2_clusters_to_blocks(sb, new_cluster); |
2923 | 2924 | struct page *page; |
2924 | 2925 | pgoff_t page_index; |
2925 | | - unsigned int from, to; |
| 2926 | + unsigned int from, to, readahead_pages; |
2926 | 2927 | loff_t offset, end, map_end; |
2927 | 2928 | struct address_space *mapping = context->inode->i_mapping; |
2928 | 2929 |
|
2929 | 2930 | mlog(0, "old_cluster %u, new %u, len %u at offset %u\n", old_cluster, |
2930 | 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 | 2936 | offset = ((loff_t)cpos) << OCFS2_SB(sb)->s_clustersize_bits; |
2933 | 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 | 2963 | if (PAGE_CACHE_SIZE <= OCFS2_SB(sb)->s_clustersize) |
2960 | 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 | 2974 | if (!PageUptodate(page)) { |
2963 | 2975 | ret = block_read_full_page(page, ocfs2_get_block); |
2964 | 2976 | if (ret) { |
@@ -3478,6 +3490,7 @@ static int ocfs2_refcount_cow_hunk(struct inode *inode, |
3478 | 3490 | context->ref_root_bh = ref_root_bh; |
3479 | 3491 | context->cow_duplicate_clusters = ocfs2_duplicate_clusters_by_page; |
3480 | 3492 | context->get_clusters = ocfs2_di_get_clusters; |
| 3493 | + context->file = file; |
3481 | 3494 |
|
3482 | 3495 | ocfs2_init_dinode_extent_tree(&context->data_et, |
3483 | 3496 | INODE_CACHE(inode), di_bh); |
|
0 commit comments