diff options
| author | Filipe Manana <[email protected]> | 2025-05-01 12:05:10 +0000 |
|---|---|---|
| committer | David Sterba <[email protected]> | 2025-05-15 12:30:55 +0000 |
| commit | 32bc875cbc159dc18ac588b64717a70b444e4656 (patch) | |
| tree | 8374a28104cd9eb976b469b6a4eae5556ec9c5a6 /fs/btrfs/delayed-inode.c | |
| parent | btrfs: raid56: use list_last_entry() at cache_rbio() (diff) | |
| download | kernel-32bc875cbc159dc18ac588b64717a70b444e4656.tar.gz kernel-32bc875cbc159dc18ac588b64717a70b444e4656.zip | |
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 <[email protected]>
Reviewed-by: Johannes Thumshirn <[email protected]>
Signed-off-by: Filipe Manana <[email protected]>
Reviewed-by: David Sterba <[email protected]>
Signed-off-by: David Sterba <[email protected]>
Diffstat (limited to 'fs/btrfs/delayed-inode.c')
| -rw-r--r-- | fs/btrfs/delayed-inode.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c index 206d39e5ce57..a1ac35bc789a 100644 --- a/fs/btrfs/delayed-inode.c +++ b/fs/btrfs/delayed-inode.c @@ -216,17 +216,13 @@ static void btrfs_dequeue_delayed_node(struct btrfs_delayed_root *root, static struct btrfs_delayed_node *btrfs_first_delayed_node( struct btrfs_delayed_root *delayed_root) { - struct list_head *p; - struct btrfs_delayed_node *node = NULL; + struct btrfs_delayed_node *node; spin_lock(&delayed_root->lock); - if (list_empty(&delayed_root->node_list)) - goto out; - - p = delayed_root->node_list.next; - node = list_entry(p, struct btrfs_delayed_node, n_list); - refcount_inc(&node->refs); -out: + node = list_first_entry_or_null(&delayed_root->node_list, + struct btrfs_delayed_node, n_list); + if (node) + refcount_inc(&node->refs); spin_unlock(&delayed_root->lock); return node; |
