OSDN Git Service

btrfs: reloc: use wrapper to replace open-coded edge linking
authorQu Wenruo <wqu@suse.com>
Mon, 24 Feb 2020 01:19:02 +0000 (09:19 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 25 May 2020 09:25:18 +0000 (11:25 +0200)
commit2a979612d594c16953ca512f2de7f0bb385ffb65
tree10569ba060c0aa9d672fbbdb1f0be27f47e266e4
parent4d81ea8bb4fc40903f4950b082955c709d785467
btrfs: reloc: use wrapper to replace open-coded edge linking

Since backref_edge is used to connect upper and lower backref nodes, and
needs to access both nodes, some code can look pretty nasty:

list_add_tail(&edge->list[LOWER], &cur->upper);

The above code will link @cur to the LOWER side of the edge, while both
"LOWER" and "upper" words show up.  This can sometimes be very confusing
for reader to grasp.

This patch introduces a new wrapper, link_backref_edge(), to handle the
linking behavior.  Which also has extra ASSERT() to ensure caller won't
pass wrong nodes.

Also, this updates the comment of related lists of backref_node and
backref_edge, to make it more clear that each list points to what.

Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/relocation.c