diff options
author | Chris Mason <chris.mason@oracle.com> | 2009-12-17 15:47:17 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2009-12-17 15:47:17 -0500 |
commit | 3a1abec9f6880cf406593c392636199ea1c6c917 (patch) | |
tree | 280edc4cacb9d14224f7d3da3510d386329a08ae /fs/btrfs | |
parent | 83d3c9696fed237a3d96fce18299e2fcf112109f (diff) |
Btrfs: make sure fallocate properly starts a transaction
The recent patch to make fallocate enospc friendly would send
down a NULL trans handle to the allocator. This moves the
transaction start to properly fix things.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/inode.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index da76cad92ecf..5440bab23635 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -5802,23 +5802,23 @@ static int prealloc_file_range(struct inode *inode, u64 start, u64 end, | |||
5802 | while (num_bytes > 0) { | 5802 | while (num_bytes > 0) { |
5803 | alloc_size = min(num_bytes, root->fs_info->max_extent); | 5803 | alloc_size = min(num_bytes, root->fs_info->max_extent); |
5804 | 5804 | ||
5805 | trans = btrfs_start_transaction(root, 1); | ||
5806 | |||
5805 | ret = btrfs_reserve_extent(trans, root, alloc_size, | 5807 | ret = btrfs_reserve_extent(trans, root, alloc_size, |
5806 | root->sectorsize, 0, alloc_hint, | 5808 | root->sectorsize, 0, alloc_hint, |
5807 | (u64)-1, &ins, 1); | 5809 | (u64)-1, &ins, 1); |
5808 | if (ret) { | 5810 | if (ret) { |
5809 | WARN_ON(1); | 5811 | WARN_ON(1); |
5810 | break; | 5812 | goto stop_trans; |
5811 | } | 5813 | } |
5812 | 5814 | ||
5813 | ret = btrfs_reserve_metadata_space(root, 3); | 5815 | ret = btrfs_reserve_metadata_space(root, 3); |
5814 | if (ret) { | 5816 | if (ret) { |
5815 | btrfs_free_reserved_extent(root, ins.objectid, | 5817 | btrfs_free_reserved_extent(root, ins.objectid, |
5816 | ins.offset); | 5818 | ins.offset); |
5817 | break; | 5819 | goto stop_trans; |
5818 | } | 5820 | } |
5819 | 5821 | ||
5820 | trans = btrfs_start_transaction(root, 1); | ||
5821 | |||
5822 | ret = insert_reserved_file_extent(trans, inode, | 5822 | ret = insert_reserved_file_extent(trans, inode, |
5823 | cur_offset, ins.objectid, | 5823 | cur_offset, ins.objectid, |
5824 | ins.offset, ins.offset, | 5824 | ins.offset, ins.offset, |
@@ -5847,6 +5847,11 @@ static int prealloc_file_range(struct inode *inode, u64 start, u64 end, | |||
5847 | btrfs_unreserve_metadata_space(root, 3); | 5847 | btrfs_unreserve_metadata_space(root, 3); |
5848 | } | 5848 | } |
5849 | return ret; | 5849 | return ret; |
5850 | |||
5851 | stop_trans: | ||
5852 | btrfs_end_transaction(trans, root); | ||
5853 | return ret; | ||
5854 | |||
5850 | } | 5855 | } |
5851 | 5856 | ||
5852 | static long btrfs_fallocate(struct inode *inode, int mode, | 5857 | static long btrfs_fallocate(struct inode *inode, int mode, |