forked from Mirrors/btrfs-progs
btrfs-progs: Refactor btrfs_finish_extent_commit()
This patch will refactor btrfs_finish_extent_commit(): - Make it return void There is no failure pattern for btrfs_finish_extent_commit(), thus it always return 0. And the caller doesn't care about the return value. So no need to return int. - Remove @root and @unpin parameters @root is only used to extract fs_info, which can be extracted from transaction handler already. @unpin is always fs_info->pinned_extents. All these parameters can be extracted from @trans, no need to pass them. The function signature now matches the kernel counterpart. Reviewed-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>master
parent
27a5b9ddc3
commit
45e58a1acf
4
ctree.h
4
ctree.h
|
@ -2516,9 +2516,7 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans,
|
||||||
struct btrfs_root *root,
|
struct btrfs_root *root,
|
||||||
u64 bytenr, u64 num_bytes, u64 parent,
|
u64 bytenr, u64 num_bytes, u64 parent,
|
||||||
u64 root_objectid, u64 owner, u64 offset);
|
u64 root_objectid, u64 owner, u64 offset);
|
||||||
int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans,
|
void btrfs_finish_extent_commit(struct btrfs_trans_handle *trans);
|
||||||
struct btrfs_root *root,
|
|
||||||
struct extent_io_tree *unpin);
|
|
||||||
int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
|
int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
|
||||||
struct btrfs_root *root,
|
struct btrfs_root *root,
|
||||||
u64 bytenr, u64 num_bytes, u64 parent,
|
u64 bytenr, u64 num_bytes, u64 parent,
|
||||||
|
|
|
@ -1977,27 +1977,25 @@ next:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans,
|
void btrfs_finish_extent_commit(struct btrfs_trans_handle *trans)
|
||||||
struct btrfs_root *root,
|
|
||||||
struct extent_io_tree *unpin)
|
|
||||||
{
|
{
|
||||||
u64 start;
|
u64 start;
|
||||||
u64 end;
|
u64 end;
|
||||||
int ret;
|
int ret;
|
||||||
struct extent_io_tree *free_space_cache;
|
struct btrfs_fs_info *fs_info = trans->fs_info;
|
||||||
free_space_cache = &root->fs_info->free_space_cache;
|
struct extent_io_tree *free_space_cache = &fs_info->free_space_cache;
|
||||||
|
struct extent_io_tree *pinned_extents = &fs_info->pinned_extents;
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
ret = find_first_extent_bit(unpin, 0, &start, &end,
|
ret = find_first_extent_bit(pinned_extents, 0, &start, &end,
|
||||||
EXTENT_DIRTY);
|
EXTENT_DIRTY);
|
||||||
if (ret)
|
if (ret)
|
||||||
break;
|
break;
|
||||||
update_pinned_extents(trans->fs_info, start, end + 1 - start,
|
update_pinned_extents(trans->fs_info, start, end + 1 - start,
|
||||||
0);
|
0);
|
||||||
clear_extent_dirty(unpin, start, end);
|
clear_extent_dirty(pinned_extents, start, end);
|
||||||
set_extent_dirty(free_space_cache, start, end);
|
set_extent_dirty(free_space_cache, start, end);
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pin_down_bytes(struct btrfs_trans_handle *trans, u64 bytenr,
|
static int pin_down_bytes(struct btrfs_trans_handle *trans, u64 bytenr,
|
||||||
|
|
|
@ -198,8 +198,7 @@ commit_tree:
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto out;
|
goto out;
|
||||||
ret = write_ctree_super(trans);
|
ret = write_ctree_super(trans);
|
||||||
btrfs_finish_extent_commit(trans, fs_info->extent_root,
|
btrfs_finish_extent_commit(trans);
|
||||||
&fs_info->pinned_extents);
|
|
||||||
kfree(trans);
|
kfree(trans);
|
||||||
free_extent_buffer(root->commit_root);
|
free_extent_buffer(root->commit_root);
|
||||||
root->commit_root = NULL;
|
root->commit_root = NULL;
|
||||||
|
|
Loading…
Reference in New Issue