linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: David Sterba <dsterba@suse.cz>
Cc: Josef Bacik <josef@toxicpanda.com>,
	linux-btrfs@vger.kernel.org, kernel-team@fb.com,
	stable@vger.kernel.org
Subject: Re: [PATCH] btrfs: save i_size in compress_file_range
Date: Mon, 4 Nov 2019 20:59:33 +0100	[thread overview]
Message-ID: <20191104195933.GG3001@twin.jikos.cz> (raw)
In-Reply-To: <20191023165102.GC3001@twin.jikos.cz>

On Wed, Oct 23, 2019 at 06:51:02PM +0200, David Sterba wrote:
> On Fri, Oct 11, 2019 at 09:03:54AM -0400, Josef Bacik wrote:
> > --- a/fs/btrfs/inode.c
> > +++ b/fs/btrfs/inode.c
> > @@ -474,6 +474,7 @@ static noinline int compress_file_range(struct async_chunk *async_chunk)
> >  	u64 start = async_chunk->start;
> >  	u64 end = async_chunk->end;
> >  	u64 actual_end;
> > +	loff_t i_size = i_size_read(inode);
> >  	int ret = 0;
> >  	struct page **pages = NULL;
> >  	unsigned long nr_pages;
> > @@ -488,7 +489,13 @@ static noinline int compress_file_range(struct async_chunk *async_chunk)
> >  	inode_should_defrag(BTRFS_I(inode), start, end, end - start + 1,
> >  			SZ_16K);
> >  
> > -	actual_end = min_t(u64, i_size_read(inode), end + 1);
> > +	/*
> > +	 * We need to save i_size before now because it could change in between
> > +	 * us evaluating the size and assigning it.  This is because we lock and
> > +	 * unlock the page in truncate and fallocate, and then modify the i_size
> > +	 * later on.
> > +	 */
> > +	actual_end = min_t(u64, i_size, end + 1);
> 
> Ping. This is not a future proof fix, please update the changelog and
> code according to the reply I sent.

The vfs i_size_read patch is being ignored so I guess we're on our own.
I have postponed last weeks pull request so I'll add this patch on top
and send in a day or two. The READ_ONCE will be simulated by barrier()s,
I've verified the assembly and actually that's alwo what read once does
among other things.

      reply	other threads:[~2019-11-04 19:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-11 13:03 [PATCH] btrfs: save i_size in compress_file_range Josef Bacik
2019-10-11 15:28 ` Filipe Manana
2019-10-11 17:15   ` Josef Bacik
2019-10-14 11:52 ` David Sterba
2019-10-23 16:51 ` David Sterba
2019-11-04 19:59   ` David Sterba [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=20191104195933.GG3001@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=josef@toxicpanda.com \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=stable@vger.kernel.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 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).