diff options
author | Chris Mason <chris.mason@oracle.com> | 2011-08-18 10:38:03 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2011-08-18 10:38:03 -0400 |
commit | 81d86e1b70961f4816f961875e0c706b0954acad (patch) | |
tree | ac69ce2e8d174260770d1a84d7d8fe910939c923 /fs/btrfs/file.c | |
parent | 9a4327ca1f45f82edad7dc0a4e52ce9316e0950c (diff) | |
parent | f1e490a7ebe41e06324abbbcd86005b0af02a375 (diff) |
Merge branch 'btrfs-3.0' into for-linus
Diffstat (limited to 'fs/btrfs/file.c')
-rw-r--r-- | fs/btrfs/file.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index f7d9df7f3fdd..e7872e485f13 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c | |||
@@ -150,6 +150,8 @@ int btrfs_add_inode_defrag(struct btrfs_trans_handle *trans, | |||
150 | spin_lock(&root->fs_info->defrag_inodes_lock); | 150 | spin_lock(&root->fs_info->defrag_inodes_lock); |
151 | if (!BTRFS_I(inode)->in_defrag) | 151 | if (!BTRFS_I(inode)->in_defrag) |
152 | __btrfs_add_inode_defrag(inode, defrag); | 152 | __btrfs_add_inode_defrag(inode, defrag); |
153 | else | ||
154 | kfree(defrag); | ||
153 | spin_unlock(&root->fs_info->defrag_inodes_lock); | 155 | spin_unlock(&root->fs_info->defrag_inodes_lock); |
154 | return 0; | 156 | return 0; |
155 | } | 157 | } |
@@ -1638,11 +1640,15 @@ static long btrfs_fallocate(struct file *file, int mode, | |||
1638 | 1640 | ||
1639 | cur_offset = alloc_start; | 1641 | cur_offset = alloc_start; |
1640 | while (1) { | 1642 | while (1) { |
1643 | u64 actual_end; | ||
1644 | |||
1641 | em = btrfs_get_extent(inode, NULL, 0, cur_offset, | 1645 | em = btrfs_get_extent(inode, NULL, 0, cur_offset, |
1642 | alloc_end - cur_offset, 0); | 1646 | alloc_end - cur_offset, 0); |
1643 | BUG_ON(IS_ERR_OR_NULL(em)); | 1647 | BUG_ON(IS_ERR_OR_NULL(em)); |
1644 | last_byte = min(extent_map_end(em), alloc_end); | 1648 | last_byte = min(extent_map_end(em), alloc_end); |
1649 | actual_end = min_t(u64, extent_map_end(em), offset + len); | ||
1645 | last_byte = (last_byte + mask) & ~mask; | 1650 | last_byte = (last_byte + mask) & ~mask; |
1651 | |||
1646 | if (em->block_start == EXTENT_MAP_HOLE || | 1652 | if (em->block_start == EXTENT_MAP_HOLE || |
1647 | (cur_offset >= inode->i_size && | 1653 | (cur_offset >= inode->i_size && |
1648 | !test_bit(EXTENT_FLAG_PREALLOC, &em->flags))) { | 1654 | !test_bit(EXTENT_FLAG_PREALLOC, &em->flags))) { |
@@ -1655,6 +1661,16 @@ static long btrfs_fallocate(struct file *file, int mode, | |||
1655 | free_extent_map(em); | 1661 | free_extent_map(em); |
1656 | break; | 1662 | break; |
1657 | } | 1663 | } |
1664 | } else if (actual_end > inode->i_size && | ||
1665 | !(mode & FALLOC_FL_KEEP_SIZE)) { | ||
1666 | /* | ||
1667 | * We didn't need to allocate any more space, but we | ||
1668 | * still extended the size of the file so we need to | ||
1669 | * update i_size. | ||
1670 | */ | ||
1671 | inode->i_ctime = CURRENT_TIME; | ||
1672 | i_size_write(inode, actual_end); | ||
1673 | btrfs_ordered_update_i_size(inode, actual_end, NULL); | ||
1658 | } | 1674 | } |
1659 | free_extent_map(em); | 1675 | free_extent_map(em); |
1660 | 1676 | ||