]> git.baikalelectronics.ru Git - kernel.git/commit
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)
commitd57a2ed51d3e74f1734206b0d3743eb236d273be
tree10569ba060c0aa9d672fbbdb1f0be27f47e266e4
parent5e6bc47c4f063743aacafc1e01a16d4f8cbabe4c
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