mm: use pagevec_lookup_range_tag() in write_cache_pages()
[sfrench/cifs-2.6.git] / mm / page-writeback.c
index c518c845f202591cfa1fb8da83a38d6fd256be7b..460fc022cbc8a11e0c3ec62f3647aa2dc4640a6e 100644 (file)
@@ -433,8 +433,11 @@ static void domain_dirty_limits(struct dirty_throttle_control *dtc)
        else
                bg_thresh = (bg_ratio * available_memory) / PAGE_SIZE;
 
-       if (bg_thresh >= thresh)
+       if (unlikely(bg_thresh >= thresh)) {
+               pr_warn("vm direct limit must be set greater than background limit.\n");
                bg_thresh = thresh / 2;
+       }
+
        tsk = current;
        if (tsk->flags & PF_LESS_THROTTLE || rt_task(tsk)) {
                bg_thresh += bg_thresh / 4 + global_wb_domain.dirty_limit / 32;
@@ -1559,8 +1562,7 @@ static inline void wb_dirty_limits(struct dirty_throttle_control *dtc)
  * If we're over `background_thresh' then the writeback threads are woken to
  * perform some writeout.
  */
-static void balance_dirty_pages(struct address_space *mapping,
-                               struct bdi_writeback *wb,
+static void balance_dirty_pages(struct bdi_writeback *wb,
                                unsigned long pages_dirtied)
 {
        struct dirty_throttle_control gdtc_stor = { GDTC_INIT(wb) };
@@ -1910,7 +1912,7 @@ void balance_dirty_pages_ratelimited(struct address_space *mapping)
        preempt_enable();
 
        if (unlikely(current->nr_dirtied >= ratelimit))
-               balance_dirty_pages(mapping, wb, current->nr_dirtied);
+               balance_dirty_pages(wb, current->nr_dirtied);
 
        wb_put(wb);
 }
@@ -2194,30 +2196,14 @@ retry:
        while (!done && (index <= end)) {
                int i;
 
-               nr_pages = pagevec_lookup_tag(&pvec, mapping, &index, tag,
-                             min(end - index, (pgoff_t)PAGEVEC_SIZE-1) + 1);
+               nr_pages = pagevec_lookup_range_tag(&pvec, mapping, &index, end,
+                               tag, PAGEVEC_SIZE);
                if (nr_pages == 0)
                        break;
 
                for (i = 0; i < nr_pages; i++) {
                        struct page *page = pvec.pages[i];
 
-                       /*
-                        * At this point, the page may be truncated or
-                        * invalidated (changing page->mapping to NULL), or
-                        * even swizzled back from swapper_space to tmpfs file
-                        * mapping. However, page->index will not change
-                        * because we have a reference on the page.
-                        */
-                       if (page->index > end) {
-                               /*
-                                * can't be range_cyclic (1st pass) because
-                                * end == -1 in that case.
-                                */
-                               done = 1;
-                               break;
-                       }
-
                        done_index = page->index;
 
                        lock_page(page);