- if (page->mapping != mapping) {
- unlock_page(page);
- continue;
- }
- page_index = page->index;
- next = page_index + 1;
- if (next == 0)
- wrapped = 1;
- if (page_index > end) {
- unlock_page(page);
- break;
- }
- wait_on_page_writeback(page);
- while (page_mapped(page)) {
- if (!did_range_unmap) {
- /*
- * Zap the rest of the file in one hit.
- */
- unmap_mapping_range(mapping,
- page_index << PAGE_CACHE_SHIFT,
- (end - page_index + 1)
- << PAGE_CACHE_SHIFT,
- 0);
- did_range_unmap = 1;
+ if (page->mapping == mapping) { /* truncate race? */
+ wait_on_page_writeback(page);
+ next = page->index + 1;
+ if (page_mapped(page)) {
+ clear_page_dirty(page);
+ ClearPageUptodate(page);