Skip to content

Commit

Permalink
Merge branch 'master' of ssh://master.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/mason/btrfs-unstable into for-linus
  • Loading branch information
Chris Mason committed Dec 17, 2009
2 parents ebfee3d + 3a1abec commit 7a5d24b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -5802,23 +5802,23 @@ static int prealloc_file_range(struct inode *inode, u64 start, u64 end,
while (num_bytes > 0) {
alloc_size = min(num_bytes, root->fs_info->max_extent);

trans = btrfs_start_transaction(root, 1);

ret = btrfs_reserve_extent(trans, root, alloc_size,
root->sectorsize, 0, alloc_hint,
(u64)-1, &ins, 1);
if (ret) {
WARN_ON(1);
break;
goto stop_trans;
}

ret = btrfs_reserve_metadata_space(root, 3);
if (ret) {
btrfs_free_reserved_extent(root, ins.objectid,
ins.offset);
break;
goto stop_trans;
}

trans = btrfs_start_transaction(root, 1);

ret = insert_reserved_file_extent(trans, inode,
cur_offset, ins.objectid,
ins.offset, ins.offset,
Expand Down Expand Up @@ -5847,6 +5847,11 @@ static int prealloc_file_range(struct inode *inode, u64 start, u64 end,
btrfs_unreserve_metadata_space(root, 3);
}
return ret;

stop_trans:
btrfs_end_transaction(trans, root);
return ret;

}

static long btrfs_fallocate(struct inode *inode, int mode,
Expand Down

0 comments on commit 7a5d24b

Please sign in to comment.