aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/writeback.h9
-rw-r--r--mm/page-writeback.c10
2 files changed, 16 insertions, 3 deletions
diff --git a/include/linux/writeback.h b/include/linux/writeback.h
index bd91987c065f..e585657e9831 100644
--- a/include/linux/writeback.h
+++ b/include/linux/writeback.h
@@ -63,6 +63,15 @@ struct writeback_control {
63 unsigned for_writepages:1; /* This is a writepages() call */ 63 unsigned for_writepages:1; /* This is a writepages() call */
64 unsigned range_cyclic:1; /* range_start is cyclic */ 64 unsigned range_cyclic:1; /* range_start is cyclic */
65 unsigned more_io:1; /* more io to be dispatched */ 65 unsigned more_io:1; /* more io to be dispatched */
66 /*
67 * write_cache_pages() won't update wbc->nr_to_write and
68 * mapping->writeback_index if no_nrwrite_index_update
69 * is set. write_cache_pages() may write more than we
70 * requested and we want to make sure nr_to_write and
71 * writeback_index are updated in a consistent manner
72 * so we use a single control to update them
73 */
74 unsigned no_nrwrite_index_update:1;
66}; 75};
67 76
68/* 77/*
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index e373f14d26f6..b40f6d5f8fe9 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -876,6 +876,7 @@ int write_cache_pages(struct address_space *mapping,
876 pgoff_t end; /* Inclusive */ 876 pgoff_t end; /* Inclusive */
877 int scanned = 0; 877 int scanned = 0;
878 int range_whole = 0; 878 int range_whole = 0;
879 long nr_to_write = wbc->nr_to_write;
879 880
880 if (wbc->nonblocking && bdi_write_congested(bdi)) { 881 if (wbc->nonblocking && bdi_write_congested(bdi)) {
881 wbc->encountered_congestion = 1; 882 wbc->encountered_congestion = 1;
@@ -939,7 +940,7 @@ retry:
939 unlock_page(page); 940 unlock_page(page);
940 ret = 0; 941 ret = 0;
941 } 942 }
942 if (ret || (--(wbc->nr_to_write) <= 0)) 943 if (ret || (--nr_to_write <= 0))
943 done = 1; 944 done = 1;
944 if (wbc->nonblocking && bdi_write_congested(bdi)) { 945 if (wbc->nonblocking && bdi_write_congested(bdi)) {
945 wbc->encountered_congestion = 1; 946 wbc->encountered_congestion = 1;
@@ -958,8 +959,11 @@ retry:
958 index = 0; 959 index = 0;
959 goto retry; 960 goto retry;
960 } 961 }
961 if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0)) 962 if (!wbc->no_nrwrite_index_update) {
962 mapping->writeback_index = index; 963 if (wbc->range_cyclic || (range_whole && nr_to_write > 0))
964 mapping->writeback_index = index;
965 wbc->nr_to_write = nr_to_write;
966 }
963 967
964 return ret; 968 return ret;
965} 969}