From 8057f80c7f223f4f08bd2a0366eb9b8dd919a5aa Mon Sep 17 00:00:00 2001 From: Tao Ma Date: Thu, 17 Jun 2010 14:14:36 +0800 Subject: [PATCH] --- yaml --- r: 212764 b: refs/heads/master c: 7b61cf54a2445ad21df9dd44f0c8bb90154ddea8 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/fs/ocfs2/refcounttree.c | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 0331fb62ee64..05e967e090a8 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 155027121fe52f9b4f25e9d156c22f2f5012e5fe +refs/heads/master: 7b61cf54a2445ad21df9dd44f0c8bb90154ddea8 diff --git a/trunk/fs/ocfs2/refcounttree.c b/trunk/fs/ocfs2/refcounttree.c index 66dab3c0d495..ad08c1134baa 100644 --- a/trunk/fs/ocfs2/refcounttree.c +++ b/trunk/fs/ocfs2/refcounttree.c @@ -3398,6 +3398,28 @@ static int ocfs2_replace_cow(struct ocfs2_cow_context *context) return ret; } +static void ocfs2_readahead_for_cow(struct inode *inode, + struct file *file, + u32 start, u32 len) +{ + struct address_space *mapping; + pgoff_t index; + unsigned long num_pages; + int cs_bits = OCFS2_SB(inode->i_sb)->s_clustersize_bits; + + if (!file) + return; + + mapping = file->f_mapping; + num_pages = (len << cs_bits) >> PAGE_CACHE_SHIFT; + if (!num_pages) + num_pages = 1; + + index = ((loff_t)start << cs_bits) >> PAGE_CACHE_SHIFT; + page_cache_sync_readahead(mapping, &file->f_ra, file, + index, num_pages); +} + /* * Starting at cpos, try to CoW write_len clusters. Don't CoW * past max_cpos. This will stop when it runs into a hole or an @@ -3433,6 +3455,8 @@ static int ocfs2_refcount_cow_hunk(struct inode *inode, BUG_ON(cow_len == 0); + ocfs2_readahead_for_cow(inode, file, cow_start, cow_len); + context = kzalloc(sizeof(struct ocfs2_cow_context), GFP_NOFS); if (!context) { ret = -ENOMEM;