From dc6d5714414c24bb6407b76402347b185a101bc2 Mon Sep 17 00:00:00 2001 From: lly Date: Fri, 17 Dec 2010 14:27:55 -0500 Subject: [PATCH] mm: write_cache_pages cyclic fix kernel.org commits: 31a12666d8f0c22235297e1c1575f82061480029 mm: write_cache_pages cyclic fix 3a4c6800f31ea8395628af5e7e490270ee5d0585 Fix page writeback thinko, causing Berkeley DB slowdown --- release/src-rt/linux/linux-2.6/mm/page-writeback.c | 25 ++++++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/release/src-rt/linux/linux-2.6/mm/page-writeback.c b/release/src-rt/linux/linux-2.6/mm/page-writeback.c index 5b0ccb80a6..5e368687f5 100644 --- a/release/src-rt/linux/linux-2.6/mm/page-writeback.c +++ b/release/src-rt/linux/linux-2.6/mm/page-writeback.c @@ -611,9 +611,10 @@ int write_cache_pages(struct address_space *mapping, int done = 0; struct pagevec pvec; int nr_pages; + pgoff_t uninitialized_var(writeback_index); pgoff_t index; pgoff_t end; /* Inclusive */ - int scanned = 0; + int cycled; int range_whole = 0; if (wbc->nonblocking && bdi_write_congested(bdi)) { @@ -623,14 +624,19 @@ int write_cache_pages(struct address_space *mapping, pagevec_init(&pvec, 0); if (wbc->range_cyclic) { - index = mapping->writeback_index; /* Start from prev offset */ + writeback_index = mapping->writeback_index; /* prev offset */ + index = writeback_index; + if (index == 0) + cycled = 1; + else + cycled = 0; end = -1; } else { index = wbc->range_start >> PAGE_CACHE_SHIFT; end = wbc->range_end >> PAGE_CACHE_SHIFT; if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX) range_whole = 1; - scanned = 1; + cycled = 1; /* ignore range_cyclic tests */ } retry: while (!done && (index <= end) && @@ -639,7 +645,6 @@ retry: min(end - index, (pgoff_t)PAGEVEC_SIZE-1) + 1))) { unsigned i; - scanned = 1; for (i = 0; i < nr_pages; i++) { struct page *page = pvec.pages[i]; @@ -657,7 +662,11 @@ retry: continue; } - if (!wbc->range_cyclic && page->index > end) { + if (page->index > end) { + /* + * can't be range_cyclic (1st pass) because + * end == -1 in that case. + */ done = 1; unlock_page(page); continue; @@ -688,13 +697,15 @@ retry: pagevec_release(&pvec); cond_resched(); } - if (!scanned && !done) { + if (!cycled && !done) { /* + * range_cyclic: * We hit the last page and there is more work to be done: wrap * back to the start of the file */ - scanned = 1; + cycled = 1; index = 0; + end = writeback_index - 1; goto retry; } if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0)) -- 2.11.4.GIT