summaryrefslogtreecommitdiffstats
path: root/fs/ocfs2
diff options
context:
space:
mode:
authorTao Ma <tao.ma@oracle.com>2010-07-14 11:19:32 +0800
committerJoel Becker <joel.becker@oracle.com>2010-07-15 10:54:28 -0700
commitf5e27b6ddfbafdd9c9c2f06bbf28af12581409bc (patch)
treeb55eb9842a3ee2cfebb6a24ab2ee4ffbd597daee /fs/ocfs2
parente372357ba55ae89307af15cd680467d8f0db4f01 (diff)
downloadop-kernel-dev-f5e27b6ddfbafdd9c9c2f06bbf28af12581409bc.zip
op-kernel-dev-f5e27b6ddfbafdd9c9c2f06bbf28af12581409bc.tar.gz
ocfs2: Don't duplicate pages past i_size during CoW.
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 <tao.ma@oracle.com> Signed-off-by: Joel Becker <joel.becker@oracle.com>
Diffstat (limited to 'fs/ocfs2')
-rw-r--r--fs/ocfs2/refcounttree.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
index 32949df..3ac5aa7 100644
--- a/fs/ocfs2/refcounttree.c
+++ b/fs/ocfs2/refcounttree.c
@@ -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;
OpenPOWER on IntegriCloud