[PATCH] FS-Cache: Fix __fscache_uncache_all_inode_pages()'s outer loop

From: David Howells
Date: Thu Jul 21 2011 - 10:04:20 EST


From: Jan Beulich <JBeulich@xxxxxxxxxx>

The compiler, at least for ix86 and m68k, validly warns that the comparison:

next <= (loff_t)-1

is always true (and it's always true also for x86-64 and probably all other
arches - as long as pgoff_t isn't wider than loff_t). The intention appears
to be to avoid wrapping of "next", so rather than eliminating the pointless
comparison, fix the loop to indeed get exited when "next" would otherwise
wrap.

On m68k the following warning 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

Reported-by: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
Reported-by: Jan Beulich <jbeulich@xxxxxxxxxx>
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>
Signed-off-by: David Howells <dhowells@xxxxxxxxxx>
Cc: Suresh Jayaraman <sjayaraman@xxxxxxx>
Cc: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
Cc: stable@xxxxxxxxxx
---

fs/fscache/page.c | 14 +++++---------
1 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/fs/fscache/page.c b/fs/fscache/page.c
index 60315b3..ff1e68f 100644
--- a/fs/fscache/page.c
+++ b/fs/fscache/page.c
@@ -993,16 +993,12 @@ void __fscache_uncache_all_inode_pages(struct fscache_cookie *cookie,

pagevec_init(&pvec, 0);
next = 0;
- while (next <= (loff_t)-1 &&
- pagevec_lookup(&pvec, mapping, next, PAGEVEC_SIZE)
- ) {
+ do {
+ if (!pagevec_lookup(&pvec, mapping, next, PAGEVEC_SIZE))
+ break;
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;
-
+ next = page->index;
if (PageFsCache(page)) {
__fscache_wait_on_page_write(cookie, page);
__fscache_uncache_page(cookie, page);
@@ -1010,7 +1006,7 @@ void __fscache_uncache_all_inode_pages(struct fscache_cookie *cookie,
}
pagevec_release(&pvec);
cond_resched();
- }
+ } while (++next);

_leave("");
}

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/