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.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 5fa63bdf52e4..bbd396ac9546 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -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}