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>
This commit is contained in:
Родитель
b8d9bfeb18
Коммит
d1ea6a6145
|
@ -5800,7 +5800,7 @@ out_fail:
|
|||
}
|
||||
|
||||
static int prealloc_file_range(struct inode *inode, u64 start, u64 end,
|
||||
u64 alloc_hint, int mode)
|
||||
u64 alloc_hint, int mode, loff_t actual_len)
|
||||
{
|
||||
struct btrfs_trans_handle *trans;
|
||||
struct btrfs_root *root = BTRFS_I(inode)->root;
|
||||
|
@ -5809,6 +5809,7 @@ static int prealloc_file_range(struct inode *inode, u64 start, u64 end,
|
|||
u64 cur_offset = start;
|
||||
u64 num_bytes = end - start;
|
||||
int ret = 0;
|
||||
u64 i_size;
|
||||
|
||||
while (num_bytes > 0) {
|
||||
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,
|
|||
BTRFS_I(inode)->flags |= BTRFS_INODE_PREALLOC;
|
||||
if (!(mode & FALLOC_FL_KEEP_SIZE) &&
|
||||
cur_offset > inode->i_size) {
|
||||
i_size_write(inode, cur_offset);
|
||||
btrfs_ordered_update_i_size(inode, cur_offset, NULL);
|
||||
if (cur_offset > actual_len)
|
||||
i_size = actual_len;
|
||||
else
|
||||
i_size = cur_offset;
|
||||
i_size_write(inode, i_size);
|
||||
btrfs_ordered_update_i_size(inode, i_size, NULL);
|
||||
}
|
||||
|
||||
ret = btrfs_update_inode(trans, root, inode);
|
||||
|
@ -5941,7 +5946,7 @@ static long btrfs_fallocate(struct inode *inode, int mode,
|
|||
!test_bit(EXTENT_FLAG_PREALLOC, &em->flags))) {
|
||||
ret = prealloc_file_range(inode,
|
||||
cur_offset, last_byte,
|
||||
alloc_hint, mode);
|
||||
alloc_hint, mode, offset+len);
|
||||
if (ret < 0) {
|
||||
free_extent_map(em);
|
||||
break;
|
||||
|
|
Загрузка…
Ссылка в новой задаче