All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: ceph-devel@vger.kernel.org
Cc: linux-cachefs@redhat.com, pfmeec@rit.edu, willy@infradead.org,
	dhowells@redhat.com, Andrew W Elble <aweits@rit.edu>
Subject: Re: [RFC PATCH] ceph: fix write_begin optimization when write is beyond EOF
Date: Fri, 11 Jun 2021 11:58:40 -0400	[thread overview]
Message-ID: <44c35af5cc83b5c01fd55c7be6c0c16dd03cea2b.camel@kernel.org> (raw)
In-Reply-To: <20210611155509.76691-1-jlayton@kernel.org>

On Fri, 2021-06-11 at 11:55 -0400, Jeff Layton wrote:
> It's not sufficient to skip reading when the pos is beyond the EOF.
> There may be data at the head of the page that we need to fill in
> before the write. Only elide the read if the pos is beyond the last page
> in the file.
> 
> Reported-by: Andrew W Elble <aweits@rit.edu>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
>  fs/ceph/addr.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> I've not tested this at all yet, but I think this is probably what we'll
> want for stable series v5.10.z - v5.12.z.
> 
> diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
> index 35c83f65475b..9f60f541b423 100644
> --- a/fs/ceph/addr.c
> +++ b/fs/ceph/addr.c
> @@ -1353,11 +1353,11 @@ static int ceph_write_begin(struct file *file, struct address_space *mapping,
>  		/*
>  		 * In some cases we don't need to read at all:
>  		 * - full page write
> -		 * - write that lies completely beyond EOF
> +		 * - write that lies in a page that is completely beyond EOF
>  		 * - write that covers the the page from start to EOF or beyond it
>  		 */
>  		if ((pos_in_page == 0 && len == PAGE_SIZE) ||
> -		    (pos >= i_size_read(inode)) ||
> +		    (index >= (i_size_read(inode) << PAGE_SHIFT)) ||

...and this should be:

		(index > (i_size_read(inode) << PAGE_SHIFT)) ||
			
We only get to skip the read if the write pos is _beyond_ the last page.

>  		    (pos_in_page == 0 && (pos + len) >= i_size_read(inode))) {
>  			zero_user_segments(page, 0, pos_in_page,
>  					   pos_in_page + len, PAGE_SIZE);

-- 
Jeff Layton <jlayton@kernel.org>


      reply	other threads:[~2021-06-11 15:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-11 15:55 [RFC PATCH] ceph: fix write_begin optimization when write is beyond EOF Jeff Layton
2021-06-11 15:58 ` Jeff Layton [this message]

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=44c35af5cc83b5c01fd55c7be6c0c16dd03cea2b.camel@kernel.org \
    --to=jlayton@kernel.org \
    --cc=aweits@rit.edu \
    --cc=ceph-devel@vger.kernel.org \
    --cc=dhowells@redhat.com \
    --cc=linux-cachefs@redhat.com \
    --cc=pfmeec@rit.edu \
    --cc=willy@infradead.org \
    /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.