Merge branch 'drm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied...
[linux-drm-fsl-dcu.git] / mm / page-writeback.c
index b289310e2c899ba472ea1f7a92a01b908f549f18..37498ef6154836943f3478304bf7440ab255669a 100644 (file)
@@ -495,7 +495,6 @@ static void balance_dirty_pages(struct address_space *mapping,
 
        for (;;) {
                struct writeback_control wbc = {
-                       .bdi            = bdi,
                        .sync_mode      = WB_SYNC_NONE,
                        .older_than_this = NULL,
                        .nr_to_write    = write_chunk,
@@ -537,7 +536,7 @@ static void balance_dirty_pages(struct address_space *mapping,
                 * up.
                 */
                if (bdi_nr_reclaimable > bdi_thresh) {
-                       writeback_inodes_wbc(&wbc);
+                       writeback_inodes_wb(&bdi->wb, &wbc);
                        pages_written += write_chunk - wbc.nr_to_write;
                        get_dirty_limits(&background_thresh, &dirty_thresh,
                                       &bdi_thresh, bdi);
@@ -597,7 +596,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_background_writeback(bdi);
 }
 
 void set_page_dirty_balance(struct page *page, int page_mkwrite)
@@ -705,9 +704,8 @@ void laptop_mode_timer_fn(unsigned long data)
         * We want to write everything out, not just down to the dirty
         * threshold
         */
-
        if (bdi_has_dirty_io(&q->backing_dev_info))
-               bdi_start_writeback(&q->backing_dev_info, NULL, nr_pages, 0);
+               bdi_start_writeback(&q->backing_dev_info, nr_pages);
 }
 
 /*
@@ -835,7 +833,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) {
@@ -852,7 +849,22 @@ int write_cache_pages(struct address_space *mapping,
                if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
                        range_whole = 1;
                cycled = 1; /* ignore range_cyclic tests */
+
+               /*
+                * If this is a data integrity sync, cap the writeback to the
+                * current end of file. Any extension to the file that occurs
+                * after this is a new write and we don't need to write those
+                * pages out to fulfil our data integrity requirements. If we
+                * try to write them out, we can get stuck in this scan until
+                * the concurrent writer stops adding dirty pages and extending
+                * EOF.
+                */
+               if (wbc->sync_mode == WB_SYNC_ALL &&
+                   wbc->range_end == LLONG_MAX) {
+                       end = i_size_read(mapping->host) >> PAGE_CACHE_SHIFT;
+               }
        }
+
 retry:
        done_index = index;
        while (!done && (index <= end)) {
@@ -935,11 +947,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
@@ -970,11 +981,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;
 }