aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2009-12-17 15:47:17 -0500
committerChris Mason <chris.mason@oracle.com>2009-12-17 15:47:17 -0500
commit3a1abec9f6880cf406593c392636199ea1c6c917 (patch)
tree280edc4cacb9d14224f7d3da3510d386329a08ae /fs
parent83d3c9696fed237a3d96fce18299e2fcf112109f (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')
-rw-r--r--fs/btrfs/inode.c13
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
5851stop_trans:
5852 btrfs_end_transaction(trans, root);
5853 return ret;
5854
5850} 5855}
5851 5856
5852static long btrfs_fallocate(struct inode *inode, int mode, 5857static long btrfs_fallocate(struct inode *inode, int mode,