Commit 906c448c authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba

btrfs: make __btrfs_drop_extents take btrfs_inode

It has only 4 uses of a vfs_inode for inode_sub_bytes but unifies the
interface with the non  __ prefixed version. Will also makes converting
its callers to btrfs_inode easier.
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 bd242a08
...@@ -3014,7 +3014,7 @@ void btrfs_drop_extent_cache(struct btrfs_inode *inode, u64 start, u64 end, ...@@ -3014,7 +3014,7 @@ void btrfs_drop_extent_cache(struct btrfs_inode *inode, u64 start, u64 end,
int skip_pinned); int skip_pinned);
extern const struct file_operations btrfs_file_operations; extern const struct file_operations btrfs_file_operations;
int __btrfs_drop_extents(struct btrfs_trans_handle *trans, int __btrfs_drop_extents(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct inode *inode, struct btrfs_root *root, struct btrfs_inode *inode,
struct btrfs_path *path, u64 start, u64 end, struct btrfs_path *path, u64 start, u64 end,
u64 *drop_end, int drop_cache, u64 *drop_end, int drop_cache,
int replace_extent, int replace_extent,
......
...@@ -731,7 +731,7 @@ void btrfs_drop_extent_cache(struct btrfs_inode *inode, u64 start, u64 end, ...@@ -731,7 +731,7 @@ void btrfs_drop_extent_cache(struct btrfs_inode *inode, u64 start, u64 end,
* is deleted from the tree. * is deleted from the tree.
*/ */
int __btrfs_drop_extents(struct btrfs_trans_handle *trans, int __btrfs_drop_extents(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct inode *inode, struct btrfs_root *root, struct btrfs_inode *inode,
struct btrfs_path *path, u64 start, u64 end, struct btrfs_path *path, u64 start, u64 end,
u64 *drop_end, int drop_cache, u64 *drop_end, int drop_cache,
int replace_extent, int replace_extent,
...@@ -744,7 +744,8 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans, ...@@ -744,7 +744,8 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans,
struct btrfs_ref ref = { 0 }; struct btrfs_ref ref = { 0 };
struct btrfs_key key; struct btrfs_key key;
struct btrfs_key new_key; struct btrfs_key new_key;
u64 ino = btrfs_ino(BTRFS_I(inode)); struct inode *vfs_inode = &inode->vfs_inode;
u64 ino = btrfs_ino(inode);
u64 search_start = start; u64 search_start = start;
u64 disk_bytenr = 0; u64 disk_bytenr = 0;
u64 num_bytes = 0; u64 num_bytes = 0;
...@@ -762,9 +763,9 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans, ...@@ -762,9 +763,9 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans,
int leafs_visited = 0; int leafs_visited = 0;
if (drop_cache) if (drop_cache)
btrfs_drop_extent_cache(BTRFS_I(inode), start, end - 1, 0); btrfs_drop_extent_cache(inode, start, end - 1, 0);
if (start >= BTRFS_I(inode)->disk_i_size && !replace_extent) if (start >= inode->disk_i_size && !replace_extent)
modify_tree = 0; modify_tree = 0;
update_refs = (test_bit(BTRFS_ROOT_SHAREABLE, &root->state) || update_refs = (test_bit(BTRFS_ROOT_SHAREABLE, &root->state) ||
...@@ -935,7 +936,7 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans, ...@@ -935,7 +936,7 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans,
extent_end - end); extent_end - end);
btrfs_mark_buffer_dirty(leaf); btrfs_mark_buffer_dirty(leaf);
if (update_refs && disk_bytenr > 0) if (update_refs && disk_bytenr > 0)
inode_sub_bytes(inode, end - key.offset); inode_sub_bytes(vfs_inode, end - key.offset);
break; break;
} }
...@@ -955,7 +956,7 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans, ...@@ -955,7 +956,7 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans,
start - key.offset); start - key.offset);
btrfs_mark_buffer_dirty(leaf); btrfs_mark_buffer_dirty(leaf);
if (update_refs && disk_bytenr > 0) if (update_refs && disk_bytenr > 0)
inode_sub_bytes(inode, extent_end - start); inode_sub_bytes(vfs_inode, extent_end - start);
if (end == extent_end) if (end == extent_end)
break; break;
...@@ -979,7 +980,7 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans, ...@@ -979,7 +980,7 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans,
if (update_refs && if (update_refs &&
extent_type == BTRFS_FILE_EXTENT_INLINE) { extent_type == BTRFS_FILE_EXTENT_INLINE) {
inode_sub_bytes(inode, inode_sub_bytes(vfs_inode,
extent_end - key.offset); extent_end - key.offset);
extent_end = ALIGN(extent_end, extent_end = ALIGN(extent_end,
fs_info->sectorsize); fs_info->sectorsize);
...@@ -993,7 +994,7 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans, ...@@ -993,7 +994,7 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans,
key.offset - extent_offset); key.offset - extent_offset);
ret = btrfs_free_extent(trans, &ref); ret = btrfs_free_extent(trans, &ref);
BUG_ON(ret); /* -ENOMEM */ BUG_ON(ret); /* -ENOMEM */
inode_sub_bytes(inode, inode_sub_bytes(vfs_inode,
extent_end - key.offset); extent_end - key.offset);
} }
...@@ -1082,8 +1083,8 @@ int btrfs_drop_extents(struct btrfs_trans_handle *trans, ...@@ -1082,8 +1083,8 @@ int btrfs_drop_extents(struct btrfs_trans_handle *trans,
path = btrfs_alloc_path(); path = btrfs_alloc_path();
if (!path) if (!path)
return -ENOMEM; return -ENOMEM;
ret = __btrfs_drop_extents(trans, root, inode, path, start, end, NULL, ret = __btrfs_drop_extents(trans, root, BTRFS_I(inode), path, start,
drop_cache, 0, 0, NULL); end, NULL, drop_cache, 0, 0, NULL);
btrfs_free_path(path); btrfs_free_path(path);
return ret; return ret;
} }
...@@ -2596,7 +2597,7 @@ int btrfs_punch_hole_range(struct inode *inode, struct btrfs_path *path, ...@@ -2596,7 +2597,7 @@ int btrfs_punch_hole_range(struct inode *inode, struct btrfs_path *path,
cur_offset = start; cur_offset = start;
while (cur_offset < end) { while (cur_offset < end) {
ret = __btrfs_drop_extents(trans, root, inode, path, ret = __btrfs_drop_extents(trans, root, BTRFS_I(inode), path,
cur_offset, end + 1, &drop_end, cur_offset, end + 1, &drop_end,
1, 0, 0, NULL); 1, 0, 0, NULL);
if (ret != -ENOSPC) { if (ret != -ENOSPC) {
......
...@@ -323,7 +323,7 @@ static noinline int cow_file_range_inline(struct inode *inode, u64 start, ...@@ -323,7 +323,7 @@ static noinline int cow_file_range_inline(struct inode *inode, u64 start,
extent_item_size = btrfs_file_extent_calc_inline_size( extent_item_size = btrfs_file_extent_calc_inline_size(
inline_len); inline_len);
ret = __btrfs_drop_extents(trans, root, inode, path, ret = __btrfs_drop_extents(trans, root, BTRFS_I(inode), path,
start, aligned_end, NULL, start, aligned_end, NULL,
1, 1, extent_item_size, &extent_inserted); 1, 1, extent_item_size, &extent_inserted);
if (ret) { if (ret) {
...@@ -2498,7 +2498,7 @@ static int insert_reserved_file_extent(struct btrfs_trans_handle *trans, ...@@ -2498,7 +2498,7 @@ static int insert_reserved_file_extent(struct btrfs_trans_handle *trans,
* the caller is expected to unpin it and allow it to be merged * the caller is expected to unpin it and allow it to be merged
* with the others. * with the others.
*/ */
ret = __btrfs_drop_extents(trans, root, inode, path, file_pos, ret = __btrfs_drop_extents(trans, root, BTRFS_I(inode), path, file_pos,
file_pos + num_bytes, NULL, 0, file_pos + num_bytes, NULL, 0,
1, sizeof(*stack_fi), &extent_inserted); 1, sizeof(*stack_fi), &extent_inserted);
if (ret) if (ret)
......
...@@ -4151,7 +4151,7 @@ static int log_one_extent(struct btrfs_trans_handle *trans, ...@@ -4151,7 +4151,7 @@ static int log_one_extent(struct btrfs_trans_handle *trans,
if (ret) if (ret)
return ret; return ret;
ret = __btrfs_drop_extents(trans, log, &inode->vfs_inode, path, em->start, ret = __btrfs_drop_extents(trans, log, inode, path, em->start,
em->start + em->len, NULL, 0, 1, em->start + em->len, NULL, 0, 1,
sizeof(*fi), &extent_inserted); sizeof(*fi), &extent_inserted);
if (ret) if (ret)
......
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