All of lore.kernel.org
 help / color / mirror / Atom feed
* [Ocfs2-devel] [PATCH] ocfs2: Don't duplicate page passes i_size during CoW.
@ 2010-07-12  7:19 Tao Ma
  2010-07-12  9:14 ` Joel Becker
  0 siblings, 1 reply; 13+ messages in thread
From: Tao Ma @ 2010-07-12  7:19 UTC (permalink / raw)
  To: ocfs2-devel

During CoW, actually all the pages after i_size contains
garbage data, so don't read and duplicate them.

Signed-off-by: Tao Ma <tao.ma@oracle.com>
---
 fs/ocfs2/refcounttree.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
index 1cf9cda..e082623 100644
--- a/fs/ocfs2/refcounttree.c
+++ b/fs/ocfs2/refcounttree.c
@@ -2921,7 +2921,7 @@ static int ocfs2_duplicate_clusters_by_page(handle_t *handle,
 	struct super_block *sb = ocfs2_metadata_cache_get_super(ci);
 	u64 new_block = ocfs2_clusters_to_blocks(sb, new_cluster);
 	struct page *page;
-	pgoff_t page_index;
+	pgoff_t page_index, last_page;
 	unsigned int from, to;
 	loff_t offset, end, map_end;
 	struct address_space *mapping = context->inode->i_mapping;
@@ -2932,12 +2932,20 @@ 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);
 
+	last_page = i_size_read(context->inode) >> PAGE_CACHE_SHIFT;
 	while (offset < end) {
 		page_index = offset >> PAGE_CACHE_SHIFT;
 		map_end = ((loff_t)page_index + 1) << PAGE_CACHE_SHIFT;
 		if (map_end > end)
 			map_end = end;
 
+		/*
+		 * If this page is beyond the page contains i_size,
+		 * stop duplicating it.
+		 */
+		if (page_index > last_page)
+			break;
+
 		/* from, to is the offset within the page. */
 		from = offset & (PAGE_CACHE_SIZE - 1);
 		to = PAGE_CACHE_SIZE;
-- 
1.7.1.571.gba4d01

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2010-07-15 21:02 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-12  7:19 [Ocfs2-devel] [PATCH] ocfs2: Don't duplicate page passes i_size during CoW Tao Ma
2010-07-12  9:14 ` Joel Becker
2010-07-13  3:22   ` [Ocfs2-devel] [PATCH v2] " Tao Ma
2010-07-13  8:13     ` Joel Becker
2010-07-13  8:15       ` Joel Becker
2010-07-13 14:25         ` Tao Ma
2010-07-13 18:38           ` Joel Becker
2010-07-14  0:29             ` Tao Ma
2010-07-14  3:19             ` [Ocfs2-devel] [PATCH v5] " Tao Ma
2010-07-15  1:15               ` tristan
2010-07-15 21:02               ` Joel Becker
2010-07-13 14:50       ` [Ocfs2-devel] [PATCH v3] " Tao Ma
2010-07-13 15:30         ` [Ocfs2-devel] [PATCH v4] " Tao Ma

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.