From: Andrew Morton <akpm@osdl.org>
To: Zach Brown <zach.brown@oracle.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [Patch] invalidate range of pages after direct IO write
Date: Thu, 3 Feb 2005 18:28:54 -0800 [thread overview]
Message-ID: <20050203182854.0b36fb4d.akpm@osdl.org> (raw)
In-Reply-To: <4202D55E.5030900@oracle.com>
Zach Brown <zach.brown@oracle.com> wrote:
>
> > I'll make that change and plop the patch into -mm, but we need to think
> > about the infinite-loop problem..
>
> I can try hacking together that macro and auditing pagevec_lookup()
> callers..
I'd be inclined to hold off on the macro until we actually get the
open-coded stuff right.. Sometimes the page lookup loops take an end+1
argument and sometimes they take an inclusive `end'. I think. That might
make it a bit messy.
How's this look?
- Don't look up more pages than we're going to use
- Don't test page->index until we've locked the page
- Check for the cursor wrapping at the end of the mapping.
--- 25/mm/truncate.c~invalidate-range-of-pages-after-direct-io-write-fix 2005-02-03 18:20:22.000000000 -0800
+++ 25-akpm/mm/truncate.c 2005-02-03 18:28:24.627796400 -0800
@@ -264,18 +264,14 @@ int invalidate_inode_pages2_range(struct
pagevec_init(&pvec, 0);
next = start;
while (next <= end &&
- !ret && pagevec_lookup(&pvec, mapping, next, PAGEVEC_SIZE)) {
+ !ret && pagevec_lookup(&pvec, mapping, next,
+ min(end - next, (pgoff_t)PAGEVEC_SIZE - 1) + 1)) {
for (i = 0; !ret && i < pagevec_count(&pvec); i++) {
struct page *page = pvec.pages[i];
int was_dirty;
- if (page->index > end) {
- next = page->index;
- break;
- }
-
lock_page(page);
- if (page->mapping != mapping) { /* truncate race? */
+ if (page->mapping != mapping || page->index > end) {
unlock_page(page);
continue;
}
@@ -311,6 +307,8 @@ int invalidate_inode_pages2_range(struct
}
pagevec_release(&pvec);
cond_resched();
+ if (next == 0)
+ break; /* The pgoff_t wrapped */
}
return ret;
}
_
next prev parent reply other threads:[~2005-02-04 2:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-29 2:16 Zach Brown
2005-02-04 0:19 ` Andrew Morton
2005-02-04 1:52 ` Zach Brown
2005-02-04 2:28 ` Andrew Morton [this message]
2005-02-04 23:12 ` Zach Brown
2005-02-04 23:35 ` Andrew Morton
2005-02-07 21:19 ` Zach Brown
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=20050203182854.0b36fb4d.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=zach.brown@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®