aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/filesystems/vfs.txt2
-rw-r--r--fs/jbd2/commit.c2
-rw-r--r--fs/sync.c8
-rw-r--r--include/linux/fs.h2
-rw-r--r--mm/filemap.c49
5 files changed, 18 insertions, 45 deletions
diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt
index 623f094c9d8d..3de2f32edd90 100644
--- a/Documentation/filesystems/vfs.txt
+++ b/Documentation/filesystems/vfs.txt
@@ -472,7 +472,7 @@ __sync_single_inode) to check if ->writepages has been successful in
472writing out the whole address_space. 472writing out the whole address_space.
473 473
474The Writeback tag is used by filemap*wait* and sync_page* functions, 474The Writeback tag is used by filemap*wait* and sync_page* functions,
475via wait_on_page_writeback_range, to wait for all writeback to 475via filemap_fdatawait_range, to wait for all writeback to
476complete. While waiting ->sync_page (if defined) will be called on 476complete. While waiting ->sync_page (if defined) will be called on
477each page that is found to require writeback. 477each page that is found to require writeback.
478 478
diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
index d4cfd6d2779e..c5edc13ccdd0 100644
--- a/fs/jbd2/commit.c
+++ b/fs/jbd2/commit.c
@@ -286,7 +286,7 @@ static int journal_finish_inode_data_buffers(journal_t *journal,
286 if (err) { 286 if (err) {
287 /* 287 /*
288 * Because AS_EIO is cleared by 288 * Because AS_EIO is cleared by
289 * wait_on_page_writeback_range(), set it again so 289 * filemap_fdatawait_range(), set it again so
290 * that user process can get -EIO from fsync(). 290 * that user process can get -EIO from fsync().
291 */ 291 */
292 set_bit(AS_EIO, 292 set_bit(AS_EIO,
diff --git a/fs/sync.c b/fs/sync.c
index b75ca68dc081..36752a683481 100644
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -453,9 +453,7 @@ int do_sync_mapping_range(struct address_space *mapping, loff_t offset,
453 453
454 ret = 0; 454 ret = 0;
455 if (flags & SYNC_FILE_RANGE_WAIT_BEFORE) { 455 if (flags & SYNC_FILE_RANGE_WAIT_BEFORE) {
456 ret = wait_on_page_writeback_range(mapping, 456 ret = filemap_fdatawait_range(mapping, offset, endbyte);
457 offset >> PAGE_CACHE_SHIFT,
458 endbyte >> PAGE_CACHE_SHIFT);
459 if (ret < 0) 457 if (ret < 0)
460 goto out; 458 goto out;
461 } 459 }
@@ -468,9 +466,7 @@ int do_sync_mapping_range(struct address_space *mapping, loff_t offset,
468 } 466 }
469 467
470 if (flags & SYNC_FILE_RANGE_WAIT_AFTER) { 468 if (flags & SYNC_FILE_RANGE_WAIT_AFTER) {
471 ret = wait_on_page_writeback_range(mapping, 469 ret = filemap_fdatawait_range(mapping, offset, endbyte);
472 offset >> PAGE_CACHE_SHIFT,
473 endbyte >> PAGE_CACHE_SHIFT);
474 } 470 }
475out: 471out:
476 return ret; 472 return ret;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 891f7d642e5c..a057f48eb156 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2091,8 +2091,6 @@ extern int filemap_fdatawait_range(struct address_space *, loff_t lstart,
2091extern int filemap_write_and_wait(struct address_space *mapping); 2091extern int filemap_write_and_wait(struct address_space *mapping);
2092extern int filemap_write_and_wait_range(struct address_space *mapping, 2092extern int filemap_write_and_wait_range(struct address_space *mapping,
2093 loff_t lstart, loff_t lend); 2093 loff_t lstart, loff_t lend);
2094extern int wait_on_page_writeback_range(struct address_space *mapping,
2095 pgoff_t start, pgoff_t end);
2096extern int __filemap_fdatawrite_range(struct address_space *mapping, 2094extern int __filemap_fdatawrite_range(struct address_space *mapping,
2097 loff_t start, loff_t end, int sync_mode); 2095 loff_t start, loff_t end, int sync_mode);
2098extern int filemap_fdatawrite_range(struct address_space *mapping, 2096extern int filemap_fdatawrite_range(struct address_space *mapping,
diff --git a/mm/filemap.c b/mm/filemap.c
index c3d3506ecaba..8b4d88f9249e 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -260,27 +260,27 @@ int filemap_flush(struct address_space *mapping)
260EXPORT_SYMBOL(filemap_flush); 260EXPORT_SYMBOL(filemap_flush);
261 261
262/** 262/**
263 * wait_on_page_writeback_range - wait for writeback to complete 263 * filemap_fdatawait_range - wait for writeback to complete
264 * @mapping: target address_space 264 * @mapping: address space structure to wait for
265 * @start: beginning page index 265 * @start_byte: offset in bytes where the range starts
266 * @end: ending page index 266 * @end_byte: offset in bytes where the range ends (inclusive)
267 * 267 *
268 * Wait for writeback to complete against pages indexed by start->end 268 * Walk the list of under-writeback pages of the given address space
269 * inclusive 269 * in the given range and wait for all of them.
270 */ 270 */
271int wait_on_page_writeback_range(struct address_space *mapping, 271int filemap_fdatawait_range(struct address_space *mapping, loff_t start_byte,
272 pgoff_t start, pgoff_t end) 272 loff_t end_byte)
273{ 273{
274 pgoff_t index = start_byte >> PAGE_CACHE_SHIFT;
275 pgoff_t end = end_byte >> PAGE_CACHE_SHIFT;
274 struct pagevec pvec; 276 struct pagevec pvec;
275 int nr_pages; 277 int nr_pages;
276 int ret = 0; 278 int ret = 0;
277 pgoff_t index;
278 279
279 if (end < start) 280 if (end_byte < start_byte)
280 return 0; 281 return 0;
281 282
282 pagevec_init(&pvec, 0); 283 pagevec_init(&pvec, 0);
283 index = start;
284 while ((index <= end) && 284 while ((index <= end) &&
285 (nr_pages = pagevec_lookup_tag(&pvec, mapping, &index, 285 (nr_pages = pagevec_lookup_tag(&pvec, mapping, &index,
286 PAGECACHE_TAG_WRITEBACK, 286 PAGECACHE_TAG_WRITEBACK,
@@ -310,25 +310,6 @@ int wait_on_page_writeback_range(struct address_space *mapping,
310 310
311 return ret; 311 return ret;
312} 312}
313
314/**
315 * filemap_fdatawait_range - wait for all under-writeback pages to complete in a given range
316 * @mapping: address space structure to wait for
317 * @start: offset in bytes where the range starts
318 * @end: offset in bytes where the range ends (inclusive)
319 *
320 * Walk the list of under-writeback pages of the given address space
321 * in the given range and wait for all of them.
322 *
323 * This is just a simple wrapper so that callers don't have to convert offsets
324 * to page indexes themselves
325 */
326int filemap_fdatawait_range(struct address_space *mapping, loff_t start,
327 loff_t end)
328{
329 return wait_on_page_writeback_range(mapping, start >> PAGE_CACHE_SHIFT,
330 end >> PAGE_CACHE_SHIFT);
331}
332EXPORT_SYMBOL(filemap_fdatawait_range); 313EXPORT_SYMBOL(filemap_fdatawait_range);
333 314
334/** 315/**
@@ -345,8 +326,7 @@ int filemap_fdatawait(struct address_space *mapping)
345 if (i_size == 0) 326 if (i_size == 0)
346 return 0; 327 return 0;
347 328
348 return wait_on_page_writeback_range(mapping, 0, 329 return filemap_fdatawait_range(mapping, 0, i_size - 1);
349 (i_size - 1) >> PAGE_CACHE_SHIFT);
350} 330}
351EXPORT_SYMBOL(filemap_fdatawait); 331EXPORT_SYMBOL(filemap_fdatawait);
352 332
@@ -393,9 +373,8 @@ int filemap_write_and_wait_range(struct address_space *mapping,
393 WB_SYNC_ALL); 373 WB_SYNC_ALL);
394 /* See comment of filemap_write_and_wait() */ 374 /* See comment of filemap_write_and_wait() */
395 if (err != -EIO) { 375 if (err != -EIO) {
396 int err2 = wait_on_page_writeback_range(mapping, 376 int err2 = filemap_fdatawait_range(mapping,
397 lstart >> PAGE_CACHE_SHIFT, 377 lstart, lend);
398 lend >> PAGE_CACHE_SHIFT);
399 if (!err) 378 if (!err)
400 err = err2; 379 err = err2;
401 } 380 }