ocfs2-devel.oss.oracle.com archive mirror
 help / color / mirror / Atom feed
* [Ocfs2-devel] [PATCH] Treat writes as new when holes span across page boundaries
@ 2011-02-17 15:44 Goldwyn Rodrigues
  2011-02-20  7:09 ` Joel Becker
  2011-03-26 22:48 ` Joel Becker
  0 siblings, 2 replies; 34+ messages in thread
From: Goldwyn Rodrigues @ 2011-02-17 15:44 UTC (permalink / raw)
  To: ocfs2-devel

When a hole spans across page boundaries, the next write forces
a read of the block. This could end up reading existing garbage
data from the disk in ocfs2_map_page_blocks. This leads to
non-zero holes. In order to avoid this, mark the writes as new
when the holes span across page boundaries.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.de>

---
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index 1fbb0e2..4be220d 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -1026,6 +1026,12 @@ static int ocfs2_prepare_page_for_write(struct
inode *inode, u64 *p_blkno,
 	ocfs2_figure_cluster_boundaries(OCFS2_SB(inode->i_sb), cpos,
 					&cluster_start, &cluster_end);

+	/* treat the write as new if the a hole/lseek spanned across
+	 * the page boundary.
+	 */
+	new = new | ((i_size_read(inode) <= page_offset(page)) &&
+			(page_offset(page) <= user_pos));
+
 	if (page == wc->w_target_page) {
 		map_from = user_pos & (PAGE_CACHE_SIZE - 1);
 		map_to = map_from + user_len;

-- 
Goldwyn

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

end of thread, other threads:[~2011-03-26 22:48 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-17 15:44 [Ocfs2-devel] [PATCH] Treat writes as new when holes span across page boundaries Goldwyn Rodrigues
2011-02-20  7:09 ` Joel Becker
2011-02-20 18:45   ` Goldwyn Rodrigues
2011-02-21  2:08     ` Joel Becker
2011-02-21  5:44       ` Goldwyn Rodrigues
2011-02-22  8:36         ` Joel Becker
2011-02-22  9:37           ` Joel Becker
2011-02-22 19:02           ` Goldwyn Rodrigues
2011-02-22 21:39             ` Joel Becker
2011-02-22 21:54               ` Joel Becker
2011-02-22 22:09                 ` Goldwyn Rodrigues
2011-02-22 23:34                   ` Joel Becker
2011-02-23  0:05                     ` Goldwyn Rodrigues
2011-02-23  9:39                       ` Joel Becker
2011-02-23 14:43                         ` Goldwyn Rodrigues
2011-02-23 19:13                           ` Joel Becker
2011-02-23 19:28                             ` Joel Becker
2011-02-23 21:00                               ` Goldwyn Rodrigues
2011-02-23 21:23                                 ` Joel Becker
2011-02-23 20:54                             ` Goldwyn Rodrigues
2011-02-23 21:17                               ` Joel Becker
2011-02-23 21:35                                 ` Goldwyn Rodrigues
2011-02-23 21:37                                   ` Joel Becker
2011-02-23 21:44                                     ` Joel Becker
2011-02-23 22:31                                       ` Goldwyn Rodrigues
2011-02-28 18:03                                         ` Joel Becker
2011-02-28 19:07                                           ` Goldwyn Rodrigues
2011-02-28 19:40                                             ` Joel Becker
2011-03-01  2:11                                               ` Goldwyn Rodrigues
2011-02-24 16:32                                       ` Goldwyn Rodrigues
2011-02-24 18:16                                         ` Mark Fasheh
2011-02-23 21:09                             ` Goldwyn Rodrigues
2011-02-23 21:21                               ` Joel Becker
2011-03-26 22:48 ` Joel Becker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).