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 f7d9df7f3fd..e7872e485f1 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, spin_lock(&root->fs_info->defrag_inodes_lock); if (!BTRFS_I(inode)->in_defrag) __btrfs_add_inode_defrag(inode, defrag); + else + kfree(defrag); spin_unlock(&root->fs_info->defrag_inodes_lock); return 0; } @@ -1638,11 +1640,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))) { @@ -1655,6 +1661,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); |