Skip to content

Commit 58fe389

Browse files
fdmananakdave
authored andcommitted
btrfs: simplify csum list release at btrfs_put_ordered_extent()
Instead of extracting each element by grabbing the list's first member in a local list_head variable, then extracting the csum with list_entry() and iterating with a while loop checking for list emptyness, use the iteration helper list_for_each_entry_safe(). This also removes the need to delete elements from the list with list_del() since the ordered extent is freed immediately after. 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>
1 parent 4cde072 commit 58fe389

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

fs/btrfs/ordered-data.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -607,23 +607,19 @@ bool btrfs_dec_test_ordered_pending(struct btrfs_inode *inode,
607607
*/
608608
void btrfs_put_ordered_extent(struct btrfs_ordered_extent *entry)
609609
{
610-
struct list_head *cur;
611-
struct btrfs_ordered_sum *sum;
612-
613610
trace_btrfs_ordered_extent_put(entry->inode, entry);
614611

615612
if (refcount_dec_and_test(&entry->refs)) {
613+
struct btrfs_ordered_sum *sum;
614+
struct btrfs_ordered_sum *tmp;
615+
616616
ASSERT(list_empty(&entry->root_extent_list));
617617
ASSERT(list_empty(&entry->log_list));
618618
ASSERT(RB_EMPTY_NODE(&entry->rb_node));
619619
if (entry->inode)
620620
btrfs_add_delayed_iput(entry->inode);
621-
while (!list_empty(&entry->list)) {
622-
cur = entry->list.next;
623-
sum = list_entry(cur, struct btrfs_ordered_sum, list);
624-
list_del(&sum->list);
621+
list_for_each_entry_safe(sum, tmp, &entry->list, list)
625622
kvfree(sum);
626-
}
627623
kmem_cache_free(btrfs_ordered_extent_cache, entry);
628624
}
629625
}

0 commit comments

Comments
 (0)