Skip to content

Commit b307d46

Browse files
Jan Beulichtorvalds
Jan Beulich
authored andcommitted
FS-Cache: Fix __fscache_uncache_all_inode_pages()'s outer loop
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 <[email protected]> Reported-by: Jan Beulich <[email protected]> Signed-off-by: Jan Beulich <[email protected]> Signed-off-by: David Howells <[email protected]> Cc: Suresh Jayaraman <[email protected]> Cc: Geert Uytterhoeven <[email protected]> Cc: [email protected] Signed-off-by: Linus Torvalds <[email protected]>
1 parent cf6ace1 commit b307d46

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

fs/fscache/page.c

+5-9
Original file line numberDiff line numberDiff line change
@@ -976,24 +976,20 @@ void __fscache_uncache_all_inode_pages(struct fscache_cookie *cookie,
976976

977977
pagevec_init(&pvec, 0);
978978
next = 0;
979-
while (next <= (loff_t)-1 &&
980-
pagevec_lookup(&pvec, mapping, next, PAGEVEC_SIZE)
981-
) {
979+
do {
980+
if (!pagevec_lookup(&pvec, mapping, next, PAGEVEC_SIZE))
981+
break;
982982
for (i = 0; i < pagevec_count(&pvec); i++) {
983983
struct page *page = pvec.pages[i];
984-
pgoff_t page_index = page->index;
985-
986-
ASSERTCMP(page_index, >=, next);
987-
next = page_index + 1;
988-
984+
next = page->index;
989985
if (PageFsCache(page)) {
990986
__fscache_wait_on_page_write(cookie, page);
991987
__fscache_uncache_page(cookie, page);
992988
}
993989
}
994990
pagevec_release(&pvec);
995991
cond_resched();
996-
}
992+
} while (++next);
997993

998994
_leave("");
999995
}

0 commit comments

Comments
 (0)