summaryrefslogtreecommitdiff
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-05-15 09:13:45 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:04:03 -0400
commit211c17f51f46dc6c308c742098273dd46b5ca59c (patch)
treed72de74136af93236f2b37088ff310f08ddeadf5 /fs/btrfs/inode.c
parenta0af469b58944f6e8c5c8ecbebb42997baf0cb9e (diff)
downloadlwn-211c17f51f46dc6c308c742098273dd46b5ca59c.tar.gz
lwn-211c17f51f46dc6c308c742098273dd46b5ca59c.zip
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>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 08760ff9bab7..40b4a8ec17fe 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -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);