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: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Nikolay Borisov 2020-06-03 08:55:39 +03:00 коммит произвёл David Sterba
Родитель 9db5d510ac
Коммит 25ce28caaa
4 изменённых файлов: 20 добавлений и 19 удалений

Просмотреть файл

@ -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,
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,
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;
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,
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 @@ reserve_space:
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,
* 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,
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 @@ out:
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,
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 @@ next:
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;
} }