Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 180052
b: refs/heads/master
c: d1ea6a6
h: refs/heads/master
v: v3
  • Loading branch information
Aneesh Kumar K.V authored and Chris Mason committed Jan 28, 2010
1 parent b3e0504 commit 89d2f3f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b8d9bfeb18f9af794020d96e9bee984d18a8d737
refs/heads/master: d1ea6a61454e7d7ff0873d0ad1ae27d5807da0d3
13 changes: 9 additions & 4 deletions trunk/fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -5800,7 +5800,7 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry,
}

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;
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 89d2f3f

Please sign in to comment.