]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blob - fs/aufs/hbl.h
6db65b16b08a23047cda057985cd129992be36d3
[mirror_ubuntu-focal-kernel.git] / fs / aufs / hbl.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Copyright (C) 2017-2019 Junjiro R. Okajima
4 *
5 * This program, aufs is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 /*
20 * helpers for hlist_bl.h
21 */
22
23 #ifndef __AUFS_HBL_H__
24 #define __AUFS_HBL_H__
25
26 #ifdef __KERNEL__
27
28 #include <linux/list_bl.h>
29
30 static inline void au_hbl_add(struct hlist_bl_node *node,
31 struct hlist_bl_head *hbl)
32 {
33 hlist_bl_lock(hbl);
34 hlist_bl_add_head(node, hbl);
35 hlist_bl_unlock(hbl);
36 }
37
38 static inline void au_hbl_del(struct hlist_bl_node *node,
39 struct hlist_bl_head *hbl)
40 {
41 hlist_bl_lock(hbl);
42 hlist_bl_del(node);
43 hlist_bl_unlock(hbl);
44 }
45
46 #define au_hbl_for_each(pos, head) \
47 for (pos = hlist_bl_first(head); \
48 pos; \
49 pos = pos->next)
50
51 static inline unsigned long au_hbl_count(struct hlist_bl_head *hbl)
52 {
53 unsigned long cnt;
54 struct hlist_bl_node *pos;
55
56 cnt = 0;
57 hlist_bl_lock(hbl);
58 au_hbl_for_each(pos, hbl)
59 cnt++;
60 hlist_bl_unlock(hbl);
61 return cnt;
62 }
63
64 #endif /* __KERNEL__ */
65 #endif /* __AUFS_HBL_H__ */