Skip to content

Commit 4cde072

Browse files
fdmananakdave
authored andcommitted
btrfs: simplify extracting delayed node at btrfs_first_prepared_delayed_node()
Instead of grabbing the next pointer from the list and then doing a list_entry() call, we can simply use list_first_entry(), removing the need for list_head variable. Also there's no need to check if the list is empty before attempting to extract the first element, we can use list_first_entry_or_null(), removing the need for a special if statement and the 'out' label. 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 32bc875 commit 4cde072

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

fs/btrfs/delayed-inode.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -294,18 +294,15 @@ static inline void btrfs_release_delayed_node(struct btrfs_delayed_node *node)
294294
static struct btrfs_delayed_node *btrfs_first_prepared_delayed_node(
295295
struct btrfs_delayed_root *delayed_root)
296296
{
297-
struct list_head *p;
298-
struct btrfs_delayed_node *node = NULL;
297+
struct btrfs_delayed_node *node;
299298

300299
spin_lock(&delayed_root->lock);
301-
if (list_empty(&delayed_root->prepare_list))
302-
goto out;
303-
304-
p = delayed_root->prepare_list.next;
305-
list_del_init(p);
306-
node = list_entry(p, struct btrfs_delayed_node, p_list);
307-
refcount_inc(&node->refs);
308-
out:
300+
node = list_first_entry_or_null(&delayed_root->prepare_list,
301+
struct btrfs_delayed_node, p_list);
302+
if (node) {
303+
list_del_init(&node->p_list);
304+
refcount_inc(&node->refs);
305+
}
309306
spin_unlock(&delayed_root->lock);
310307

311308
return node;

0 commit comments

Comments
 (0)