aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>2006-06-23 05:03:26 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-23 10:42:49 -0400
commit111ebb6e6f7bd7de6d722c5848e95621f43700d9 (patch)
treebb00b13001db9be201e9b6d31468a79f4d1240bf /mm
parent4c91c3648c620003cb7b21b8858f36cd6132e168 (diff)
[PATCH] writeback: fix range handling
When a writeback_control's `start' and `end' fields are used to indicate a one-byte-range starting at file offset zero, the required values of .start=0,.end=0 mean that the ->writepages() implementation has no way of telling that it is being asked to perform a range request. Because we're currently overloading (start == 0 && end == 0) to mean "this is not a write-a-range request". To make all this sane, the patch changes range of writeback_control. So caller does: If it is calling ->writepages() to write pages, it sets range (range_start/end or range_cyclic) always. And if range_cyclic is true, ->writepages() thinks the range is cyclic, otherwise it just uses range_start and range_end. This patch does, - Add LLONG_MAX, LLONG_MIN, ULLONG_MAX to include/linux/kernel.h -1 is usually ok for range_end (type is long long). But, if someone did, range_end += val; range_end is "val - 1" u64val = range_end >> bits; u64val is "~(0ULL)" or something, they are wrong. So, this adds LLONG_MAX to avoid nasty things, and uses LLONG_MAX for range_end. - All callers of ->writepages() sets range_start/end or range_cyclic. - Fix updates of ->writeback_index. It seems already bit strange. If it starts at 0 and ended by check of nr_to_write, this last index may reduce chance to scan end of file. So, this updates ->writeback_index only if range_cyclic is true or whole-file is scanned. Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> Cc: Nathan Scott <nathans@sgi.com> Cc: Anton Altaparmakov <aia21@cantab.net> Cc: Steven French <sfrench@us.ibm.com> Cc: "Vladimir V. Saveliev" <vs@namesys.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/filemap.c6
-rw-r--r--mm/page-writeback.c3
-rw-r--r--mm/vmscan.c2
3 files changed, 8 insertions, 3 deletions
diff --git a/mm/filemap.c b/mm/filemap.c
index fd57442186cb..3342067ca436 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -190,8 +190,8 @@ int __filemap_fdatawrite_range(struct address_space *mapping, loff_t start,
190 struct writeback_control wbc = { 190 struct writeback_control wbc = {
191 .sync_mode = sync_mode, 191 .sync_mode = sync_mode,
192 .nr_to_write = mapping->nrpages * 2, 192 .nr_to_write = mapping->nrpages * 2,
193 .start = start, 193 .range_start = start,
194 .end = end, 194 .range_end = end,
195 }; 195 };
196 196
197 if (!mapping_cap_writeback_dirty(mapping)) 197 if (!mapping_cap_writeback_dirty(mapping))
@@ -204,7 +204,7 @@ int __filemap_fdatawrite_range(struct address_space *mapping, loff_t start,
204static inline int __filemap_fdatawrite(struct address_space *mapping, 204static inline int __filemap_fdatawrite(struct address_space *mapping,
205 int sync_mode) 205 int sync_mode)
206{ 206{
207 return __filemap_fdatawrite_range(mapping, 0, 0, sync_mode); 207 return __filemap_fdatawrite_range(mapping, 0, LLONG_MAX, sync_mode);
208} 208}
209 209
210int filemap_fdatawrite(struct address_space *mapping) 210int filemap_fdatawrite(struct address_space *mapping)
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 75d7f48b79bb..8ccf6f1b1473 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -204,6 +204,7 @@ static void balance_dirty_pages(struct address_space *mapping)
204 .sync_mode = WB_SYNC_NONE, 204 .sync_mode = WB_SYNC_NONE,
205 .older_than_this = NULL, 205 .older_than_this = NULL,
206 .nr_to_write = write_chunk, 206 .nr_to_write = write_chunk,
207 .range_cyclic = 1,
207 }; 208 };
208 209
209 get_dirty_limits(&wbs, &background_thresh, 210 get_dirty_limits(&wbs, &background_thresh,
@@ -331,6 +332,7 @@ static void background_writeout(unsigned long _min_pages)
331 .older_than_this = NULL, 332 .older_than_this = NULL,
332 .nr_to_write = 0, 333 .nr_to_write = 0,
333 .nonblocking = 1, 334 .nonblocking = 1,
335 .range_cyclic = 1,
334 }; 336 };
335 337
336 for ( ; ; ) { 338 for ( ; ; ) {
@@ -407,6 +409,7 @@ static void wb_kupdate(unsigned long arg)
407 .nr_to_write = 0, 409 .nr_to_write = 0,
408 .nonblocking = 1, 410 .nonblocking = 1,
409 .for_kupdate = 1, 411 .for_kupdate = 1,
412 .range_cyclic = 1,
410 }; 413 };
411 414
412 sync_supers(); 415 sync_supers();
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 46be8a02280e..bc5d4f43036c 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -339,6 +339,8 @@ pageout_t pageout(struct page *page, struct address_space *mapping)
339 struct writeback_control wbc = { 339 struct writeback_control wbc = {
340 .sync_mode = WB_SYNC_NONE, 340 .sync_mode = WB_SYNC_NONE,
341 .nr_to_write = SWAP_CLUSTER_MAX, 341 .nr_to_write = SWAP_CLUSTER_MAX,
342 .range_start = 0,
343 .range_end = LLONG_MAX,
342 .nonblocking = 1, 344 .nonblocking = 1,
343 .for_reclaim = 1, 345 .for_reclaim = 1,
344 }; 346 };