Fix corners in writepage and btrfs_truncate_page
The extent_io writepage calls needed an extra check for discarding pages that started on th last byte in the file. btrfs_truncate_page needed checks to make sure the page was still part of the file after reading it, and most importantly, needed to wait for all IO to the page to finish before freeing the corresponding extents on disk. Signed-off-by: Chris Mason <chris.mason@oracle.com>
This commit is contained in:
@@ -1988,9 +1988,12 @@ static int __extent_writepage(struct page *page, struct writeback_control *wbc,
|
||||
u64 nr_delalloc;
|
||||
u64 delalloc_end;
|
||||
|
||||
|
||||
WARN_ON(!PageLocked(page));
|
||||
if (page->index > end_index) {
|
||||
clear_extent_dirty(tree, start, page_end, GFP_NOFS);
|
||||
page_offset = i_size & (PAGE_CACHE_SIZE - 1);
|
||||
if (page->index > end_index ||
|
||||
(page->index == end_index && !page_offset)) {
|
||||
page->mapping->a_ops->invalidatepage(page, 0);
|
||||
unlock_page(page);
|
||||
return 0;
|
||||
}
|
||||
@@ -1998,13 +2001,13 @@ static int __extent_writepage(struct page *page, struct writeback_control *wbc,
|
||||
if (page->index == end_index) {
|
||||
char *userpage;
|
||||
|
||||
size_t offset = i_size & (PAGE_CACHE_SIZE - 1);
|
||||
|
||||
userpage = kmap_atomic(page, KM_USER0);
|
||||
memset(userpage + offset, 0, PAGE_CACHE_SIZE - offset);
|
||||
flush_dcache_page(page);
|
||||
memset(userpage + page_offset, 0,
|
||||
PAGE_CACHE_SIZE - page_offset);
|
||||
kunmap_atomic(userpage, KM_USER0);
|
||||
flush_dcache_page(page);
|
||||
}
|
||||
page_offset = 0;
|
||||
|
||||
set_page_extent_mapped(page);
|
||||
|
||||
|
Reference in New Issue
Block a user