diff options
author | 2025-05-02 11:23:02 +0100 | |
---|---|---|
committer | 2025-05-15 14:30:55 +0200 | |
commit | 5bc3b7e2b5f840a4131093b66fd3c1ab604ba9a9 (patch) | |
tree | aa25af0fc00be83c6d31d600c00f34d06b78c75f | |
parent | btrfs: simplify csum list release at btrfs_put_ordered_extent() (diff) | |
download | wireguard-linux-5bc3b7e2b5f840a4131093b66fd3c1ab604ba9a9.tar.xz wireguard-linux-5bc3b7e2b5f840a4131093b66fd3c1ab604ba9a9.zip |
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>
-rw-r--r-- | fs/btrfs/defrag.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/btrfs/defrag.c b/fs/btrfs/defrag.c index 48e12c8a90a7..1831618579cb 100644 --- a/fs/btrfs/defrag.c +++ b/fs/btrfs/defrag.c @@ -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 */ |