aboutsummaryrefslogtreecommitdiffstats
path: root/mm/page-writeback.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/page-writeback.c')
-rw-r--r--mm/page-writeback.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index b289310e2c89..bbd396ac9546 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -597,7 +597,7 @@ static void balance_dirty_pages(struct address_space *mapping,
597 (!laptop_mode && ((global_page_state(NR_FILE_DIRTY) 597 (!laptop_mode && ((global_page_state(NR_FILE_DIRTY)
598 + global_page_state(NR_UNSTABLE_NFS)) 598 + global_page_state(NR_UNSTABLE_NFS))
599 > background_thresh))) 599 > background_thresh)))
600 bdi_start_writeback(bdi, NULL, 0, 0); 600 bdi_start_writeback(bdi, NULL, 0);
601} 601}
602 602
603void set_page_dirty_balance(struct page *page, int page_mkwrite) 603void set_page_dirty_balance(struct page *page, int page_mkwrite)
@@ -707,7 +707,7 @@ void laptop_mode_timer_fn(unsigned long data)
707 */ 707 */
708 708
709 if (bdi_has_dirty_io(&q->backing_dev_info)) 709 if (bdi_has_dirty_io(&q->backing_dev_info))
710 bdi_start_writeback(&q->backing_dev_info, NULL, nr_pages, 0); 710 bdi_start_writeback(&q->backing_dev_info, NULL, nr_pages);
711} 711}
712 712
713/* 713/*
@@ -835,7 +835,6 @@ int write_cache_pages(struct address_space *mapping,
835 pgoff_t done_index; 835 pgoff_t done_index;
836 int cycled; 836 int cycled;
837 int range_whole = 0; 837 int range_whole = 0;
838 long nr_to_write = wbc->nr_to_write;
839 838
840 pagevec_init(&pvec, 0); 839 pagevec_init(&pvec, 0);
841 if (wbc->range_cyclic) { 840 if (wbc->range_cyclic) {
@@ -852,7 +851,22 @@ int write_cache_pages(struct address_space *mapping,
852 if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX) 851 if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
853 range_whole = 1; 852 range_whole = 1;
854 cycled = 1; /* ignore range_cyclic tests */ 853 cycled = 1; /* ignore range_cyclic tests */
854
855 /*
856 * If this is a data integrity sync, cap the writeback to the
857 * current end of file. Any extension to the file that occurs
858 * after this is a new write and we don't need to write those
859 * pages out to fulfil our data integrity requirements. If we
860 * try to write them out, we can get stuck in this scan until
861 * the concurrent writer stops adding dirty pages and extending
862 * EOF.
863 */
864 if (wbc->sync_mode == WB_SYNC_ALL &&
865 wbc->range_end == LLONG_MAX) {
866 end = i_size_read(mapping->host) >> PAGE_CACHE_SHIFT;
867 }
855 } 868 }
869
856retry: 870retry:
857 done_index = index; 871 done_index = index;
858 while (!done && (index <= end)) { 872 while (!done && (index <= end)) {
@@ -935,11 +949,10 @@ continue_unlock:
935 done = 1; 949 done = 1;
936 break; 950 break;
937 } 951 }
938 } 952 }
939 953
940 if (nr_to_write > 0) { 954 if (wbc->nr_to_write > 0) {
941 nr_to_write--; 955 if (--wbc->nr_to_write == 0 &&
942 if (nr_to_write == 0 &&
943 wbc->sync_mode == WB_SYNC_NONE) { 956 wbc->sync_mode == WB_SYNC_NONE) {
944 /* 957 /*
945 * We stop writing back only if we are 958 * We stop writing back only if we are
@@ -970,11 +983,8 @@ continue_unlock:
970 end = writeback_index - 1; 983 end = writeback_index - 1;
971 goto retry; 984 goto retry;
972 } 985 }
973 if (!wbc->no_nrwrite_index_update) { 986 if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0))
974 if (wbc->range_cyclic || (range_whole && nr_to_write > 0)) 987 mapping->writeback_index = done_index;
975 mapping->writeback_index = done_index;
976 wbc->nr_to_write = nr_to_write;
977 }
978 988
979 return ret; 989 return ret;
980} 990}