mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 12:28:41 +08:00
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:
parent
9db5d510ac
commit
25ce28caaa
@ -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
|
||||
* 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 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 */
|
||||
len = round_up(start + len, root->fs_info->sectorsize) -
|
||||
round_down(start, root->fs_info->sectorsize);
|
||||
start = round_down(start, root->fs_info->sectorsize);
|
||||
len = round_up(start + len, fs_info->sectorsize) -
|
||||
round_down(start, fs_info->sectorsize);
|
||||
start = round_down(start, fs_info->sectorsize);
|
||||
|
||||
btrfs_free_reserved_data_space_noquota(root->fs_info, len);
|
||||
btrfs_qgroup_free_data(BTRFS_I(inode), reserved, start, len);
|
||||
btrfs_free_reserved_data_space_noquota(fs_info, len);
|
||||
btrfs_qgroup_free_data(inode, reserved, start, len);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -563,7 +563,7 @@ int btrfs_delalloc_reserve_space(struct inode *inode,
|
||||
return ret;
|
||||
ret = btrfs_delalloc_reserve_metadata(BTRFS_I(inode), len);
|
||||
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;
|
||||
}
|
||||
|
||||
@ -584,5 +584,5 @@ void btrfs_delalloc_release_space(struct inode *inode,
|
||||
u64 start, u64 len, bool 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_check_data_free_space(struct inode *inode,
|
||||
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);
|
||||
void btrfs_delalloc_release_space(struct inode *inode,
|
||||
struct extent_changeset *reserved,
|
||||
|
@ -1710,7 +1710,7 @@ static noinline ssize_t btrfs_buffered_write(struct kiocb *iocb,
|
||||
reserve_bytes);
|
||||
if (ret) {
|
||||
if (!only_release_metadata)
|
||||
btrfs_free_reserved_data_space(inode,
|
||||
btrfs_free_reserved_data_space(BTRFS_I(inode),
|
||||
data_reserved, pos,
|
||||
write_bytes);
|
||||
else
|
||||
@ -3232,7 +3232,7 @@ reserve_space:
|
||||
ret = btrfs_fallocate_update_isize(inode, offset + len, mode);
|
||||
out:
|
||||
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);
|
||||
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
|
||||
* it'll result in false ENOSPC error.
|
||||
*/
|
||||
btrfs_free_reserved_data_space(inode, data_reserved,
|
||||
cur_offset, last_byte - cur_offset);
|
||||
btrfs_free_reserved_data_space(BTRFS_I(inode),
|
||||
data_reserved, cur_offset,
|
||||
last_byte - cur_offset);
|
||||
}
|
||||
free_extent_map(em);
|
||||
cur_offset = last_byte;
|
||||
@ -3415,7 +3416,7 @@ static long btrfs_fallocate(struct file *file, int mode,
|
||||
range->len, i_blocksize(inode),
|
||||
offset + len, &alloc_hint);
|
||||
else
|
||||
btrfs_free_reserved_data_space(inode,
|
||||
btrfs_free_reserved_data_space(BTRFS_I(inode),
|
||||
data_reserved, range->start,
|
||||
range->len);
|
||||
list_del(&range->list);
|
||||
@ -3436,7 +3437,7 @@ out:
|
||||
inode_unlock(inode);
|
||||
/* Let go of our reservation. */
|
||||
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);
|
||||
extent_changeset_free(data_reserved);
|
||||
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);
|
||||
if (ret < 0) {
|
||||
if (!only_release_metadata)
|
||||
btrfs_free_reserved_data_space(inode, data_reserved,
|
||||
block_start, blocksize);
|
||||
btrfs_free_reserved_data_space(BTRFS_I(inode),
|
||||
data_reserved, block_start, blocksize);
|
||||
goto out;
|
||||
}
|
||||
again:
|
||||
@ -9772,7 +9772,7 @@ next:
|
||||
btrfs_end_transaction(trans);
|
||||
}
|
||||
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);
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user