Commit 25ce28ca authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba

btrfs: make btrfs_free_reserved_data_space take btrfs_inode

It only uses btrfs_inode internally so take it as a parameter.
Signed-off-by: default avatarNikolay Borisov <nborisov@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 9db5d510
...@@ -289,18 +289,18 @@ void btrfs_free_reserved_data_space_noquota(struct btrfs_fs_info *fs_info, ...@@ -289,18 +289,18 @@ void btrfs_free_reserved_data_space_noquota(struct btrfs_fs_info *fs_info,
* This one will handle the per-inode data rsv map for accurate reserved * This one will handle the per-inode data rsv map for accurate reserved
* space framework. * space framework.
*/ */
void btrfs_free_reserved_data_space(struct inode *inode, void btrfs_free_reserved_data_space(struct btrfs_inode *inode,
struct extent_changeset *reserved, u64 start, u64 len) struct extent_changeset *reserved, u64 start, u64 len)
{ {
struct btrfs_root *root = BTRFS_I(inode)->root; struct btrfs_fs_info *fs_info = inode->root->fs_info;
/* Make sure the range is aligned to sectorsize */ /* Make sure the range is aligned to sectorsize */
len = round_up(start + len, root->fs_info->sectorsize) - len = round_up(start + len, fs_info->sectorsize) -
round_down(start, root->fs_info->sectorsize); round_down(start, fs_info->sectorsize);
start = round_down(start, root->fs_info->sectorsize); start = round_down(start, fs_info->sectorsize);
btrfs_free_reserved_data_space_noquota(root->fs_info, len); btrfs_free_reserved_data_space_noquota(fs_info, len);
btrfs_qgroup_free_data(BTRFS_I(inode), reserved, start, len); btrfs_qgroup_free_data(inode, reserved, start, len);
} }
/** /**
...@@ -563,7 +563,7 @@ int btrfs_delalloc_reserve_space(struct inode *inode, ...@@ -563,7 +563,7 @@ int btrfs_delalloc_reserve_space(struct inode *inode,
return ret; return ret;
ret = btrfs_delalloc_reserve_metadata(BTRFS_I(inode), len); ret = btrfs_delalloc_reserve_metadata(BTRFS_I(inode), len);
if (ret < 0) if (ret < 0)
btrfs_free_reserved_data_space(inode, *reserved, start, len); btrfs_free_reserved_data_space(BTRFS_I(inode), *reserved, start, len);
return ret; return ret;
} }
...@@ -584,5 +584,5 @@ void btrfs_delalloc_release_space(struct inode *inode, ...@@ -584,5 +584,5 @@ void btrfs_delalloc_release_space(struct inode *inode,
u64 start, u64 len, bool qgroup_free) u64 start, u64 len, bool qgroup_free)
{ {
btrfs_delalloc_release_metadata(BTRFS_I(inode), len, qgroup_free); btrfs_delalloc_release_metadata(BTRFS_I(inode), len, qgroup_free);
btrfs_free_reserved_data_space(inode, reserved, start, len); btrfs_free_reserved_data_space(BTRFS_I(inode), reserved, start, len);
} }
...@@ -8,7 +8,7 @@ struct extent_changeset; ...@@ -8,7 +8,7 @@ struct extent_changeset;
int btrfs_alloc_data_chunk_ondemand(struct btrfs_inode *inode, u64 bytes); int btrfs_alloc_data_chunk_ondemand(struct btrfs_inode *inode, u64 bytes);
int btrfs_check_data_free_space(struct inode *inode, int btrfs_check_data_free_space(struct inode *inode,
struct extent_changeset **reserved, u64 start, u64 len); struct extent_changeset **reserved, u64 start, u64 len);
void btrfs_free_reserved_data_space(struct inode *inode, void btrfs_free_reserved_data_space(struct btrfs_inode *inode,
struct extent_changeset *reserved, u64 start, u64 len); struct extent_changeset *reserved, u64 start, u64 len);
void btrfs_delalloc_release_space(struct inode *inode, void btrfs_delalloc_release_space(struct inode *inode,
struct extent_changeset *reserved, struct extent_changeset *reserved,
......
...@@ -1710,7 +1710,7 @@ static noinline ssize_t btrfs_buffered_write(struct kiocb *iocb, ...@@ -1710,7 +1710,7 @@ static noinline ssize_t btrfs_buffered_write(struct kiocb *iocb,
reserve_bytes); reserve_bytes);
if (ret) { if (ret) {
if (!only_release_metadata) if (!only_release_metadata)
btrfs_free_reserved_data_space(inode, btrfs_free_reserved_data_space(BTRFS_I(inode),
data_reserved, pos, data_reserved, pos,
write_bytes); write_bytes);
else else
...@@ -3232,7 +3232,7 @@ static int btrfs_zero_range(struct inode *inode, ...@@ -3232,7 +3232,7 @@ static int btrfs_zero_range(struct inode *inode,
ret = btrfs_fallocate_update_isize(inode, offset + len, mode); ret = btrfs_fallocate_update_isize(inode, offset + len, mode);
out: out:
if (ret && space_reserved) if (ret && space_reserved)
btrfs_free_reserved_data_space(inode, data_reserved, btrfs_free_reserved_data_space(BTRFS_I(inode), data_reserved,
alloc_start, bytes_to_reserve); alloc_start, bytes_to_reserve);
extent_changeset_free(data_reserved); extent_changeset_free(data_reserved);
...@@ -3397,8 +3397,9 @@ static long btrfs_fallocate(struct file *file, int mode, ...@@ -3397,8 +3397,9 @@ static long btrfs_fallocate(struct file *file, int mode,
* range, free reserved data space first, otherwise * range, free reserved data space first, otherwise
* it'll result in false ENOSPC error. * it'll result in false ENOSPC error.
*/ */
btrfs_free_reserved_data_space(inode, data_reserved, btrfs_free_reserved_data_space(BTRFS_I(inode),
cur_offset, last_byte - cur_offset); data_reserved, cur_offset,
last_byte - cur_offset);
} }
free_extent_map(em); free_extent_map(em);
cur_offset = last_byte; cur_offset = last_byte;
...@@ -3415,7 +3416,7 @@ static long btrfs_fallocate(struct file *file, int mode, ...@@ -3415,7 +3416,7 @@ static long btrfs_fallocate(struct file *file, int mode,
range->len, i_blocksize(inode), range->len, i_blocksize(inode),
offset + len, &alloc_hint); offset + len, &alloc_hint);
else else
btrfs_free_reserved_data_space(inode, btrfs_free_reserved_data_space(BTRFS_I(inode),
data_reserved, range->start, data_reserved, range->start,
range->len); range->len);
list_del(&range->list); list_del(&range->list);
...@@ -3436,7 +3437,7 @@ static long btrfs_fallocate(struct file *file, int mode, ...@@ -3436,7 +3437,7 @@ static long btrfs_fallocate(struct file *file, int mode,
inode_unlock(inode); inode_unlock(inode);
/* Let go of our reservation. */ /* Let go of our reservation. */
if (ret != 0 && !(mode & FALLOC_FL_ZERO_RANGE)) if (ret != 0 && !(mode & FALLOC_FL_ZERO_RANGE))
btrfs_free_reserved_data_space(inode, data_reserved, btrfs_free_reserved_data_space(BTRFS_I(inode), data_reserved,
cur_offset, alloc_end - cur_offset); cur_offset, alloc_end - cur_offset);
extent_changeset_free(data_reserved); extent_changeset_free(data_reserved);
return ret; return ret;
......
...@@ -4532,8 +4532,8 @@ int btrfs_truncate_block(struct inode *inode, loff_t from, loff_t len, ...@@ -4532,8 +4532,8 @@ int btrfs_truncate_block(struct inode *inode, loff_t from, loff_t len,
ret = btrfs_delalloc_reserve_metadata(BTRFS_I(inode), blocksize); ret = btrfs_delalloc_reserve_metadata(BTRFS_I(inode), blocksize);
if (ret < 0) { if (ret < 0) {
if (!only_release_metadata) if (!only_release_metadata)
btrfs_free_reserved_data_space(inode, data_reserved, btrfs_free_reserved_data_space(BTRFS_I(inode),
block_start, blocksize); data_reserved, block_start, blocksize);
goto out; goto out;
} }
again: again:
...@@ -9772,7 +9772,7 @@ static int __btrfs_prealloc_file_range(struct inode *inode, int mode, ...@@ -9772,7 +9772,7 @@ static int __btrfs_prealloc_file_range(struct inode *inode, int mode,
btrfs_end_transaction(trans); btrfs_end_transaction(trans);
} }
if (clear_offset < end) if (clear_offset < end)
btrfs_free_reserved_data_space(inode, NULL, clear_offset, btrfs_free_reserved_data_space(BTRFS_I(inode), NULL, clear_offset,
end - clear_offset + 1); end - clear_offset + 1);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment