mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 01:04:41 +01:00
btrfs: merge setting ret and return ret
In many places we have pattern: ret = ...; return ret; This can be simplified to a direct return, removing 'ret' if not otherwise needed. The places in self tests are not converted so we can add more test cases without changing surrounding code (extent-map-tests.c:test_case_4()). Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
d7a5d511c0
commit
4b117be65f
13 changed files with 32 additions and 63 deletions
|
|
@ -1057,8 +1057,7 @@ static int remove_block_group_item(struct btrfs_trans_handle *trans,
|
|||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = btrfs_del_item(trans, root, path);
|
||||
return ret;
|
||||
return btrfs_del_item(trans, root, path);
|
||||
}
|
||||
|
||||
int btrfs_remove_block_group(struct btrfs_trans_handle *trans,
|
||||
|
|
|
|||
|
|
@ -4002,8 +4002,7 @@ int btrfs_split_item(struct btrfs_trans_handle *trans,
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = split_item(trans, path, new_key, split_offset);
|
||||
return ret;
|
||||
return split_item(trans, path, new_key, split_offset);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -1137,8 +1137,8 @@ __btrfs_commit_inode_delayed_items(struct btrfs_trans_handle *trans,
|
|||
ret = btrfs_record_root_in_trans(trans, node->root);
|
||||
if (ret)
|
||||
return ret;
|
||||
ret = btrfs_update_delayed_inode(trans, node->root, path, node);
|
||||
return ret;
|
||||
|
||||
return btrfs_update_delayed_inode(trans, node->root, path, node);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -175,7 +175,6 @@ static int btrfs_repair_eb_io_failure(const struct extent_buffer *eb,
|
|||
const u32 step = min(fs_info->nodesize, PAGE_SIZE);
|
||||
const u32 nr_steps = eb->len / step;
|
||||
phys_addr_t paddrs[BTRFS_MAX_BLOCKSIZE / PAGE_SIZE];
|
||||
int ret = 0;
|
||||
|
||||
if (sb_rdonly(fs_info->sb))
|
||||
return -EROFS;
|
||||
|
|
@ -197,9 +196,8 @@ static int btrfs_repair_eb_io_failure(const struct extent_buffer *eb,
|
|||
paddrs[i] = page_to_phys(&folio->page) + offset_in_page(eb->start);
|
||||
}
|
||||
|
||||
ret = btrfs_repair_io_failure(fs_info, 0, eb->start, eb->len, eb->start,
|
||||
paddrs, step, mirror_num);
|
||||
return ret;
|
||||
return btrfs_repair_io_failure(fs_info, 0, eb->start, eb->len,
|
||||
eb->start, paddrs, step, mirror_num);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -2145,11 +2143,10 @@ static int load_global_roots(struct btrfs_root *tree_root)
|
|||
return ret;
|
||||
if (!btrfs_fs_compat_ro(tree_root->fs_info, FREE_SPACE_TREE))
|
||||
return ret;
|
||||
ret = load_global_roots_objectid(tree_root, path,
|
||||
BTRFS_FREE_SPACE_TREE_OBJECTID,
|
||||
"free space");
|
||||
|
||||
return ret;
|
||||
return load_global_roots_objectid(tree_root, path,
|
||||
BTRFS_FREE_SPACE_TREE_OBJECTID,
|
||||
"free space");
|
||||
}
|
||||
|
||||
static int btrfs_read_roots(struct btrfs_fs_info *fs_info)
|
||||
|
|
|
|||
|
|
@ -187,8 +187,6 @@ static int add_extent_changeset(struct extent_state *state, u32 bits,
|
|||
struct extent_changeset *changeset,
|
||||
int set)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (!changeset)
|
||||
return 0;
|
||||
if (set && (state->state & bits) == bits)
|
||||
|
|
@ -196,9 +194,8 @@ static int add_extent_changeset(struct extent_state *state, u32 bits,
|
|||
if (!set && (state->state & bits) == 0)
|
||||
return 0;
|
||||
changeset->bytes_changed += state->end - state->start + 1;
|
||||
ret = ulist_add(&changeset->range_changed, state->start, state->end,
|
||||
GFP_ATOMIC);
|
||||
return ret;
|
||||
|
||||
return ulist_add(&changeset->range_changed, state->start, state->end, GFP_ATOMIC);
|
||||
}
|
||||
|
||||
static inline struct extent_state *next_state(struct extent_state *state)
|
||||
|
|
|
|||
|
|
@ -2559,7 +2559,6 @@ static u64 get_alloc_profile_by_root(struct btrfs_root *root, int data)
|
|||
{
|
||||
struct btrfs_fs_info *fs_info = root->fs_info;
|
||||
u64 flags;
|
||||
u64 ret;
|
||||
|
||||
if (data)
|
||||
flags = BTRFS_BLOCK_GROUP_DATA;
|
||||
|
|
@ -2568,8 +2567,7 @@ static u64 get_alloc_profile_by_root(struct btrfs_root *root, int data)
|
|||
else
|
||||
flags = BTRFS_BLOCK_GROUP_METADATA;
|
||||
|
||||
ret = btrfs_get_alloc_profile(fs_info, flags);
|
||||
return ret;
|
||||
return btrfs_get_alloc_profile(fs_info, flags);
|
||||
}
|
||||
|
||||
static u64 first_logical_byte(struct btrfs_fs_info *fs_info)
|
||||
|
|
@ -4191,10 +4189,8 @@ static int find_free_extent_update_loop(struct btrfs_fs_info *fs_info,
|
|||
else
|
||||
trans = btrfs_join_transaction(root);
|
||||
|
||||
if (IS_ERR(trans)) {
|
||||
ret = PTR_ERR(trans);
|
||||
return ret;
|
||||
}
|
||||
if (IS_ERR(trans))
|
||||
return PTR_ERR(trans);
|
||||
|
||||
ret = btrfs_chunk_alloc(trans, space_info, ffe_ctl->flags,
|
||||
CHUNK_ALLOC_FORCE_FOR_EXTENT);
|
||||
|
|
|
|||
|
|
@ -1272,8 +1272,7 @@ again:
|
|||
btrfs_delalloc_release_extents(inode, reserved_len);
|
||||
release_space(inode, *data_reserved, reserved_start, reserved_len,
|
||||
only_release_metadata);
|
||||
ret = extents_locked;
|
||||
return ret;
|
||||
return extents_locked;
|
||||
}
|
||||
|
||||
copied = copy_folio_from_iter_atomic(folio, offset_in_folio(folio, start),
|
||||
|
|
|
|||
|
|
@ -1525,9 +1525,7 @@ int btrfs_remove_block_group_free_space(struct btrfs_trans_handle *trans,
|
|||
btrfs_release_path(path);
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int load_free_space_bitmaps(struct btrfs_caching_control *caching_ctl,
|
||||
|
|
|
|||
|
|
@ -371,14 +371,13 @@ int btrfs_insert_empty_inode(struct btrfs_trans_handle *trans,
|
|||
struct btrfs_path *path, u64 objectid)
|
||||
{
|
||||
struct btrfs_key key;
|
||||
int ret;
|
||||
|
||||
key.objectid = objectid;
|
||||
key.type = BTRFS_INODE_ITEM_KEY;
|
||||
key.offset = 0;
|
||||
|
||||
ret = btrfs_insert_empty_item(trans, root, path, &key,
|
||||
sizeof(struct btrfs_inode_item));
|
||||
return ret;
|
||||
return btrfs_insert_empty_item(trans, root, path, &key,
|
||||
sizeof(struct btrfs_inode_item));
|
||||
}
|
||||
|
||||
int btrfs_lookup_inode(struct btrfs_trans_handle *trans, struct btrfs_root
|
||||
|
|
|
|||
|
|
@ -2372,7 +2372,6 @@ int btrfs_run_delalloc_range(struct btrfs_inode *inode, struct folio *locked_fol
|
|||
u64 start, u64 end, struct writeback_control *wbc)
|
||||
{
|
||||
const bool zoned = btrfs_is_zoned(inode->root->fs_info);
|
||||
int ret;
|
||||
|
||||
/*
|
||||
* The range must cover part of the @locked_folio, or a return of 1
|
||||
|
|
@ -2381,10 +2380,8 @@ int btrfs_run_delalloc_range(struct btrfs_inode *inode, struct folio *locked_fol
|
|||
ASSERT(!(end <= folio_pos(locked_folio) ||
|
||||
start >= folio_next_pos(locked_folio)));
|
||||
|
||||
if (should_nocow(inode, start, end)) {
|
||||
ret = run_delalloc_nocow(inode, locked_folio, start, end);
|
||||
return ret;
|
||||
}
|
||||
if (should_nocow(inode, start, end))
|
||||
return run_delalloc_nocow(inode, locked_folio, start, end);
|
||||
|
||||
if (btrfs_inode_can_compress(inode) &&
|
||||
inode_need_compress(inode, start, end) &&
|
||||
|
|
@ -2392,11 +2389,9 @@ int btrfs_run_delalloc_range(struct btrfs_inode *inode, struct folio *locked_fol
|
|||
return 1;
|
||||
|
||||
if (zoned)
|
||||
ret = run_delalloc_cow(inode, locked_folio, start, end, wbc,
|
||||
true);
|
||||
return run_delalloc_cow(inode, locked_folio, start, end, wbc, true);
|
||||
else
|
||||
ret = cow_file_range(inode, locked_folio, start, end, NULL, 0);
|
||||
return ret;
|
||||
return cow_file_range(inode, locked_folio, start, end, NULL, 0);
|
||||
}
|
||||
|
||||
void btrfs_split_delalloc_extent(struct btrfs_inode *inode,
|
||||
|
|
|
|||
|
|
@ -694,7 +694,6 @@ void btrfs_free_qgroup_config(struct btrfs_fs_info *fs_info)
|
|||
static int add_qgroup_relation_item(struct btrfs_trans_handle *trans, u64 src,
|
||||
u64 dst)
|
||||
{
|
||||
int ret;
|
||||
struct btrfs_root *quota_root = trans->fs_info->quota_root;
|
||||
BTRFS_PATH_AUTO_FREE(path);
|
||||
struct btrfs_key key;
|
||||
|
|
@ -707,8 +706,7 @@ static int add_qgroup_relation_item(struct btrfs_trans_handle *trans, u64 src,
|
|||
key.type = BTRFS_QGROUP_RELATION_KEY;
|
||||
key.offset = dst;
|
||||
|
||||
ret = btrfs_insert_empty_item(trans, quota_root, path, &key, 0);
|
||||
return ret;
|
||||
return btrfs_insert_empty_item(trans, quota_root, path, &key, 0);
|
||||
}
|
||||
|
||||
static int del_qgroup_relation_item(struct btrfs_trans_handle *trans, u64 src,
|
||||
|
|
@ -833,9 +831,7 @@ static int del_qgroup_item(struct btrfs_trans_handle *trans, u64 qgroupid)
|
|||
if (ret > 0)
|
||||
return -ENOENT;
|
||||
|
||||
ret = btrfs_del_item(trans, quota_root, path);
|
||||
|
||||
return ret;
|
||||
return btrfs_del_item(trans, quota_root, path);
|
||||
}
|
||||
|
||||
static int update_qgroup_limit_item(struct btrfs_trans_handle *trans,
|
||||
|
|
@ -2655,10 +2651,8 @@ int btrfs_qgroup_trace_subtree(struct btrfs_trans_handle *trans,
|
|||
return ret;
|
||||
}
|
||||
|
||||
if (root_level == 0) {
|
||||
ret = btrfs_qgroup_trace_leaf_items(trans, root_eb);
|
||||
return ret;
|
||||
}
|
||||
if (root_level == 0)
|
||||
return btrfs_qgroup_trace_leaf_items(trans, root_eb);
|
||||
|
||||
path = btrfs_alloc_path();
|
||||
if (!path)
|
||||
|
|
|
|||
|
|
@ -3254,7 +3254,6 @@ static int delete_v1_space_cache(struct extent_buffer *leaf,
|
|||
struct btrfs_key key;
|
||||
bool found = false;
|
||||
int i;
|
||||
int ret;
|
||||
|
||||
if (btrfs_header_owner(leaf) != BTRFS_ROOT_TREE_OBJECTID)
|
||||
return 0;
|
||||
|
|
@ -3278,8 +3277,8 @@ static int delete_v1_space_cache(struct extent_buffer *leaf,
|
|||
}
|
||||
if (!found)
|
||||
return -ENOENT;
|
||||
ret = delete_block_group_cache(block_group, NULL, space_cache_ino);
|
||||
return ret;
|
||||
|
||||
return delete_block_group_cache(block_group, NULL, space_cache_ino);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -2316,9 +2316,7 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info,
|
|||
free_fs_devices(cur_devices);
|
||||
}
|
||||
|
||||
ret = btrfs_commit_transaction(trans);
|
||||
|
||||
return ret;
|
||||
return btrfs_commit_transaction(trans);
|
||||
|
||||
error_undo:
|
||||
if (test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state)) {
|
||||
|
|
@ -7167,7 +7165,6 @@ static int read_one_dev(struct extent_buffer *leaf,
|
|||
struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
|
||||
struct btrfs_device *device;
|
||||
u64 devid;
|
||||
int ret;
|
||||
u8 fs_uuid[BTRFS_FSID_SIZE];
|
||||
u8 dev_uuid[BTRFS_UUID_SIZE];
|
||||
|
||||
|
|
@ -7267,8 +7264,8 @@ static int read_one_dev(struct extent_buffer *leaf,
|
|||
atomic64_add(device->total_bytes - device->bytes_used,
|
||||
&fs_info->free_chunk_space);
|
||||
}
|
||||
ret = 0;
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int btrfs_read_sys_array(struct btrfs_fs_info *fs_info)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue