summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/util.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2024-11-29 19:13:54 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2024-12-21 01:36:21 -0500
commit7807b5b07de1d009275e00b7fa51db31071d57a4 (patch)
tree919258fe1cf6d43a1bc4174b2615ccd3308028ee /fs/bcachefs/util.h
parentbcachefs: Convert write path errors to inum_to_path() (diff)
downloadlinux-7807b5b07de1d009275e00b7fa51db31071d57a4.tar.gz
linux-7807b5b07de1d009275e00b7fa51db31071d57a4.zip
bcachefs: list_pop_entry()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/util.h')
-rw-r--r--fs/bcachefs/util.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/fs/bcachefs/util.h b/fs/bcachefs/util.h
index fb02c1c36004..5e4820c8fa44 100644
--- a/fs/bcachefs/util.h
+++ b/fs/bcachefs/util.h
@@ -317,6 +317,19 @@ do { \
_ptr ? container_of(_ptr, type, member) : NULL; \
})
+static inline struct list_head *list_pop(struct list_head *head)
+{
+ if (list_empty(head))
+ return NULL;
+
+ struct list_head *ret = head->next;
+ list_del_init(ret);
+ return ret;
+}
+
+#define list_pop_entry(head, type, member) \
+ container_of_or_null(list_pop(head), type, member)
+
/* Does linear interpolation between powers of two */
static inline unsigned fract_exp_two(unsigned x, unsigned fract_bits)
{