hbl.h 959 Bytes
Newer Older
J. R. Okajima's avatar
J. R. Okajima committed
1
2
/* SPDX-License-Identifier: GPL-2.0 */
/*
3
 * Copyright (C) 2017-2020 Junjiro R. Okajima
J. R. Okajima's avatar
J. R. Okajima committed
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
 */

/*
 * helpers for hlist_bl.h
 */

#ifndef __AUFS_HBL_H__
#define __AUFS_HBL_H__

#ifdef __KERNEL__

#include <linux/list_bl.h>

static inline void au_hbl_add(struct hlist_bl_node *node,
			      struct hlist_bl_head *hbl)
{
	hlist_bl_lock(hbl);
	hlist_bl_add_head(node, hbl);
	hlist_bl_unlock(hbl);
}

static inline void au_hbl_del(struct hlist_bl_node *node,
			      struct hlist_bl_head *hbl)
{
	hlist_bl_lock(hbl);
	hlist_bl_del(node);
	hlist_bl_unlock(hbl);
}

#define au_hbl_for_each(pos, head)					\
	for (pos = hlist_bl_first(head);				\
	     pos;							\
	     pos = pos->next)

static inline unsigned long au_hbl_count(struct hlist_bl_head *hbl)
{
	unsigned long cnt;
	struct hlist_bl_node *pos;

	cnt = 0;
	hlist_bl_lock(hbl);
	au_hbl_for_each(pos, hbl)
		cnt++;
	hlist_bl_unlock(hbl);
	return cnt;
}

#endif /* __KERNEL__ */
#endif /* __AUFS_HBL_H__ */