From: Christoph Hellwig <hch@infradead.org>
To: Josef Bacik <josef@redhat.com>
Cc: linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fs: make sure to invalidate pages if we fall back on buffered reads
Date: Mon, 14 Jun 2010 04:17:36 -0400 [thread overview]
Message-ID: <20100614081736.GA29239@infradead.org> (raw)
In-Reply-To: <1276007044-17715-1-git-send-email-josef@redhat.com>
On Tue, Jun 08, 2010 at 10:24:04AM -0400, Josef Bacik wrote:
> Since BTRFS can fallback on buffered reads after having done some direct reads,
> we need to make sure to invalidate any pages that we may have read by doing
> buffered IO. This shouldn't have shown up as a visible user problem, it's just
> for correctness sake. Thanks,
Everything else in direct I/O land uses invalidate_inode_pages2(_range),
why not this one?
> loff_t *ppos = &iocb->ki_pos;
> + bool invalidate = false;
>
> count = 0;
> retval = generic_segment_checks(iov, &nr_segs, &count, VERIFY_WRITE);
> @@ -1291,7 +1292,8 @@ generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
> iov, pos, nr_segs);
> }
> if (retval > 0) {
> - *ppos = pos + retval;
> + pos += retval;
> + *ppos = pos;
> count -= retval;
> }
>
> @@ -1307,6 +1309,7 @@ generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
> file_accessed(filp);
> goto out;
> }
> + invalidate = true;
> }
> }
>
> @@ -1343,6 +1346,10 @@ generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
> if (desc.count > 0)
> break;
> }
> + if (invalidate && retval > 0)
> + invalidate_mapping_pages(filp->f_mapping,
> + pos >> PAGE_CACHE_SHIFT,
> + (*ppos - 1) >> PAGE_CACHE_SHIFT);
A little comment here would be surely useful. Telling that we want to
get rid of the pages again if we were falling through from an attempted
direct I/O read.
next prev parent reply other threads:[~2010-06-14 8:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-08 14:24 [PATCH] fs: make sure to invalidate pages if we fall back on buffered reads Josef Bacik
2010-06-11 19:22 ` Jeff Moyer
2010-06-14 8:17 ` Christoph Hellwig [this message]
2010-06-14 13:13 ` Josef Bacik
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=20100614081736.GA29239@infradead.org \
--to=hch@infradead.org \
--cc=josef@redhat.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@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).