mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-11-01 09:13:37 +00:00
btrfs: defrag: use list_last_entry() at defrag_collect_targets()
Instead of using list_entry() against the list's prev entry, use list_last_entry(), which removes the need to know the last member is accessed through the prev list pointer and the naming makes it easier to reason about what we are doing. Reviewed-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
58fe389a2a
commit
5bc3b7e2b5
1 changed files with 4 additions and 4 deletions
|
|
@ -1068,8 +1068,8 @@ static int defrag_collect_targets(struct btrfs_inode *inode,
|
|||
/* Empty target list, no way to merge with last entry */
|
||||
if (list_empty(target_list))
|
||||
goto next;
|
||||
last = list_entry(target_list->prev,
|
||||
struct defrag_target_range, list);
|
||||
last = list_last_entry(target_list,
|
||||
struct defrag_target_range, list);
|
||||
/* Not mergeable with last entry */
|
||||
if (last->start + last->len != cur)
|
||||
goto next;
|
||||
|
|
@ -1087,8 +1087,8 @@ add:
|
|||
if (!list_empty(target_list)) {
|
||||
struct defrag_target_range *last;
|
||||
|
||||
last = list_entry(target_list->prev,
|
||||
struct defrag_target_range, list);
|
||||
last = list_last_entry(target_list,
|
||||
struct defrag_target_range, list);
|
||||
ASSERT(last->start + last->len <= cur);
|
||||
if (last->start + last->len == cur) {
|
||||
/* Mergeable, enlarge the last entry */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue