* [PATCH] FS-Cache: Fix bounds check
[not found] <20110712124622.9331.83332.sendpatchset@squad5-lp1.lab.bos.redhat.com>
@ 2011-07-13 11:47 ` David Howells
2011-07-13 11:55 ` David Howells
0 siblings, 1 reply; 3+ messages in thread
From: David Howells @ 2011-07-13 11:47 UTC (permalink / raw)
To: geert; +Cc: linux-kernel, stable, David Howells
__fscache_uncache_all_inode_pages() has a loop that goes through page index
numbers go up to (loff_t)-1. This is incorrect. The limit should be
(pgoff_t)-1 as on a 32-bit machine the pgoff_t is smaller than loff_t.
On m68k the following error is observed:
fs/fscache/page.c: In function '__fscache_uncache_all_inode_pages':
fs/fscache/page.c:979: warning: comparison is always false due to
limited range of data type
[Should there be a PGOFF_T_MAX constant defined?]
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: David Howells <dhowells@redhat.com>
---
fs/fscache/page.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fs/fscache/page.c b/fs/fscache/page.c
index 60315b3..112359d 100644
--- a/fs/fscache/page.c
+++ b/fs/fscache/page.c
@@ -993,7 +993,7 @@ void __fscache_uncache_all_inode_pages(struct fscache_cookie *cookie,
pagevec_init(&pvec, 0);
next = 0;
- while (next <= (loff_t)-1 &&
+ while (next <= (pgoff_t)-1 &&
pagevec_lookup(&pvec, mapping, next, PAGEVEC_SIZE)
) {
for (i = 0; i < pagevec_count(&pvec); i++) {
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: FS-Cache: Add a helper to bulk uncache pages on an inode
@ 2011-07-12 19:26 Geert Uytterhoeven
2011-07-13 11:55 ` [PATCH] FS-Cache: Fix bounds check David Howells
0 siblings, 1 reply; 3+ messages in thread
From: Geert Uytterhoeven @ 2011-07-12 19:26 UTC (permalink / raw)
To: David Howells; +Cc: Linux Kernel Mailing List, stable
On Thu, Jul 7, 2011 at 22:59, Linux Kernel Mailing List
<linux-kernel@vger.kernel.org> wrote:
> FS-Cache: Add a helper to bulk uncache pages on an inode
>
> Add an FS-Cache helper to bulk uncache pages on an inode. This will
> only work for the circumstance where the pages in the cache correspond
> 1:1 with the pages attached to an inode's page cache.
>
> This is required for CIFS and NFS: When disabling inode cookie, we were
> returning the cookie and setting cifsi->fscache to NULL but failed to
> invalidate any previously mapped pages. This resulted in "Bad page
> state" errors and manifested in other kind of errors when running
> fsstress. Fix it by uncaching mapped pages when we disable the inode
> cookie.
>
> This patch should fix the following oops and "Bad page state" errors
> seen during fsstress testing.
> --- a/fs/fscache/page.c
> +++ b/fs/fscache/page.c
> @@ -954,3 +954,47 @@ void fscache_mark_pages_cached(struct fscache_retrieval *op,
> pagevec_reinit(pagevec);
> }
> EXPORT_SYMBOL(fscache_mark_pages_cached);
> +
> +/*
> + * Uncache all the pages in an inode that are marked PG_fscache, assuming them
> + * to be associated with the given cookie.
> + */
> +void __fscache_uncache_all_inode_pages(struct fscache_cookie *cookie,
> + struct inode *inode)
> +{
> + struct address_space *mapping = inode->i_mapping;
> + struct pagevec pvec;
> + pgoff_t next;
> + int i;
> +
> + _enter("%p,%p", cookie, inode);
> +
> + if (!mapping || mapping->nrpages == 0) {
> + _leave(" [no pages]");
> + return;
> + }
> +
> + pagevec_init(&pvec, 0);
> + next = 0;
> + while (next <= (loff_t)-1 &&
On m68k, I get:
fs/fscache/page.c: In function ‘__fscache_uncache_all_inode_pages’:
fs/fscache/page.c:979: warning: comparison is always false due to
limited range of data type
next is pgoff_t, which is defined to unsigned long by default, unless
overridden by the arch
(hmm, no single arch seems to do that?).
loff_t is (signed) long long.
> + pagevec_lookup(&pvec, mapping, next, PAGEVEC_SIZE)
> + ) {
> + for (i = 0; i < pagevec_count(&pvec); i++) {
> + struct page *page = pvec.pages[i];
> + pgoff_t page_index = page->index;
> +
> + ASSERTCMP(page_index, >=, next);
> + next = page_index + 1;
> +
> + if (PageFsCache(page)) {
> + __fscache_wait_on_page_write(cookie, page);
> + __fscache_uncache_page(cookie, page);
> + }
> + }
> + pagevec_release(&pvec);
> + cond_resched();
> + }
> +
> + _leave("");
> +}
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH] FS-Cache: Fix bounds check
2011-07-12 19:26 FS-Cache: Add a helper to bulk uncache pages on an inode Geert Uytterhoeven
@ 2011-07-13 11:55 ` David Howells
0 siblings, 0 replies; 3+ messages in thread
From: David Howells @ 2011-07-13 11:55 UTC (permalink / raw)
To: geert; +Cc: linux-kernel, stable, David Howells
__fscache_uncache_all_inode_pages() has a loop that goes through page index
numbers go up to (loff_t)-1. This is incorrect. The limit should be
(pgoff_t)-1 as on a 32-bit machine the pgoff_t is smaller than loff_t.
On m68k the following error is observed:
fs/fscache/page.c: In function '__fscache_uncache_all_inode_pages':
fs/fscache/page.c:979: warning: comparison is always false due to
limited range of data type
[Should there be a PGOFF_T_MAX constant defined?]
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: David Howells <dhowells@redhat.com>
---
fs/fscache/page.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fs/fscache/page.c b/fs/fscache/page.c
index 60315b3..112359d 100644
--- a/fs/fscache/page.c
+++ b/fs/fscache/page.c
@@ -993,7 +993,7 @@ void __fscache_uncache_all_inode_pages(struct fscache_cookie *cookie,
pagevec_init(&pvec, 0);
next = 0;
- while (next <= (loff_t)-1 &&
+ while (next <= (pgoff_t)-1 &&
pagevec_lookup(&pvec, mapping, next, PAGEVEC_SIZE)
) {
for (i = 0; i < pagevec_count(&pvec); i++) {
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-07-13 11:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20110712124622.9331.83332.sendpatchset@squad5-lp1.lab.bos.redhat.com>
2011-07-13 11:47 ` [PATCH] FS-Cache: Fix bounds check David Howells
2011-07-13 11:55 ` David Howells
2011-07-12 19:26 FS-Cache: Add a helper to bulk uncache pages on an inode Geert Uytterhoeven
2011-07-13 11:55 ` [PATCH] FS-Cache: Fix bounds check David Howells
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.