From: Suparna Bhattacharya Safeguard to make sure we break out of pagevec_lookup_tag loop if we are beyond the specified range. --- rc3mm3/fs/mpage.c 2004-04-01 15:54:14.657954776 +0530 +++ linux-2.6.5-rc3-mm3/fs/mpage.c 2004-04-01 16:03:04.525402680 +0530 @@ -637,7 +637,8 @@ mpage_writepages(struct address_space *m scanned = 1; } retry: - while (!done && (nr_pages = pagevec_lookup_tag(&pvec, mapping, &index, + while (!done && (index <= end) && + (nr_pages = pagevec_lookup_tag(&pvec, mapping, &index, PAGECACHE_TAG_DIRTY, min(end - index, (pgoff_t)PAGEVEC_SIZE-1) + 1))) { unsigned i;