mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 20:00:53 +07:00
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>
This commit is contained in:
parent
83d3c9696f
commit
3a1abec9f6
@ -5802,23 +5802,23 @@ static int prealloc_file_range(struct inode *inode, u64 start, u64 end,
|
|||||||
while (num_bytes > 0) {
|
while (num_bytes > 0) {
|
||||||
alloc_size = min(num_bytes, root->fs_info->max_extent);
|
alloc_size = min(num_bytes, root->fs_info->max_extent);
|
||||||
|
|
||||||
|
trans = btrfs_start_transaction(root, 1);
|
||||||
|
|
||||||
ret = btrfs_reserve_extent(trans, root, alloc_size,
|
ret = btrfs_reserve_extent(trans, root, alloc_size,
|
||||||
root->sectorsize, 0, alloc_hint,
|
root->sectorsize, 0, alloc_hint,
|
||||||
(u64)-1, &ins, 1);
|
(u64)-1, &ins, 1);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
WARN_ON(1);
|
WARN_ON(1);
|
||||||
break;
|
goto stop_trans;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = btrfs_reserve_metadata_space(root, 3);
|
ret = btrfs_reserve_metadata_space(root, 3);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
btrfs_free_reserved_extent(root, ins.objectid,
|
btrfs_free_reserved_extent(root, ins.objectid,
|
||||||
ins.offset);
|
ins.offset);
|
||||||
break;
|
goto stop_trans;
|
||||||
}
|
}
|
||||||
|
|
||||||
trans = btrfs_start_transaction(root, 1);
|
|
||||||
|
|
||||||
ret = insert_reserved_file_extent(trans, inode,
|
ret = insert_reserved_file_extent(trans, inode,
|
||||||
cur_offset, ins.objectid,
|
cur_offset, ins.objectid,
|
||||||
ins.offset, ins.offset,
|
ins.offset, ins.offset,
|
||||||
@ -5847,6 +5847,11 @@ static int prealloc_file_range(struct inode *inode, u64 start, u64 end,
|
|||||||
btrfs_unreserve_metadata_space(root, 3);
|
btrfs_unreserve_metadata_space(root, 3);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
stop_trans:
|
||||||
|
btrfs_end_transaction(trans, root);
|
||||||
|
return ret;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static long btrfs_fallocate(struct inode *inode, int mode,
|
static long btrfs_fallocate(struct inode *inode, int mode,
|
||||||
|
Loading…
Reference in New Issue
Block a user