Commit 013a3540 authored by Suparna Bhattacharya's avatar Suparna Bhattacharya Committed by Linus Torvalds

[PATCH] Fix writeback page range to use exact limits

wait_on_page_writeback_range shouldn't wait for pages beyond the specified
range.  Ideally, the radix-tree-lookup could accept an end_index parameter so
that it doesn't return the extra pages in the first place, but for now we just
add a few extra checks to skip such pages.
Signed-off-by: default avatarSuparna Bhattacharya <suparna@in.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent f07812ca
......@@ -198,7 +198,8 @@ static int wait_on_page_writeback_range(struct address_space *mapping,
pagevec_init(&pvec, 0);
index = start;
while ((nr_pages = pagevec_lookup_tag(&pvec, mapping, &index,
while ((index <= end) &&
(nr_pages = pagevec_lookup_tag(&pvec, mapping, &index,
PAGECACHE_TAG_WRITEBACK,
min(end - index, (pgoff_t)PAGEVEC_SIZE-1) + 1)) != 0) {
unsigned i;
......@@ -206,6 +207,10 @@ static int wait_on_page_writeback_range(struct address_space *mapping,
for (i = 0; i < nr_pages; i++) {
struct page *page = pvec.pages[i];
/* until radix tree lookup accepts end_index */
if (page->index > end)
continue;
wait_on_page_writeback(page);
if (PageError(page))
ret = -EIO;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment