Commit 691fa059 authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba

btrfs: all btrfs_delalloc_release_metadata take btrfs_inode

Signed-off-by: default avatarNikolay Borisov <nborisov@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 9f3db423
...@@ -2704,7 +2704,7 @@ int btrfs_subvolume_reserve_metadata(struct btrfs_root *root, ...@@ -2704,7 +2704,7 @@ int btrfs_subvolume_reserve_metadata(struct btrfs_root *root,
void btrfs_subvolume_release_metadata(struct btrfs_fs_info *fs_info, void btrfs_subvolume_release_metadata(struct btrfs_fs_info *fs_info,
struct btrfs_block_rsv *rsv); struct btrfs_block_rsv *rsv);
int btrfs_delalloc_reserve_metadata(struct btrfs_inode *inode, u64 num_bytes); int btrfs_delalloc_reserve_metadata(struct btrfs_inode *inode, u64 num_bytes);
void btrfs_delalloc_release_metadata(struct inode *inode, u64 num_bytes); void btrfs_delalloc_release_metadata(struct btrfs_inode *inode, u64 num_bytes);
int btrfs_delalloc_reserve_space(struct inode *inode, u64 start, u64 len); int btrfs_delalloc_reserve_space(struct inode *inode, u64 start, u64 len);
void btrfs_delalloc_release_space(struct inode *inode, u64 start, u64 len); void btrfs_delalloc_release_space(struct inode *inode, u64 start, u64 len);
void btrfs_init_block_rsv(struct btrfs_block_rsv *rsv, unsigned short type); void btrfs_init_block_rsv(struct btrfs_block_rsv *rsv, unsigned short type);
......
...@@ -6081,27 +6081,27 @@ int btrfs_delalloc_reserve_metadata(struct btrfs_inode *inode, u64 num_bytes) ...@@ -6081,27 +6081,27 @@ int btrfs_delalloc_reserve_metadata(struct btrfs_inode *inode, u64 num_bytes)
* once we complete IO for a given set of bytes to release their metadata * once we complete IO for a given set of bytes to release their metadata
* reservations. * reservations.
*/ */
void btrfs_delalloc_release_metadata(struct inode *inode, u64 num_bytes) void btrfs_delalloc_release_metadata(struct btrfs_inode *inode, u64 num_bytes)
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb);
u64 to_free = 0; u64 to_free = 0;
unsigned dropped; unsigned dropped;
num_bytes = ALIGN(num_bytes, fs_info->sectorsize); num_bytes = ALIGN(num_bytes, fs_info->sectorsize);
spin_lock(&BTRFS_I(inode)->lock); spin_lock(&inode->lock);
dropped = drop_outstanding_extent(BTRFS_I(inode), num_bytes); dropped = drop_outstanding_extent(inode, num_bytes);
if (num_bytes) if (num_bytes)
to_free = calc_csum_metadata_size(BTRFS_I(inode), num_bytes, 0); to_free = calc_csum_metadata_size(inode, num_bytes, 0);
spin_unlock(&BTRFS_I(inode)->lock); spin_unlock(&inode->lock);
if (dropped > 0) if (dropped > 0)
to_free += btrfs_calc_trans_metadata_size(fs_info, dropped); to_free += btrfs_calc_trans_metadata_size(fs_info, dropped);
if (btrfs_is_testing(fs_info)) if (btrfs_is_testing(fs_info))
return; return;
trace_btrfs_space_reservation(fs_info, "delalloc", trace_btrfs_space_reservation(fs_info, "delalloc", btrfs_ino(inode),
btrfs_ino(BTRFS_I(inode)), to_free, 0); to_free, 0);
btrfs_block_rsv_release(fs_info, &fs_info->delalloc_block_rsv, to_free); btrfs_block_rsv_release(fs_info, &fs_info->delalloc_block_rsv, to_free);
} }
...@@ -6159,7 +6159,7 @@ int btrfs_delalloc_reserve_space(struct inode *inode, u64 start, u64 len) ...@@ -6159,7 +6159,7 @@ int btrfs_delalloc_reserve_space(struct inode *inode, u64 start, u64 len)
*/ */
void btrfs_delalloc_release_space(struct inode *inode, u64 start, u64 len) void btrfs_delalloc_release_space(struct inode *inode, u64 start, u64 len)
{ {
btrfs_delalloc_release_metadata(inode, len); btrfs_delalloc_release_metadata(BTRFS_I(inode), len);
btrfs_free_reserved_data_space(inode, start, len); btrfs_free_reserved_data_space(inode, start, len);
} }
......
...@@ -1678,7 +1678,7 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file, ...@@ -1678,7 +1678,7 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file,
spin_unlock(&BTRFS_I(inode)->lock); spin_unlock(&BTRFS_I(inode)->lock);
} }
if (only_release_metadata) { if (only_release_metadata) {
btrfs_delalloc_release_metadata(inode, btrfs_delalloc_release_metadata(BTRFS_I(inode),
release_bytes); release_bytes);
} else { } else {
u64 __pos; u64 __pos;
...@@ -1739,7 +1739,8 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file, ...@@ -1739,7 +1739,8 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file,
if (release_bytes) { if (release_bytes) {
if (only_release_metadata) { if (only_release_metadata) {
btrfs_end_write_no_snapshoting(root); btrfs_end_write_no_snapshoting(root);
btrfs_delalloc_release_metadata(inode, release_bytes); btrfs_delalloc_release_metadata(BTRFS_I(inode),
release_bytes);
} else { } else {
btrfs_delalloc_release_space(inode, btrfs_delalloc_release_space(inode,
round_down(pos, fs_info->sectorsize), round_down(pos, fs_info->sectorsize),
......
...@@ -3545,7 +3545,8 @@ int btrfs_write_out_ino_cache(struct btrfs_root *root, ...@@ -3545,7 +3545,8 @@ int btrfs_write_out_ino_cache(struct btrfs_root *root,
if (ret) { if (ret) {
if (release_metadata) if (release_metadata)
btrfs_delalloc_release_metadata(inode, inode->i_size); btrfs_delalloc_release_metadata(BTRFS_I(inode),
inode->i_size);
#ifdef DEBUG #ifdef DEBUG
btrfs_err(fs_info, btrfs_err(fs_info,
"failed to write free ino cache for root %llu", "failed to write free ino cache for root %llu",
......
...@@ -499,7 +499,7 @@ int btrfs_save_ino_cache(struct btrfs_root *root, ...@@ -499,7 +499,7 @@ int btrfs_save_ino_cache(struct btrfs_root *root,
ret = btrfs_prealloc_file_range_trans(inode, trans, 0, 0, prealloc, ret = btrfs_prealloc_file_range_trans(inode, trans, 0, 0, prealloc,
prealloc, prealloc, &alloc_hint); prealloc, prealloc, &alloc_hint);
if (ret) { if (ret) {
btrfs_delalloc_release_metadata(inode, prealloc); btrfs_delalloc_release_metadata(BTRFS_I(inode), prealloc);
goto out_put; goto out_put;
} }
......
...@@ -316,7 +316,7 @@ static noinline int cow_file_range_inline(struct btrfs_root *root, ...@@ -316,7 +316,7 @@ static noinline int cow_file_range_inline(struct btrfs_root *root,
} }
set_bit(BTRFS_INODE_NEEDS_FULL_SYNC, &BTRFS_I(inode)->runtime_flags); set_bit(BTRFS_INODE_NEEDS_FULL_SYNC, &BTRFS_I(inode)->runtime_flags);
btrfs_delalloc_release_metadata(inode, end + 1 - start); btrfs_delalloc_release_metadata(BTRFS_I(inode), end + 1 - start);
btrfs_drop_extent_cache(inode, start, aligned_end - 1, 0); btrfs_drop_extent_cache(inode, start, aligned_end - 1, 0);
out: out:
/* /*
...@@ -1737,7 +1737,7 @@ static void btrfs_clear_bit_hook(struct inode *inode, ...@@ -1737,7 +1737,7 @@ static void btrfs_clear_bit_hook(struct inode *inode,
*/ */
if (*bits & EXTENT_DO_ACCOUNTING && if (*bits & EXTENT_DO_ACCOUNTING &&
root != fs_info->tree_root) root != fs_info->tree_root)
btrfs_delalloc_release_metadata(inode, len); btrfs_delalloc_release_metadata(BTRFS_I(inode), len);
/* For sanity tests. */ /* For sanity tests. */
if (btrfs_is_testing(fs_info)) if (btrfs_is_testing(fs_info))
...@@ -2914,7 +2914,8 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent) ...@@ -2914,7 +2914,8 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
ordered_extent->len - 1, &cached_state, GFP_NOFS); ordered_extent->len - 1, &cached_state, GFP_NOFS);
out: out:
if (root != fs_info->tree_root) if (root != fs_info->tree_root)
btrfs_delalloc_release_metadata(inode, ordered_extent->len); btrfs_delalloc_release_metadata(BTRFS_I(inode),
ordered_extent->len);
if (trans) if (trans)
btrfs_end_transaction(trans); btrfs_end_transaction(trans);
......
...@@ -3216,7 +3216,7 @@ static int relocate_file_extent_cluster(struct inode *inode, ...@@ -3216,7 +3216,7 @@ static int relocate_file_extent_cluster(struct inode *inode,
page = find_or_create_page(inode->i_mapping, index, page = find_or_create_page(inode->i_mapping, index,
mask); mask);
if (!page) { if (!page) {
btrfs_delalloc_release_metadata(inode, btrfs_delalloc_release_metadata(BTRFS_I(inode),
PAGE_SIZE); PAGE_SIZE);
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
...@@ -3235,7 +3235,7 @@ static int relocate_file_extent_cluster(struct inode *inode, ...@@ -3235,7 +3235,7 @@ static int relocate_file_extent_cluster(struct inode *inode,
if (!PageUptodate(page)) { if (!PageUptodate(page)) {
unlock_page(page); unlock_page(page);
put_page(page); put_page(page);
btrfs_delalloc_release_metadata(inode, btrfs_delalloc_release_metadata(BTRFS_I(inode),
PAGE_SIZE); PAGE_SIZE);
ret = -EIO; ret = -EIO;
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