writeback: pay attention to wbc->nr_to_write in write_cache_pages
[pandora-kernel.git] / mm / page-writeback.c
index 53b2fcf..b3dbb80 100644 (file)
@@ -597,7 +597,7 @@ static void balance_dirty_pages(struct address_space *mapping,
            (!laptop_mode && ((global_page_state(NR_FILE_DIRTY)
                               + global_page_state(NR_UNSTABLE_NFS))
                                          > background_thresh)))
-               bdi_start_writeback(bdi, NULL, 0, 0);
+               bdi_start_writeback(bdi, NULL, 0);
 }
 
 void set_page_dirty_balance(struct page *page, int page_mkwrite)
@@ -690,9 +690,11 @@ int dirty_writeback_centisecs_handler(ctl_table *table, int write,
        void __user *buffer, size_t *length, loff_t *ppos)
 {
        proc_dointvec(table, write, buffer, length, ppos);
+       bdi_arm_supers_timer();
        return 0;
 }
 
+#ifdef CONFIG_BLOCK
 void laptop_mode_timer_fn(unsigned long data)
 {
        struct request_queue *q = (struct request_queue *)data;
@@ -705,7 +707,7 @@ void laptop_mode_timer_fn(unsigned long data)
         */
 
        if (bdi_has_dirty_io(&q->backing_dev_info))
-               bdi_start_writeback(&q->backing_dev_info, NULL, 0, nr_pages);
+               bdi_start_writeback(&q->backing_dev_info, NULL, nr_pages);
 }
 
 /*
@@ -734,6 +736,7 @@ void laptop_sync_completion(void)
 
        rcu_read_unlock();
 }
+#endif
 
 /*
  * If ratelimit_pages is too high then we can get into dirty-data overload
@@ -832,7 +835,6 @@ int write_cache_pages(struct address_space *mapping,
        pgoff_t done_index;
        int cycled;
        int range_whole = 0;
-       long nr_to_write = wbc->nr_to_write;
 
        pagevec_init(&pvec, 0);
        if (wbc->range_cyclic) {
@@ -932,11 +934,10 @@ continue_unlock:
                                        done = 1;
                                        break;
                                }
-                       }
+                       }
 
-                       if (nr_to_write > 0) {
-                               nr_to_write--;
-                               if (nr_to_write == 0 &&
+                       if (wbc->nr_to_write > 0) {
+                               if (--wbc->nr_to_write == 0 &&
                                    wbc->sync_mode == WB_SYNC_NONE) {
                                        /*
                                         * We stop writing back only if we are
@@ -967,11 +968,8 @@ continue_unlock:
                end = writeback_index - 1;
                goto retry;
        }
-       if (!wbc->no_nrwrite_index_update) {
-               if (wbc->range_cyclic || (range_whole && nr_to_write > 0))
-                       mapping->writeback_index = done_index;
-               wbc->nr_to_write = nr_to_write;
-       }
+       if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0))
+               mapping->writeback_index = done_index;
 
        return ret;
 }