Commit e5b7231e authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba

btrfs: make btrfs_delalloc_reserve_space take btrfs_inode

All of its children take btrfs_inode so bubble up this requirement to
btrfs_delalloc_reserve_space's interface and stop calling BTRFS_I
internally.
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 36ea6f3e
...@@ -553,17 +553,17 @@ void btrfs_delalloc_release_extents(struct btrfs_inode *inode, u64 num_bytes) ...@@ -553,17 +553,17 @@ void btrfs_delalloc_release_extents(struct btrfs_inode *inode, u64 num_bytes)
* Return 0 for success * Return 0 for success
* Return <0 for error(-ENOSPC or -EQUOT) * Return <0 for error(-ENOSPC or -EQUOT)
*/ */
int btrfs_delalloc_reserve_space(struct inode *inode, int btrfs_delalloc_reserve_space(struct btrfs_inode *inode,
struct extent_changeset **reserved, u64 start, u64 len) struct extent_changeset **reserved, u64 start, u64 len)
{ {
int ret; int ret;
ret = btrfs_check_data_free_space(BTRFS_I(inode), reserved, start, len); ret = btrfs_check_data_free_space(inode, reserved, start, len);
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = btrfs_delalloc_reserve_metadata(BTRFS_I(inode), len); ret = btrfs_delalloc_reserve_metadata(inode, len);
if (ret < 0) if (ret < 0)
btrfs_free_reserved_data_space(BTRFS_I(inode), *reserved, start, len); btrfs_free_reserved_data_space(inode, *reserved, start, len);
return ret; return ret;
} }
......
...@@ -17,7 +17,7 @@ void btrfs_free_reserved_data_space_noquota(struct btrfs_fs_info *fs_info, ...@@ -17,7 +17,7 @@ void btrfs_free_reserved_data_space_noquota(struct btrfs_fs_info *fs_info,
u64 len); u64 len);
void btrfs_delalloc_release_metadata(struct btrfs_inode *inode, u64 num_bytes, void btrfs_delalloc_release_metadata(struct btrfs_inode *inode, u64 num_bytes,
bool qgroup_free); bool qgroup_free);
int btrfs_delalloc_reserve_space(struct inode *inode, int btrfs_delalloc_reserve_space(struct btrfs_inode *inode,
struct extent_changeset **reserved, u64 start, u64 len); struct extent_changeset **reserved, u64 start, u64 len);
#endif /* BTRFS_DELALLOC_SPACE_H */ #endif /* BTRFS_DELALLOC_SPACE_H */
...@@ -495,7 +495,8 @@ int btrfs_save_ino_cache(struct btrfs_root *root, ...@@ -495,7 +495,8 @@ int btrfs_save_ino_cache(struct btrfs_root *root,
/* Just to make sure we have enough space */ /* Just to make sure we have enough space */
prealloc += 8 * PAGE_SIZE; prealloc += 8 * PAGE_SIZE;
ret = btrfs_delalloc_reserve_space(inode, &data_reserved, 0, prealloc); ret = btrfs_delalloc_reserve_space(BTRFS_I(inode), &data_reserved, 0,
prealloc);
if (ret) if (ret)
goto out_put; goto out_put;
......
...@@ -2297,8 +2297,8 @@ static void btrfs_writepage_fixup_worker(struct btrfs_work *work) ...@@ -2297,8 +2297,8 @@ static void btrfs_writepage_fixup_worker(struct btrfs_work *work)
* This is similar to page_mkwrite, we need to reserve the space before * This is similar to page_mkwrite, we need to reserve the space before
* we take the page lock. * we take the page lock.
*/ */
ret = btrfs_delalloc_reserve_space(inode, &data_reserved, page_start, ret = btrfs_delalloc_reserve_space(BTRFS_I(inode), &data_reserved,
PAGE_SIZE); page_start, PAGE_SIZE);
again: again:
lock_page(page); lock_page(page);
...@@ -4518,7 +4518,6 @@ int btrfs_truncate_block(struct inode *inode, loff_t from, loff_t len, ...@@ -4518,7 +4518,6 @@ int btrfs_truncate_block(struct inode *inode, loff_t from, loff_t len,
block_start = round_down(from, blocksize); block_start = round_down(from, blocksize);
block_end = block_start + blocksize - 1; block_end = block_start + blocksize - 1;
ret = btrfs_check_data_free_space(BTRFS_I(inode), &data_reserved, ret = btrfs_check_data_free_space(BTRFS_I(inode), &data_reserved,
block_start, blocksize); block_start, blocksize);
if (ret < 0) { if (ret < 0) {
...@@ -7916,7 +7915,7 @@ static ssize_t btrfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter) ...@@ -7916,7 +7915,7 @@ static ssize_t btrfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
inode_unlock(inode); inode_unlock(inode);
relock = true; relock = true;
} }
ret = btrfs_delalloc_reserve_space(inode, &data_reserved, ret = btrfs_delalloc_reserve_space(BTRFS_I(inode), &data_reserved,
offset, count); offset, count);
if (ret) if (ret)
goto out; goto out;
...@@ -8231,8 +8230,8 @@ vm_fault_t btrfs_page_mkwrite(struct vm_fault *vmf) ...@@ -8231,8 +8230,8 @@ vm_fault_t btrfs_page_mkwrite(struct vm_fault *vmf)
* end up waiting indefinitely to get a lock on the page currently * end up waiting indefinitely to get a lock on the page currently
* being processed by btrfs_page_mkwrite() function. * being processed by btrfs_page_mkwrite() function.
*/ */
ret2 = btrfs_delalloc_reserve_space(inode, &data_reserved, page_start, ret2 = btrfs_delalloc_reserve_space(BTRFS_I(inode), &data_reserved,
reserved_space); page_start, reserved_space);
if (!ret2) { if (!ret2) {
ret2 = file_update_time(vmf->vma->vm_file); ret2 = file_update_time(vmf->vma->vm_file);
reserved = 1; reserved = 1;
......
...@@ -1243,7 +1243,7 @@ static int cluster_pages_for_defrag(struct inode *inode, ...@@ -1243,7 +1243,7 @@ static int cluster_pages_for_defrag(struct inode *inode,
page_cnt = min_t(u64, (u64)num_pages, (u64)file_end - start_index + 1); page_cnt = min_t(u64, (u64)num_pages, (u64)file_end - start_index + 1);
ret = btrfs_delalloc_reserve_space(inode, &data_reserved, ret = btrfs_delalloc_reserve_space(BTRFS_I(inode), &data_reserved,
start_index << PAGE_SHIFT, start_index << PAGE_SHIFT,
page_cnt << PAGE_SHIFT); page_cnt << PAGE_SHIFT);
if (ret) if (ret)
......
...@@ -68,8 +68,8 @@ static int copy_inline_to_page(struct inode *inode, ...@@ -68,8 +68,8 @@ static int copy_inline_to_page(struct inode *inode,
* reservation here. Also we must not do the reservation while holding * reservation here. Also we must not do the reservation while holding
* a transaction open, otherwise we would deadlock. * a transaction open, otherwise we would deadlock.
*/ */
ret = btrfs_delalloc_reserve_space(inode, &data_reserved, file_offset, ret = btrfs_delalloc_reserve_space(BTRFS_I(inode), &data_reserved,
block_size); file_offset, block_size);
if (ret) if (ret)
goto out; goto out;
......
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