summaryrefslogtreecommitdiff
path: root/include/linux/list.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-11-12 20:53:57 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2023-11-12 20:57:28 -0500
commit7fd6c3ffe45b3b42c0bc8a8c5d1387a5e3316a54 (patch)
treed596299da8c34dff74cb13caf9dd47d9154c25b4 /include/linux/list.h
parenta613340b26ad88801666362d2824118396f34c38 (diff)
Update bcachefs sources to 3ca08ab51ec9 bcachefs: six locks: Simplify optimistic spinning
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'include/linux/list.h')
-rw-r--r--include/linux/list.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/linux/list.h b/include/linux/list.h
index bdd09efa..d176d0d3 100644
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -98,4 +98,15 @@ static inline void hlist_del_init(struct hlist_node *n)
pos; \
pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
+static inline size_t list_count_nodes(struct list_head *head)
+{
+ struct list_head *pos;
+ size_t count = 0;
+
+ list_for_each(pos, head)
+ count++;
+
+ return count;
+}
+
#endif /* _LIST_LIST_H */