Commit 86d52921 authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba

btrfs: make btrfs_delalloc_release_space take btrfs_inode

It needs btrfs_inode so take it as a parameter directly.
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 25ce28ca
...@@ -579,10 +579,10 @@ int btrfs_delalloc_reserve_space(struct inode *inode, ...@@ -579,10 +579,10 @@ int btrfs_delalloc_reserve_space(struct inode *inode,
* list if there are no delalloc bytes left. * list if there are no delalloc bytes left.
* Also it will handle the qgroup reserved space. * Also it will handle the qgroup reserved space.
*/ */
void btrfs_delalloc_release_space(struct inode *inode, void btrfs_delalloc_release_space(struct btrfs_inode *inode,
struct extent_changeset *reserved, struct extent_changeset *reserved,
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(inode, len, qgroup_free);
btrfs_free_reserved_data_space(BTRFS_I(inode), reserved, start, len); btrfs_free_reserved_data_space(inode, reserved, start, len);
} }
...@@ -10,7 +10,7 @@ int btrfs_check_data_free_space(struct inode *inode, ...@@ -10,7 +10,7 @@ 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 btrfs_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 btrfs_inode *inode,
struct extent_changeset *reserved, struct extent_changeset *reserved,
u64 start, u64 len, bool qgroup_free); u64 start, u64 len, bool qgroup_free);
void btrfs_free_reserved_data_space_noquota(struct btrfs_fs_info *fs_info, void btrfs_free_reserved_data_space_noquota(struct btrfs_fs_info *fs_info,
......
...@@ -1784,7 +1784,7 @@ static noinline ssize_t btrfs_buffered_write(struct kiocb *iocb, ...@@ -1784,7 +1784,7 @@ static noinline ssize_t btrfs_buffered_write(struct kiocb *iocb,
__pos = round_down(pos, __pos = round_down(pos,
fs_info->sectorsize) + fs_info->sectorsize) +
(dirty_pages << PAGE_SHIFT); (dirty_pages << PAGE_SHIFT);
btrfs_delalloc_release_space(inode, btrfs_delalloc_release_space(BTRFS_I(inode),
data_reserved, __pos, data_reserved, __pos,
release_bytes, true); release_bytes, true);
} }
...@@ -1850,7 +1850,8 @@ static noinline ssize_t btrfs_buffered_write(struct kiocb *iocb, ...@@ -1850,7 +1850,8 @@ static noinline ssize_t btrfs_buffered_write(struct kiocb *iocb,
btrfs_delalloc_release_metadata(BTRFS_I(inode), btrfs_delalloc_release_metadata(BTRFS_I(inode),
release_bytes, true); release_bytes, true);
} else { } else {
btrfs_delalloc_release_space(inode, data_reserved, btrfs_delalloc_release_space(BTRFS_I(inode),
data_reserved,
round_down(pos, fs_info->sectorsize), round_down(pos, fs_info->sectorsize),
release_bytes, true); release_bytes, true);
} }
......
...@@ -2328,7 +2328,8 @@ static void btrfs_writepage_fixup_worker(struct btrfs_work *work) ...@@ -2328,7 +2328,8 @@ static void btrfs_writepage_fixup_worker(struct btrfs_work *work)
if (!ret) { if (!ret) {
btrfs_delalloc_release_extents(BTRFS_I(inode), btrfs_delalloc_release_extents(BTRFS_I(inode),
PAGE_SIZE); PAGE_SIZE);
btrfs_delalloc_release_space(inode, data_reserved, btrfs_delalloc_release_space(BTRFS_I(inode),
data_reserved,
page_start, PAGE_SIZE, page_start, PAGE_SIZE,
true); true);
} }
...@@ -2378,8 +2379,8 @@ static void btrfs_writepage_fixup_worker(struct btrfs_work *work) ...@@ -2378,8 +2379,8 @@ static void btrfs_writepage_fixup_worker(struct btrfs_work *work)
out_reserved: out_reserved:
btrfs_delalloc_release_extents(BTRFS_I(inode), PAGE_SIZE); btrfs_delalloc_release_extents(BTRFS_I(inode), PAGE_SIZE);
if (free_delalloc_space) if (free_delalloc_space)
btrfs_delalloc_release_space(inode, data_reserved, page_start, btrfs_delalloc_release_space(BTRFS_I(inode), data_reserved,
PAGE_SIZE, true); page_start, PAGE_SIZE, true);
unlock_extent_cached(&BTRFS_I(inode)->io_tree, page_start, page_end, unlock_extent_cached(&BTRFS_I(inode)->io_tree, page_start, page_end,
&cached_state); &cached_state);
out_page: out_page:
...@@ -4539,7 +4540,7 @@ int btrfs_truncate_block(struct inode *inode, loff_t from, loff_t len, ...@@ -4539,7 +4540,7 @@ int btrfs_truncate_block(struct inode *inode, loff_t from, loff_t len,
again: again:
page = find_or_create_page(mapping, index, mask); page = find_or_create_page(mapping, index, mask);
if (!page) { if (!page) {
btrfs_delalloc_release_space(inode, data_reserved, btrfs_delalloc_release_space(BTRFS_I(inode), data_reserved,
block_start, blocksize, true); block_start, blocksize, true);
btrfs_delalloc_release_extents(BTRFS_I(inode), blocksize); btrfs_delalloc_release_extents(BTRFS_I(inode), blocksize);
ret = -ENOMEM; ret = -ENOMEM;
...@@ -4615,7 +4616,7 @@ int btrfs_truncate_block(struct inode *inode, loff_t from, loff_t len, ...@@ -4615,7 +4616,7 @@ int btrfs_truncate_block(struct inode *inode, loff_t from, loff_t len,
btrfs_delalloc_release_metadata(BTRFS_I(inode), btrfs_delalloc_release_metadata(BTRFS_I(inode),
blocksize, true); blocksize, true);
else else
btrfs_delalloc_release_space(inode, data_reserved, btrfs_delalloc_release_space(BTRFS_I(inode), data_reserved,
block_start, blocksize, true); block_start, blocksize, true);
} }
btrfs_delalloc_release_extents(BTRFS_I(inode), blocksize); btrfs_delalloc_release_extents(BTRFS_I(inode), blocksize);
...@@ -7947,8 +7948,9 @@ static ssize_t btrfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter) ...@@ -7947,8 +7948,9 @@ static ssize_t btrfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
current->journal_info = NULL; current->journal_info = NULL;
if (ret < 0 && ret != -EIOCBQUEUED) { if (ret < 0 && ret != -EIOCBQUEUED) {
if (dio_data.reserve) if (dio_data.reserve)
btrfs_delalloc_release_space(inode, data_reserved, btrfs_delalloc_release_space(BTRFS_I(inode),
offset, dio_data.reserve, true); data_reserved, offset, dio_data.reserve,
true);
/* /*
* On error we might have left some ordered extents * On error we might have left some ordered extents
* without submitting corresponding bios for them, so * without submitting corresponding bios for them, so
...@@ -7963,7 +7965,7 @@ static ssize_t btrfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter) ...@@ -7963,7 +7965,7 @@ static ssize_t btrfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
dio_data.unsubmitted_oe_range_start, dio_data.unsubmitted_oe_range_start,
false); false);
} else if (ret >= 0 && (size_t)ret < count) } else if (ret >= 0 && (size_t)ret < count)
btrfs_delalloc_release_space(inode, data_reserved, btrfs_delalloc_release_space(BTRFS_I(inode), data_reserved,
offset, count - (size_t)ret, true); offset, count - (size_t)ret, true);
btrfs_delalloc_release_extents(BTRFS_I(inode), count); btrfs_delalloc_release_extents(BTRFS_I(inode), count);
} }
...@@ -8277,9 +8279,9 @@ vm_fault_t btrfs_page_mkwrite(struct vm_fault *vmf) ...@@ -8277,9 +8279,9 @@ vm_fault_t btrfs_page_mkwrite(struct vm_fault *vmf)
fs_info->sectorsize); fs_info->sectorsize);
if (reserved_space < PAGE_SIZE) { if (reserved_space < PAGE_SIZE) {
end = page_start + reserved_space - 1; end = page_start + reserved_space - 1;
btrfs_delalloc_release_space(inode, data_reserved, btrfs_delalloc_release_space(BTRFS_I(inode),
page_start, PAGE_SIZE - reserved_space, data_reserved, page_start,
true); PAGE_SIZE - reserved_space, true);
} }
} }
...@@ -8334,7 +8336,7 @@ vm_fault_t btrfs_page_mkwrite(struct vm_fault *vmf) ...@@ -8334,7 +8336,7 @@ vm_fault_t btrfs_page_mkwrite(struct vm_fault *vmf)
unlock_page(page); unlock_page(page);
out: out:
btrfs_delalloc_release_extents(BTRFS_I(inode), PAGE_SIZE); btrfs_delalloc_release_extents(BTRFS_I(inode), PAGE_SIZE);
btrfs_delalloc_release_space(inode, data_reserved, page_start, btrfs_delalloc_release_space(BTRFS_I(inode), data_reserved, page_start,
reserved_space, (ret != 0)); reserved_space, (ret != 0));
out_noreserve: out_noreserve:
sb_end_pagefault(inode->i_sb); sb_end_pagefault(inode->i_sb);
......
...@@ -1333,7 +1333,7 @@ static int cluster_pages_for_defrag(struct inode *inode, ...@@ -1333,7 +1333,7 @@ static int cluster_pages_for_defrag(struct inode *inode,
spin_lock(&BTRFS_I(inode)->lock); spin_lock(&BTRFS_I(inode)->lock);
btrfs_mod_outstanding_extents(BTRFS_I(inode), 1); btrfs_mod_outstanding_extents(BTRFS_I(inode), 1);
spin_unlock(&BTRFS_I(inode)->lock); spin_unlock(&BTRFS_I(inode)->lock);
btrfs_delalloc_release_space(inode, data_reserved, btrfs_delalloc_release_space(BTRFS_I(inode), data_reserved,
start_index << PAGE_SHIFT, start_index << PAGE_SHIFT,
(page_cnt - i_done) << PAGE_SHIFT, true); (page_cnt - i_done) << PAGE_SHIFT, true);
} }
...@@ -1361,7 +1361,7 @@ static int cluster_pages_for_defrag(struct inode *inode, ...@@ -1361,7 +1361,7 @@ static int cluster_pages_for_defrag(struct inode *inode,
unlock_page(pages[i]); unlock_page(pages[i]);
put_page(pages[i]); put_page(pages[i]);
} }
btrfs_delalloc_release_space(inode, data_reserved, btrfs_delalloc_release_space(BTRFS_I(inode), data_reserved,
start_index << PAGE_SHIFT, start_index << PAGE_SHIFT,
page_cnt << PAGE_SHIFT, true); page_cnt << PAGE_SHIFT, true);
btrfs_delalloc_release_extents(BTRFS_I(inode), page_cnt << PAGE_SHIFT); btrfs_delalloc_release_extents(BTRFS_I(inode), page_cnt << PAGE_SHIFT);
......
...@@ -134,8 +134,8 @@ static int copy_inline_to_page(struct inode *inode, ...@@ -134,8 +134,8 @@ static int copy_inline_to_page(struct inode *inode,
put_page(page); put_page(page);
} }
if (ret) if (ret)
btrfs_delalloc_release_space(inode, data_reserved, file_offset, btrfs_delalloc_release_space(BTRFS_I(inode), data_reserved,
block_size, true); file_offset, block_size, true);
btrfs_delalloc_release_extents(BTRFS_I(inode), block_size); btrfs_delalloc_release_extents(BTRFS_I(inode), block_size);
out: out:
extent_changeset_free(data_reserved); extent_changeset_free(data_reserved);
......
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