Commit a7571232 authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba
Browse files

btrfs: use list_for_each_entry_safe in free_reloc_roots



The function always works on a local copy of the reloc root list, which
cannot be modified outside of it so using list_for_each_entry is fine.
Additionally the macro handles empty lists so drop list_empty checks of
callers. No semantic changes.

Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
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 7c09c030
Loading
Loading
Loading
Loading
+5 −11
Original line number Diff line number Diff line
@@ -1884,14 +1884,11 @@ again:
static noinline_for_stack
void free_reloc_roots(struct list_head *list)
{
	struct btrfs_root *reloc_root;
	struct btrfs_root *reloc_root, *tmp;

	while (!list_empty(list)) {
		reloc_root = list_entry(list->next, struct btrfs_root,
					root_list);
	list_for_each_entry_safe(reloc_root, tmp, list, root_list)
		__del_reloc_root(reloc_root);
}
}

static noinline_for_stack
void merge_reloc_roots(struct reloc_control *rc)
@@ -1949,14 +1946,12 @@ again:
out:
	if (ret) {
		btrfs_handle_fs_error(fs_info, ret, NULL);
		if (!list_empty(&reloc_roots))
		free_reloc_roots(&reloc_roots);

		/* new reloc root may be added */
		mutex_lock(&fs_info->reloc_mutex);
		list_splice_init(&rc->reloc_roots, &reloc_roots);
		mutex_unlock(&fs_info->reloc_mutex);
		if (!list_empty(&reloc_roots))
		free_reloc_roots(&reloc_roots);
	}

@@ -3869,7 +3864,6 @@ out_unset:
	unset_reloc_control(rc);
	free_reloc_control(rc);
out:
	if (!list_empty(&reloc_roots))
	free_reloc_roots(&reloc_roots);

	btrfs_free_path(path);