Merge branch 'cow_readahead' of git://oss.oracle.com/git/tma/linux-2.6 into merge-2

+63 -17
+4 -3
fs/ocfs2/aops.c
··· 1642 1642 return ret; 1643 1643 } 1644 1644 1645 - int ocfs2_write_begin_nolock(struct address_space *mapping, 1645 + int ocfs2_write_begin_nolock(struct file *filp, 1646 + struct address_space *mapping, 1646 1647 loff_t pos, unsigned len, unsigned flags, 1647 1648 struct page **pagep, void **fsdata, 1648 1649 struct buffer_head *di_bh, struct page *mmap_page) ··· 1693 1692 mlog_errno(ret); 1694 1693 goto out; 1695 1694 } else if (ret == 1) { 1696 - ret = ocfs2_refcount_cow(inode, di_bh, 1695 + ret = ocfs2_refcount_cow(inode, filp, di_bh, 1697 1696 wc->w_cpos, wc->w_clen, UINT_MAX); 1698 1697 if (ret) { 1699 1698 mlog_errno(ret); ··· 1855 1854 */ 1856 1855 down_write(&OCFS2_I(inode)->ip_alloc_sem); 1857 1856 1858 - ret = ocfs2_write_begin_nolock(mapping, pos, len, flags, pagep, 1857 + ret = ocfs2_write_begin_nolock(file, mapping, pos, len, flags, pagep, 1859 1858 fsdata, di_bh, NULL); 1860 1859 if (ret) { 1861 1860 mlog_errno(ret);
+2 -1
fs/ocfs2/aops.h
··· 48 48 loff_t pos, unsigned len, unsigned copied, 49 49 struct page *page, void *fsdata); 50 50 51 - int ocfs2_write_begin_nolock(struct address_space *mapping, 51 + int ocfs2_write_begin_nolock(struct file *filp, 52 + struct address_space *mapping, 52 53 loff_t pos, unsigned len, unsigned flags, 53 54 struct page **pagep, void **fsdata, 54 55 struct buffer_head *di_bh, struct page *mmap_page);
+10 -7
fs/ocfs2/file.c
··· 360 360 if (!(ext_flags & OCFS2_EXT_REFCOUNTED)) 361 361 goto out; 362 362 363 - return ocfs2_refcount_cow(inode, fe_bh, cpos, 1, cpos+1); 363 + return ocfs2_refcount_cow(inode, NULL, fe_bh, cpos, 1, cpos+1); 364 364 365 365 out: 366 366 return status; ··· 903 903 zero_clusters = last_cpos - zero_cpos; 904 904 905 905 if (needs_cow) { 906 - rc = ocfs2_refcount_cow(inode, di_bh, zero_cpos, zero_clusters, 907 - UINT_MAX); 906 + rc = ocfs2_refcount_cow(inode, NULL, di_bh, zero_cpos, 907 + zero_clusters, UINT_MAX); 908 908 if (rc) { 909 909 mlog_errno(rc); 910 910 goto out; ··· 2052 2052 } 2053 2053 2054 2054 static int ocfs2_prepare_inode_for_refcount(struct inode *inode, 2055 + struct file *file, 2055 2056 loff_t pos, size_t count, 2056 2057 int *meta_level) 2057 2058 { ··· 2070 2069 2071 2070 *meta_level = 1; 2072 2071 2073 - ret = ocfs2_refcount_cow(inode, di_bh, cpos, clusters, UINT_MAX); 2072 + ret = ocfs2_refcount_cow(inode, file, di_bh, cpos, clusters, UINT_MAX); 2074 2073 if (ret) 2075 2074 mlog_errno(ret); 2076 2075 out: ··· 2078 2077 return ret; 2079 2078 } 2080 2079 2081 - static int ocfs2_prepare_inode_for_write(struct dentry *dentry, 2080 + static int ocfs2_prepare_inode_for_write(struct file *file, 2082 2081 loff_t *ppos, 2083 2082 size_t count, 2084 2083 int appending, ··· 2086 2085 int *has_refcount) 2087 2086 { 2088 2087 int ret = 0, meta_level = 0; 2088 + struct dentry *dentry = file->f_path.dentry; 2089 2089 struct inode *inode = dentry->d_inode; 2090 2090 loff_t saved_pos, end; 2091 2091 ··· 2142 2140 meta_level = -1; 2143 2141 2144 2142 ret = ocfs2_prepare_inode_for_refcount(inode, 2143 + file, 2145 2144 saved_pos, 2146 2145 count, 2147 2146 &meta_level); ··· 2257 2254 } 2258 2255 2259 2256 can_do_direct = direct_io; 2260 - ret = ocfs2_prepare_inode_for_write(file->f_path.dentry, ppos, 2257 + ret = ocfs2_prepare_inode_for_write(file, ppos, 2261 2258 iocb->ki_left, appending, 2262 2259 &can_do_direct, &has_refcount); 2263 2260 if (ret < 0) { ··· 2376 2373 { 2377 2374 int ret; 2378 2375 2379 - ret = ocfs2_prepare_inode_for_write(out->f_path.dentry, &sd->pos, 2376 + ret = ocfs2_prepare_inode_for_write(out, &sd->pos, 2380 2377 sd->total_len, 0, NULL, NULL); 2381 2378 if (ret < 0) { 2382 2379 mlog_errno(ret);
+4 -3
fs/ocfs2/mmap.c
··· 59 59 return ret; 60 60 } 61 61 62 - static int __ocfs2_page_mkwrite(struct inode *inode, struct buffer_head *di_bh, 62 + static int __ocfs2_page_mkwrite(struct file *file, struct buffer_head *di_bh, 63 63 struct page *page) 64 64 { 65 65 int ret; 66 + struct inode *inode = file->f_path.dentry->d_inode; 66 67 struct address_space *mapping = inode->i_mapping; 67 68 loff_t pos = page_offset(page); 68 69 unsigned int len = PAGE_CACHE_SIZE; ··· 112 111 if (page->index == last_index) 113 112 len = ((size - 1) & ~PAGE_CACHE_MASK) + 1; 114 113 115 - ret = ocfs2_write_begin_nolock(mapping, pos, len, 0, &locked_page, 114 + ret = ocfs2_write_begin_nolock(file, mapping, pos, len, 0, &locked_page, 116 115 &fsdata, di_bh, page); 117 116 if (ret) { 118 117 if (ret != -ENOSPC) ··· 160 159 */ 161 160 down_write(&OCFS2_I(inode)->ip_alloc_sem); 162 161 163 - ret = __ocfs2_page_mkwrite(inode, di_bh, page); 162 + ret = __ocfs2_page_mkwrite(vma->vm_file, di_bh, page); 164 163 165 164 up_write(&OCFS2_I(inode)->ip_alloc_sem); 166 165
+41 -2
fs/ocfs2/refcounttree.c
··· 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; ··· 2933 2932 u64 new_block = ocfs2_clusters_to_blocks(sb, new_cluster); 2934 2933 struct page *page; 2935 2934 pgoff_t page_index; 2936 - unsigned int from, to; 2935 + unsigned int from, to, readahead_pages; 2937 2936 loff_t offset, end, map_end; 2938 2937 struct address_space *mapping = context->inode->i_mapping; 2939 2938 2940 2939 mlog(0, "old_cluster %u, new %u, len %u at offset %u\n", old_cluster, 2941 2940 new_cluster, new_len, cpos); 2942 2941 2942 + readahead_pages = 2943 + (ocfs2_cow_contig_clusters(sb) << 2944 + OCFS2_SB(sb)->s_clustersize_bits) >> PAGE_CACHE_SHIFT; 2943 2945 offset = ((loff_t)cpos) << OCFS2_SB(sb)->s_clustersize_bits; 2944 2946 end = offset + (new_len << OCFS2_SB(sb)->s_clustersize_bits); 2945 2947 /* ··· 2972 2968 */ 2973 2969 if (PAGE_CACHE_SIZE <= OCFS2_SB(sb)->s_clustersize) 2974 2970 BUG_ON(PageDirty(page)); 2971 + 2972 + if (PageReadahead(page) && context->file) { 2973 + page_cache_async_readahead(mapping, 2974 + &context->file->f_ra, 2975 + context->file, 2976 + page, page_index, 2977 + readahead_pages); 2978 + } 2975 2979 2976 2980 if (!PageUptodate(page)) { 2977 2981 ret = block_read_full_page(page, ocfs2_get_block); ··· 3421 3409 return ret; 3422 3410 } 3423 3411 3412 + static void ocfs2_readahead_for_cow(struct inode *inode, 3413 + struct file *file, 3414 + u32 start, u32 len) 3415 + { 3416 + struct address_space *mapping; 3417 + pgoff_t index; 3418 + unsigned long num_pages; 3419 + int cs_bits = OCFS2_SB(inode->i_sb)->s_clustersize_bits; 3420 + 3421 + if (!file) 3422 + return; 3423 + 3424 + mapping = file->f_mapping; 3425 + num_pages = (len << cs_bits) >> PAGE_CACHE_SHIFT; 3426 + if (!num_pages) 3427 + num_pages = 1; 3428 + 3429 + index = ((loff_t)start << cs_bits) >> PAGE_CACHE_SHIFT; 3430 + page_cache_sync_readahead(mapping, &file->f_ra, file, 3431 + index, num_pages); 3432 + } 3433 + 3424 3434 /* 3425 3435 * Starting at cpos, try to CoW write_len clusters. Don't CoW 3426 3436 * past max_cpos. This will stop when it runs into a hole or an 3427 3437 * unrefcounted extent. 3428 3438 */ 3429 3439 static int ocfs2_refcount_cow_hunk(struct inode *inode, 3440 + struct file *file, 3430 3441 struct buffer_head *di_bh, 3431 3442 u32 cpos, u32 write_len, u32 max_cpos) 3432 3443 { ··· 3478 3443 3479 3444 BUG_ON(cow_len == 0); 3480 3445 3446 + ocfs2_readahead_for_cow(inode, file, cow_start, cow_len); 3447 + 3481 3448 context = kzalloc(sizeof(struct ocfs2_cow_context), GFP_NOFS); 3482 3449 if (!context) { 3483 3450 ret = -ENOMEM; ··· 3501 3464 context->ref_root_bh = ref_root_bh; 3502 3465 context->cow_duplicate_clusters = ocfs2_duplicate_clusters_by_page; 3503 3466 context->get_clusters = ocfs2_di_get_clusters; 3467 + context->file = file; 3504 3468 3505 3469 ocfs2_init_dinode_extent_tree(&context->data_et, 3506 3470 INODE_CACHE(inode), di_bh); ··· 3530 3492 * clusters between cpos and cpos+write_len are safe to modify. 3531 3493 */ 3532 3494 int ocfs2_refcount_cow(struct inode *inode, 3495 + struct file *file, 3533 3496 struct buffer_head *di_bh, 3534 3497 u32 cpos, u32 write_len, u32 max_cpos) 3535 3498 { ··· 3550 3511 num_clusters = write_len; 3551 3512 3552 3513 if (ext_flags & OCFS2_EXT_REFCOUNTED) { 3553 - ret = ocfs2_refcount_cow_hunk(inode, di_bh, cpos, 3514 + ret = ocfs2_refcount_cow_hunk(inode, file, di_bh, cpos, 3554 3515 num_clusters, max_cpos); 3555 3516 if (ret) { 3556 3517 mlog_errno(ret);
+2 -1
fs/ocfs2/refcounttree.h
··· 52 52 u32 clusters, 53 53 int *credits, 54 54 int *ref_blocks); 55 - int ocfs2_refcount_cow(struct inode *inode, struct buffer_head *di_bh, 55 + int ocfs2_refcount_cow(struct inode *inode, 56 + struct file *filep, struct buffer_head *di_bh, 56 57 u32 cpos, u32 write_len, u32 max_cpos); 57 58 58 59 typedef int (ocfs2_post_refcount_func)(struct inode *inode,