In the spirit of filemap_fdatawait_range() and filemap_fdatawait_keep_errors(), introduce filemap_fdatawait_range_keep_errors() which both takes a range upon which to wait and does not clear errors from the address space.
Unified · Split
| @@ -2712,6 +2712,8 @@ extern int filemap_flush(struct address_space *); · 2711 unmodified lines | |||
| 2712 | extern int filemap_fdatawait_keep_errors(struct address_space *mapping); | 2712 | extern int filemap_fdatawait_keep_errors(struct address_space *mapping); |
| 2713 | extern int filemap_fdatawait_range(struct address_space *, loff_t lstart, | 2713 | extern int filemap_fdatawait_range(struct address_space *, loff_t lstart, |
| 2714 | loff_t lend); | 2714 | loff_t lend); |
| 2715 | extern int filemap_fdatawait_range_keep_errors(struct address_space *mapping, | ||
| 2716 | loff_t start_byte, loff_t end_byte); | ||
| 2715 | 2717 | ||
| 2716 | static inline int filemap_fdatawait(struct address_space *mapping) | 2718 | static inline int filemap_fdatawait(struct address_space *mapping) |
| 2717 | { | 2719 | { |
| @@ -553,6 +553,28 @@ int filemap_fdatawait_range(struct address_space *mapping, loff_t start_byte, · 552 unmodified lines | |||
| 553 | } | 553 | } |
| 554 | EXPORT_SYMBOL(filemap_fdatawait_range); | 554 | EXPORT_SYMBOL(filemap_fdatawait_range); |
| 555 | 555 | ||
| 556 | /** | ||
| 557 | * filemap_fdatawait_range_keep_errors - wait for writeback to complete | ||
| 558 | * @mapping: address space structure to wait for | ||
| 559 | * @start_byte: offset in bytes where the range starts | ||
| 560 | * @end_byte: offset in bytes where the range ends (inclusive) | ||
| 561 | * | ||
| 562 | * Walk the list of under-writeback pages of the given address space in the | ||
| 563 | * given range and wait for all of them. Unlike filemap_fdatawait_range(), | ||
| 564 | * this function does not clear error status of the address space. | ||
| 565 | * | ||
| 566 | * Use this function if callers don't handle errors themselves. Expected | ||
| 567 | * call sites are system-wide / filesystem-wide data flushers: e.g. sync(2), | ||
| 568 | * fsfreeze(8) | ||
| 569 | */ | ||
| 570 | int filemap_fdatawait_range_keep_errors(struct address_space *mapping, | ||
| 571 | loff_t start_byte, loff_t end_byte) | ||
| 572 | { | ||
| 573 | __filemap_fdatawait_range(mapping, start_byte, end_byte); | ||
| 574 | return filemap_check_and_keep_errors(mapping); | ||
| 575 | } | ||
| 576 | EXPORT_SYMBOL(filemap_fdatawait_range_keep_errors); | ||
| 577 | |||
| 556 | /** | 578 | /** |
| 557 | * file_fdatawait_range - wait for writeback to complete | 579 | * file_fdatawait_range - wait for writeback to complete |
| 558 | * @file: file pointing to address space structure to wait for | 580 | * @file: file pointing to address space structure to wait for |