diff options
| author | Tao Ma <tao.ma@oracle.com> | 2010-06-17 02:14:36 -0400 |
|---|---|---|
| committer | Tao Ma <tao.ma@oracle.com> | 2010-08-11 22:40:01 -0400 |
| commit | 7b61cf54a2445ad21df9dd44f0c8bb90154ddea8 (patch) | |
| tree | d170c7e635f3c7a1c74551065e9c51ab8b8f24b8 | |
| parent | 155027121fe52f9b4f25e9d156c22f2f5012e5fe (diff) | |
ocfs2: Add readahead support for CoW.
Add a new function ocfs2_readahead_for_cow so that
we start readahead before we start our CoW.
Signed-off-by: Tao Ma <tao.ma@oracle.com>
| -rw-r--r-- | fs/ocfs2/refcounttree.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index 66dab3c0d49..ad08c1134ba 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c | |||
| @@ -3398,6 +3398,28 @@ static int ocfs2_replace_cow(struct ocfs2_cow_context *context) | |||
| 3398 | return ret; | 3398 | return ret; |
| 3399 | } | 3399 | } |
| 3400 | 3400 | ||
| 3401 | static void ocfs2_readahead_for_cow(struct inode *inode, | ||
| 3402 | struct file *file, | ||
| 3403 | u32 start, u32 len) | ||
| 3404 | { | ||
| 3405 | struct address_space *mapping; | ||
| 3406 | pgoff_t index; | ||
| 3407 | unsigned long num_pages; | ||
| 3408 | int cs_bits = OCFS2_SB(inode->i_sb)->s_clustersize_bits; | ||
| 3409 | |||
| 3410 | if (!file) | ||
| 3411 | return; | ||
| 3412 | |||
| 3413 | mapping = file->f_mapping; | ||
| 3414 | num_pages = (len << cs_bits) >> PAGE_CACHE_SHIFT; | ||
| 3415 | if (!num_pages) | ||
| 3416 | num_pages = 1; | ||
| 3417 | |||
| 3418 | index = ((loff_t)start << cs_bits) >> PAGE_CACHE_SHIFT; | ||
| 3419 | page_cache_sync_readahead(mapping, &file->f_ra, file, | ||
| 3420 | index, num_pages); | ||
| 3421 | } | ||
| 3422 | |||
| 3401 | /* | 3423 | /* |
| 3402 | * Starting at cpos, try to CoW write_len clusters. Don't CoW | 3424 | * Starting at cpos, try to CoW write_len clusters. Don't CoW |
| 3403 | * past max_cpos. This will stop when it runs into a hole or an | 3425 | * 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, | |||
| 3433 | 3455 | ||
| 3434 | BUG_ON(cow_len == 0); | 3456 | BUG_ON(cow_len == 0); |
| 3435 | 3457 | ||
| 3458 | ocfs2_readahead_for_cow(inode, file, cow_start, cow_len); | ||
| 3459 | |||
| 3436 | context = kzalloc(sizeof(struct ocfs2_cow_context), GFP_NOFS); | 3460 | context = kzalloc(sizeof(struct ocfs2_cow_context), GFP_NOFS); |
| 3437 | if (!context) { | 3461 | if (!context) { |
| 3438 | ret = -ENOMEM; | 3462 | ret = -ENOMEM; |
