Skip to content

Commit 32bc875

Browse files
fdmananakdave
authored andcommitted
btrfs: simplify extracting delayed node at btrfs_first_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 c5d12d5 commit 32bc875

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

fs/btrfs/delayed-inode.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -216,17 +216,13 @@ static void btrfs_dequeue_delayed_node(struct btrfs_delayed_root *root,
216216
static struct btrfs_delayed_node *btrfs_first_delayed_node(
217217
struct btrfs_delayed_root *delayed_root)
218218
{
219-
struct list_head *p;
220-
struct btrfs_delayed_node *node = NULL;
219+
struct btrfs_delayed_node *node;
221220

222221
spin_lock(&delayed_root->lock);
223-
if (list_empty(&delayed_root->node_list))
224-
goto out;
225-
226-
p = delayed_root->node_list.next;
227-
node = list_entry(p, struct btrfs_delayed_node, n_list);
228-
refcount_inc(&node->refs);
229-
out:
222+
node = list_first_entry_or_null(&delayed_root->node_list,
223+
struct btrfs_delayed_node, n_list);
224+
if (node)
225+
refcount_inc(&node->refs);
230226
spin_unlock(&delayed_root->lock);
231227

232228
return node;

0 commit comments

Comments
 (0)