diff options
author | Josef Bacik <josef@redhat.com> | 2010-11-22 13:50:32 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2010-11-27 12:59:16 -0500 |
commit | 55a61d1d06a3dc443d0db8aaa613365dcb83b98a (patch) | |
tree | 39f59ec200674081b086f9e25393401d08848ffd /fs/btrfs/inode.c | |
parent | 45f49bce99d008d6864a20324548f35936ba46fb (diff) |
Btrfs: fix typo in fallocate to make it honor actual size
There is a typo in __btrfs_prealloc_file_range() where we set the i_size to
actual_len/cur_offset, and then just set it to cur_offset again, and do the same
with btrfs_ordered_update_i_size(). This fixes it back to keeping i_size in a
local variable and then updating i_size properly. Tested this with
xfs_io -F -f -c "falloc 0 1" -c "pwrite 0 1" foo
stat'ing foo gives us a size of 1 instead of 4096 like it was. Thanks,
Signed-off-by: Josef Bacik <josef@redhat.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 37cc1776a5d7..0058fb3c2561 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -7002,6 +7002,7 @@ static int __btrfs_prealloc_file_range(struct inode *inode, int mode, | |||
7002 | struct btrfs_root *root = BTRFS_I(inode)->root; | 7002 | struct btrfs_root *root = BTRFS_I(inode)->root; |
7003 | struct btrfs_key ins; | 7003 | struct btrfs_key ins; |
7004 | u64 cur_offset = start; | 7004 | u64 cur_offset = start; |
7005 | u64 i_size; | ||
7005 | int ret = 0; | 7006 | int ret = 0; |
7006 | bool own_trans = true; | 7007 | bool own_trans = true; |
7007 | 7008 | ||
@@ -7043,11 +7044,11 @@ static int __btrfs_prealloc_file_range(struct inode *inode, int mode, | |||
7043 | (actual_len > inode->i_size) && | 7044 | (actual_len > inode->i_size) && |
7044 | (cur_offset > inode->i_size)) { | 7045 | (cur_offset > inode->i_size)) { |
7045 | if (cur_offset > actual_len) | 7046 | if (cur_offset > actual_len) |
7046 | i_size_write(inode, actual_len); | 7047 | i_size = actual_len; |
7047 | else | 7048 | else |
7048 | i_size_write(inode, cur_offset); | 7049 | i_size = cur_offset; |
7049 | i_size_write(inode, cur_offset); | 7050 | i_size_write(inode, i_size); |
7050 | btrfs_ordered_update_i_size(inode, cur_offset, NULL); | 7051 | btrfs_ordered_update_i_size(inode, i_size, NULL); |
7051 | } | 7052 | } |
7052 | 7053 | ||
7053 | ret = btrfs_update_inode(trans, root, inode); | 7054 | ret = btrfs_update_inode(trans, root, inode); |