Commit c0dce8b6 authored by Filipe Manana's avatar Filipe Manana Committed by David Sterba

btrfs: remove use of a temporary list at btrfs_lookup_csums_list()

There's no need to use a temporary list to add the checksums, we can just
add them to input list and then on error delete and free any checksums
that were added. So simplify and remove the temporary list.
Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent afcb8062
...@@ -470,7 +470,6 @@ int btrfs_lookup_csums_list(struct btrfs_root *root, u64 start, u64 end, ...@@ -470,7 +470,6 @@ int btrfs_lookup_csums_list(struct btrfs_root *root, u64 start, u64 end,
struct extent_buffer *leaf; struct extent_buffer *leaf;
struct btrfs_ordered_sum *sums; struct btrfs_ordered_sum *sums;
struct btrfs_csum_item *item; struct btrfs_csum_item *item;
LIST_HEAD(tmplist);
int ret; int ret;
ASSERT(IS_ALIGNED(start, fs_info->sectorsize) && ASSERT(IS_ALIGNED(start, fs_info->sectorsize) &&
...@@ -572,18 +571,17 @@ int btrfs_lookup_csums_list(struct btrfs_root *root, u64 start, u64 end, ...@@ -572,18 +571,17 @@ int btrfs_lookup_csums_list(struct btrfs_root *root, u64 start, u64 end,
bytes_to_csum_size(fs_info, size)); bytes_to_csum_size(fs_info, size));
start += size; start += size;
list_add_tail(&sums->list, &tmplist); list_add_tail(&sums->list, list);
} }
path->slots[0]++; path->slots[0]++;
} }
ret = 0; ret = 0;
fail: fail:
while (ret < 0 && !list_empty(&tmplist)) { while (ret < 0 && !list_empty(list)) {
sums = list_entry(tmplist.next, struct btrfs_ordered_sum, list); sums = list_entry(list->next, struct btrfs_ordered_sum, list);
list_del(&sums->list); list_del(&sums->list);
kfree(sums); kfree(sums);
} }
list_splice_tail(&tmplist, list);
btrfs_free_path(path); btrfs_free_path(path);
return ret; return 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