Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 263103
b: refs/heads/master
c: f1e490a
h: refs/heads/master
i:
  263101: 7d914d0
  263099: fe2aaaa
  263095: 8405af1
  263087: c23d13c
  263071: b0823e7
  263039: 21e9f95
v: v3
  • Loading branch information
Josef Bacik authored and Chris Mason committed Aug 18, 2011
1 parent d73e5a6 commit 94c111a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f81c9cdc567cd3160ff9e64868d9a1a7ee226480
refs/heads/master: f1e490a7ebe41e06324abbbcd86005b0af02a375
14 changes: 14 additions & 0 deletions trunk/fs/btrfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1631,11 +1631,15 @@ static long btrfs_fallocate(struct file *file, int mode,

cur_offset = alloc_start;
while (1) {
u64 actual_end;

em = btrfs_get_extent(inode, NULL, 0, cur_offset,
alloc_end - cur_offset, 0);
BUG_ON(IS_ERR_OR_NULL(em));
last_byte = min(extent_map_end(em), alloc_end);
actual_end = min_t(u64, extent_map_end(em), offset + len);
last_byte = (last_byte + mask) & ~mask;

if (em->block_start == EXTENT_MAP_HOLE ||
(cur_offset >= inode->i_size &&
!test_bit(EXTENT_FLAG_PREALLOC, &em->flags))) {
Expand All @@ -1648,6 +1652,16 @@ static long btrfs_fallocate(struct file *file, int mode,
free_extent_map(em);
break;
}
} else if (actual_end > inode->i_size &&
!(mode & FALLOC_FL_KEEP_SIZE)) {
/*
* We didn't need to allocate any more space, but we
* still extended the size of the file so we need to
* update i_size.
*/
inode->i_ctime = CURRENT_TIME;
i_size_write(inode, actual_end);
btrfs_ordered_update_i_size(inode, actual_end, NULL);
}
free_extent_map(em);

Expand Down

0 comments on commit 94c111a

Please sign in to comment.