All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joel Becker <jlbec@evilplan.org>
To: ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] [PATCH] Treat writes as new when holes span across page boundaries
Date: Sat, 19 Feb 2011 23:09:54 -0800	[thread overview]
Message-ID: <20110220070953.GC17784@noexit> (raw)
In-Reply-To: <AANLkTi=pEu5y4=kjG1YoLR+YCd7Ak21QaFQz=AR3dffX@mail.gmail.com>

On Thu, Feb 17, 2011 at 09:44:40AM -0600, Goldwyn Rodrigues wrote:
> 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.

	Is this a new approach to your earlier patch, or an additional
change?

> ---
> 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));

	There are two problems here.  First, It's not safe to claim
existing data is 'new'.  Imagine you have a 4K page and a 512B
blocksize.  The first 2 blocks of the page have data in them, but your
code change will cause them to be set_uptodate() even if we haven't read
them in yet.
	Secondly, ocfs2_should_read_blk() already checks for blocks past
i_size and skips reading them.  So if you are trying to avoid reading
them, it is already handled.

Joel

-- 

Life's Little Instruction Book #511

	"Call your mother."

			http://www.jlbec.org/
			jlbec@evilplan.org

  reply	other threads:[~2011-02-20  7:09 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110220070953.GC17784@noexit \
    --to=jlbec@evilplan.org \
    --cc=ocfs2-devel@oss.oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.