aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>2010-01-20 02:28:54 -0500
committerChris Mason <chris.mason@oracle.com>2010-01-28 16:20:38 -0500
commitd1ea6a61454e7d7ff0873d0ad1ae27d5807da0d3 (patch)
tree73645e52ffa4a38ea4a2a871489d0e2622e7304e /fs/btrfs
parentb8d9bfeb18f9af794020d96e9bee984d18a8d737 (diff)
Btrfs: Use correct values when updating inode i_size on fallocate
commit f2bc9dd07e3424c4ec5f3949961fe053d47bc825 Author: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Date: Wed Jan 20 12:57:53 2010 +0530 Btrfs: Use correct values when updating inode i_size on fallocate Even though we allocate more, we should be updating inode i_size as per the arguments passed Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/inode.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index f46c57276844..5606361b5f04 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -5800,7 +5800,7 @@ out_fail:
5800} 5800}
5801 5801
5802static int prealloc_file_range(struct inode *inode, u64 start, u64 end, 5802static int prealloc_file_range(struct inode *inode, u64 start, u64 end,
5803 u64 alloc_hint, int mode) 5803 u64 alloc_hint, int mode, loff_t actual_len)
5804{ 5804{
5805 struct btrfs_trans_handle *trans; 5805 struct btrfs_trans_handle *trans;
5806 struct btrfs_root *root = BTRFS_I(inode)->root; 5806 struct btrfs_root *root = BTRFS_I(inode)->root;
@@ -5809,6 +5809,7 @@ static int prealloc_file_range(struct inode *inode, u64 start, u64 end,
5809 u64 cur_offset = start; 5809 u64 cur_offset = start;
5810 u64 num_bytes = end - start; 5810 u64 num_bytes = end - start;
5811 int ret = 0; 5811 int ret = 0;
5812 u64 i_size;
5812 5813
5813 while (num_bytes > 0) { 5814 while (num_bytes > 0) {
5814 alloc_size = min(num_bytes, root->fs_info->max_extent); 5815 alloc_size = min(num_bytes, root->fs_info->max_extent);
@@ -5847,8 +5848,12 @@ static int prealloc_file_range(struct inode *inode, u64 start, u64 end,
5847 BTRFS_I(inode)->flags |= BTRFS_INODE_PREALLOC; 5848 BTRFS_I(inode)->flags |= BTRFS_INODE_PREALLOC;
5848 if (!(mode & FALLOC_FL_KEEP_SIZE) && 5849 if (!(mode & FALLOC_FL_KEEP_SIZE) &&
5849 cur_offset > inode->i_size) { 5850 cur_offset > inode->i_size) {
5850 i_size_write(inode, cur_offset); 5851 if (cur_offset > actual_len)
5851 btrfs_ordered_update_i_size(inode, cur_offset, NULL); 5852 i_size = actual_len;
5853 else
5854 i_size = cur_offset;
5855 i_size_write(inode, i_size);
5856 btrfs_ordered_update_i_size(inode, i_size, NULL);
5852 } 5857 }
5853 5858
5854 ret = btrfs_update_inode(trans, root, inode); 5859 ret = btrfs_update_inode(trans, root, inode);
@@ -5941,7 +5946,7 @@ static long btrfs_fallocate(struct inode *inode, int mode,
5941 !test_bit(EXTENT_FLAG_PREALLOC, &em->flags))) { 5946 !test_bit(EXTENT_FLAG_PREALLOC, &em->flags))) {
5942 ret = prealloc_file_range(inode, 5947 ret = prealloc_file_range(inode,
5943 cur_offset, last_byte, 5948 cur_offset, last_byte,
5944 alloc_hint, mode); 5949 alloc_hint, mode, offset+len);
5945 if (ret < 0) { 5950 if (ret < 0) {
5946 free_extent_map(em); 5951 free_extent_map(em);
5947 break; 5952 break;