Skip to content

Commit

Permalink
ocfs2: Don't duplicate pages past i_size during CoW.
Browse files Browse the repository at this point in the history
During CoW, the pages after i_size don't contain valid data, so there's
no need to read and duplicate them.

Signed-off-by: Tao Ma <[email protected]>
Signed-off-by: Joel Becker <[email protected]>
  • Loading branch information
Tao Ma authored and Joel Becker committed Jul 15, 2010
1 parent e372357 commit f5e27b6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions fs/ocfs2/refcounttree.c
Original file line number Diff line number Diff line change
Expand Up @@ -2931,6 +2931,12 @@ static int ocfs2_duplicate_clusters_by_page(handle_t *handle,

offset = ((loff_t)cpos) << OCFS2_SB(sb)->s_clustersize_bits;
end = offset + (new_len << OCFS2_SB(sb)->s_clustersize_bits);
/*
* We only duplicate pages until we reach the page contains i_size - 1.
* So trim 'end' to i_size.
*/
if (end > i_size_read(context->inode))
end = i_size_read(context->inode);

while (offset < end) {
page_index = offset >> PAGE_CACHE_SHIFT;
Expand Down

0 comments on commit f5e27b6

Please sign in to comment.