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:
@@ -1180,19 +1180,26 @@ static int btrfs_truncate_page(struct address_space *mapping, loff_t from)
|
||||
goto out;
|
||||
|
||||
ret = -ENOMEM;
|
||||
again:
|
||||
page = grab_cache_page(mapping, index);
|
||||
if (!page)
|
||||
goto out;
|
||||
if (!PageUptodate(page)) {
|
||||
ret = btrfs_readpage(NULL, page);
|
||||
lock_page(page);
|
||||
if (page->mapping != mapping) {
|
||||
unlock_page(page);
|
||||
page_cache_release(page);
|
||||
goto again;
|
||||
}
|
||||
if (!PageUptodate(page)) {
|
||||
ret = -EIO;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
page_start = (u64)page->index << PAGE_CACHE_SHIFT;
|
||||
|
||||
page_start = (u64)page->index << PAGE_CACHE_SHIFT;
|
||||
wait_on_page_writeback(page);
|
||||
ret = btrfs_cow_one_page(inode, page, offset);
|
||||
|
||||
unlock_page(page);
|
||||
|
Reference in New Issue
Block a user