Commit 4dae077a authored by Jeff Mahoney's avatar Jeff Mahoney Committed by David Sterba

btrfs: backref, add unode_aux_to_inode_list helper

Replacing the double cast and ternary conditional with a helper makes
the code easier on the eyes.
Signed-off-by: default avatarJeff Mahoney <jeffm@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 73980bec
...@@ -682,6 +682,14 @@ static int __resolve_indirect_ref(struct btrfs_fs_info *fs_info, ...@@ -682,6 +682,14 @@ static int __resolve_indirect_ref(struct btrfs_fs_info *fs_info,
return ret; return ret;
} }
static struct extent_inode_elem *
unode_aux_to_inode_list(struct ulist_node *node)
{
if (!node)
return NULL;
return (struct extent_inode_elem *)(uintptr_t)node->aux;
}
/* /*
* resolve all indirect backrefs from the list * resolve all indirect backrefs from the list
*/ */
...@@ -736,8 +744,7 @@ static int __resolve_indirect_refs(struct btrfs_fs_info *fs_info, ...@@ -736,8 +744,7 @@ static int __resolve_indirect_refs(struct btrfs_fs_info *fs_info,
ULIST_ITER_INIT(&uiter); ULIST_ITER_INIT(&uiter);
node = ulist_next(parents, &uiter); node = ulist_next(parents, &uiter);
ref->parent = node ? node->val : 0; ref->parent = node ? node->val : 0;
ref->inode_list = node ? ref->inode_list = unode_aux_to_inode_list(node);
(struct extent_inode_elem *)(uintptr_t)node->aux : NULL;
/* additional parents require new refs being added here */ /* additional parents require new refs being added here */
while ((node = ulist_next(parents, &uiter))) { while ((node = ulist_next(parents, &uiter))) {
...@@ -749,8 +756,7 @@ static int __resolve_indirect_refs(struct btrfs_fs_info *fs_info, ...@@ -749,8 +756,7 @@ static int __resolve_indirect_refs(struct btrfs_fs_info *fs_info,
} }
memcpy(new_ref, ref, sizeof(*ref)); memcpy(new_ref, ref, sizeof(*ref));
new_ref->parent = node->val; new_ref->parent = node->val;
new_ref->inode_list = (struct extent_inode_elem *) new_ref->inode_list = unode_aux_to_inode_list(node);
(uintptr_t)node->aux;
list_add(&new_ref->list, &ref->list); list_add(&new_ref->list, &ref->list);
} }
ulist_reinit(parents); ulist_reinit(parents);
...@@ -1476,7 +1482,7 @@ static void free_leaf_list(struct ulist *blocks) ...@@ -1476,7 +1482,7 @@ static void free_leaf_list(struct ulist *blocks)
while ((node = ulist_next(blocks, &uiter))) { while ((node = ulist_next(blocks, &uiter))) {
if (!node->aux) if (!node->aux)
continue; continue;
eie = (struct extent_inode_elem *)(uintptr_t)node->aux; eie = unode_aux_to_inode_list(node);
free_inode_elem_list(eie); free_inode_elem_list(eie);
node->aux = 0; node->aux = 0;
} }
......
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