aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorMiao Xie <miaox@cn.fujitsu.com>2012-12-05 05:56:13 -0500
committerChris Mason <chris.mason@fusionio.com>2012-12-16 20:46:20 -0500
commitac6a2b36f9fcfbe4865550afb6d333dec6b57578 (patch)
tree7e6212618664d645a5954ddcd8de58267e0f916c /fs/btrfs
parent7426cc04d407621773af3a0403e57642e40c36bf (diff)
Btrfs: fix wrong return value of btrfs_truncate_page()
ret variant may be set to 0 if we read page successfully, but it might be released before we lock it again. On this case, if we fail to allocate a new page, we will return 0, it is wrong, fix it. Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/inode.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index bf609581c5d0..0446cbe8bcaf 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -3521,11 +3521,11 @@ int btrfs_truncate_page(struct inode *inode, loff_t from, loff_t len,
3521 if (ret) 3521 if (ret)
3522 goto out; 3522 goto out;
3523 3523
3524 ret = -ENOMEM;
3525again: 3524again:
3526 page = find_or_create_page(mapping, index, mask); 3525 page = find_or_create_page(mapping, index, mask);
3527 if (!page) { 3526 if (!page) {
3528 btrfs_delalloc_release_space(inode, PAGE_CACHE_SIZE); 3527 btrfs_delalloc_release_space(inode, PAGE_CACHE_SIZE);
3528 ret = -ENOMEM;
3529 goto out; 3529 goto out;
3530 } 3530 }
3531 3531
@@ -3574,7 +3574,6 @@ again:
3574 goto out_unlock; 3574 goto out_unlock;
3575 } 3575 }
3576 3576
3577 ret = 0;
3578 if (offset != PAGE_CACHE_SIZE) { 3577 if (offset != PAGE_CACHE_SIZE) {
3579 if (!len) 3578 if (!len)
3580 len = PAGE_CACHE_SIZE - offset; 3579 len = PAGE_CACHE_SIZE - offset;