linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Moyer <jmoyer@redhat.com>
To: Dave Chinner <david@fromorbit.com>
Cc: viro@zeniv.linux.org.uk, Lukas Czerner <lczerner@redhat.com>,
	linux-fsdevel@vger.kernel.org, jack@suse.cz, hch@infradead.org
Subject: Re: [PATCH v5] fs: Fix page cache inconsistency when mixing buffered and AIO DIO
Date: Mon, 07 Aug 2017 11:52:45 -0400	[thread overview]
Message-ID: <x497eyfs7ci.fsf@segfault.boston.devel.redhat.com> (raw)
In-Reply-To: <20170804100909.GD21024@dastard> (Dave Chinner's message of "Fri, 4 Aug 2017 20:09:09 +1000")

Dave Chinner <david@fromorbit.com> writes:

> On Thu, Aug 03, 2017 at 02:10:47PM -0400, Jeff Moyer wrote:
>> Al, would you mind taking this in through your tree?  It's been reviewed
>> by myself and Jan in this mail thread.
>
> Still needs more fixing, I think?
>
> Sorry, this is the first time I've seen this patch....
>
>> > diff --git a/fs/iomap.c b/fs/iomap.c
>> > index 1732228..144512e 100644
>> > --- a/fs/iomap.c
>> > +++ b/fs/iomap.c
>> > @@ -713,8 +713,15 @@ struct iomap_dio {
>> >  static ssize_t iomap_dio_complete(struct iomap_dio *dio)
>> >  {
>> >  	struct kiocb *iocb = dio->iocb;
>> > +	struct inode *inode = file_inode(iocb->ki_filp);
>> >  	ssize_t ret;
>> >  
>> > +	if (!dio->error &&
>> > +	    (dio->flags & IOMAP_DIO_WRITE) && inode->i_mapping->nrpages)
>> > +		invalidate_inode_pages2_range(inode->i_mapping,
>> > +				iocb->ki_pos >> PAGE_SHIFT,
>> > +				(iocb->ki_pos + dio->size - 1) >> PAGE_SHIFT);
>> > +
>> >  	if (dio->end_io) {
>> >  		ret = dio->end_io(iocb,
>> >  				dio->error ? dio->error : dio->size,
>> 
>
> This invalidation is already run in iomap_dio_rw() for the sync IO
> case directly after the call to iomap_dio_complete().  It also has a
> comment to explain exactly why the the invalidation is needed, and
> it issues a warning to dmesg if the invalidation fails to indicate
> the reason why the user is reporting data corruption to us. i.e.:
>
> .....
>         ret = iomap_dio_complete(dio);
>
>         /*
>          * Try again to invalidate clean pages which might have been cached by
>          * non-direct readahead, or faulted in by get_user_pages() if the source
>          * of the write was an mmap'ed region of the file we're writing.  Either
>          * one is a pretty crazy thing to do, so we don't support it 100%.  If
>          * this invalidation fails, tough, the write still worked...
>          */
>         if (iov_iter_rw(iter) == WRITE) {
>                 int err = invalidate_inode_pages2_range(mapping,
>                                 start >> PAGE_SHIFT, end >> PAGE_SHIFT);
>                 WARN_ON_ONCE(err);
>         }
>
>         return ret;
>
> If we're going to replace this with an invalidation in
> iomap_dio_complete() so it also handles the AIO path, then the
> comment and warning on invalidation failure also need to be moved to
> iomap_dio_complete() and the duplicate code removed from
> iomap_dio_rw()...

Yep, good catch.  Lukas, care to respin?

-Jeff

  reply	other threads:[~2017-08-07 15:52 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-13 15:17 [PATCH] fs: Fix page cache inconsistency when mixing buffered and AIO DIO Lukas Czerner
2017-07-14 10:41 ` kbuild test robot
2017-07-14 13:40   ` Lukas Czerner
2017-07-14 15:40 ` [PATCH v2] " Lukas Czerner
2017-07-17 15:12   ` Jan Kara
2017-07-17 15:28     ` Lukas Czerner
2017-07-17 15:39       ` Jeff Moyer
2017-07-17 16:17         ` Jan Kara
2017-07-17 19:52           ` Jeff Moyer
2017-07-18  7:39         ` Lukas Czerner
2017-07-18  9:06           ` Jan Kara
2017-07-18  9:32             ` Lukas Czerner
2017-07-18 12:19   ` [PATCH v3] " Lukas Czerner
2017-07-18 13:44     ` Christoph Hellwig
2017-07-18 14:17       ` Jan Kara
2017-07-19  8:42       ` Lukas Czerner
2017-07-19  8:48     ` [PATCH v4] " Lukas Czerner
2017-07-19  9:26       ` Jan Kara
2017-07-19 11:01         ` Lukas Czerner
2017-07-19 11:28     ` [PATCH v5] " Lukas Czerner
2017-07-19 11:37       ` Jan Kara
2017-07-19 12:17       ` Jeff Moyer
2017-08-03 18:10       ` Jeff Moyer
2017-08-04 10:09         ` Dave Chinner
2017-08-07 15:52           ` Jeff Moyer [this message]
2017-08-08  8:41             ` Lukas Czerner
2017-08-10 12:59       ` [PATCH v6] " Lukas Czerner
2017-08-10 13:56         ` Jan Kara
2017-08-10 14:22           ` Jeff Moyer
2017-08-11  9:03             ` Lukas Czerner
2017-08-14  9:43               ` Jan Kara
2017-08-15 12:47                 ` Lukas Czerner
2017-08-15 13:28         ` [PATCH v7] " Lukas Czerner
2017-08-16 13:15           ` Jan Kara
2017-08-16 16:01           ` Darrick J. Wong
2017-09-21 13:44           ` Jeff Moyer
2017-09-21 13:44           ` Lukas Czerner
2017-09-21 14:14             ` Jens Axboe
2017-10-10 14:34           ` David Sterba
2017-10-11  9:21             ` Lukas Czerner

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=x497eyfs7ci.fsf@segfault.boston.devel.redhat.com \
    --to=jmoyer@redhat.com \
    --cc=david@fromorbit.com \
    --cc=hch@infradead.org \
    --cc=jack@suse.cz \
    --cc=lczerner@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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).