Use dentry_path() to create full path to inode object
[pohmelfs.git] / include / linux / rculist_nulls.h
blob2ae13714828bc42568e77684fedfc2cf929c291d
1 #ifndef _LINUX_RCULIST_NULLS_H
2 #define _LINUX_RCULIST_NULLS_H
4 #ifdef __KERNEL__
6 /*
7 * RCU-protected list version
8 */
9 #include <linux/list_nulls.h>
10 #include <linux/rcupdate.h>
12 /**
13 * hlist_nulls_del_init_rcu - deletes entry from hash list with re-initialization
14 * @n: the element to delete from the hash list.
16 * Note: hlist_nulls_unhashed() on the node return true after this. It is
17 * useful for RCU based read lockfree traversal if the writer side
18 * must know if the list entry is still hashed or already unhashed.
20 * In particular, it means that we can not poison the forward pointers
21 * that may still be used for walking the hash list and we can only
22 * zero the pprev pointer so list_unhashed() will return true after
23 * this.
25 * The caller must take whatever precautions are necessary (such as
26 * holding appropriate locks) to avoid racing with another
27 * list-mutation primitive, such as hlist_nulls_add_head_rcu() or
28 * hlist_nulls_del_rcu(), running on this same list. However, it is
29 * perfectly legal to run concurrently with the _rcu list-traversal
30 * primitives, such as hlist_nulls_for_each_entry_rcu().
32 static inline void hlist_nulls_del_init_rcu(struct hlist_nulls_node *n)
34 if (!hlist_nulls_unhashed(n)) {
35 __hlist_nulls_del(n);
36 n->pprev = NULL;
40 #define hlist_nulls_first_rcu(head) \
41 (*((struct hlist_nulls_node __rcu __force **)&(head)->first))
43 #define hlist_nulls_next_rcu(node) \
44 (*((struct hlist_nulls_node __rcu __force **)&(node)->next))
46 /**
47 * hlist_nulls_del_rcu - deletes entry from hash list without re-initialization
48 * @n: the element to delete from the hash list.
50 * Note: hlist_nulls_unhashed() on entry does not return true after this,
51 * the entry is in an undefined state. It is useful for RCU based
52 * lockfree traversal.
54 * In particular, it means that we can not poison the forward
55 * pointers that may still be used for walking the hash list.
57 * The caller must take whatever precautions are necessary
58 * (such as holding appropriate locks) to avoid racing
59 * with another list-mutation primitive, such as hlist_nulls_add_head_rcu()
60 * or hlist_nulls_del_rcu(), running on this same list.
61 * However, it is perfectly legal to run concurrently with
62 * the _rcu list-traversal primitives, such as
63 * hlist_nulls_for_each_entry().
65 static inline void hlist_nulls_del_rcu(struct hlist_nulls_node *n)
67 __hlist_nulls_del(n);
68 n->pprev = LIST_POISON2;
71 /**
72 * hlist_nulls_add_head_rcu
73 * @n: the element to add to the hash list.
74 * @h: the list to add to.
76 * Description:
77 * Adds the specified element to the specified hlist_nulls,
78 * while permitting racing traversals.
80 * The caller must take whatever precautions are necessary
81 * (such as holding appropriate locks) to avoid racing
82 * with another list-mutation primitive, such as hlist_nulls_add_head_rcu()
83 * or hlist_nulls_del_rcu(), running on this same list.
84 * However, it is perfectly legal to run concurrently with
85 * the _rcu list-traversal primitives, such as
86 * hlist_nulls_for_each_entry_rcu(), used to prevent memory-consistency
87 * problems on Alpha CPUs. Regardless of the type of CPU, the
88 * list-traversal primitive must be guarded by rcu_read_lock().
90 static inline void hlist_nulls_add_head_rcu(struct hlist_nulls_node *n,
91 struct hlist_nulls_head *h)
93 struct hlist_nulls_node *first = h->first;
95 n->next = first;
96 n->pprev = &h->first;
97 rcu_assign_pointer(hlist_nulls_first_rcu(h), n);
98 if (!is_a_nulls(first))
99 first->pprev = &n->next;
102 * hlist_nulls_for_each_entry_rcu - iterate over rcu list of given type
103 * @tpos: the type * to use as a loop cursor.
104 * @pos: the &struct hlist_nulls_node to use as a loop cursor.
105 * @head: the head for your list.
106 * @member: the name of the hlist_nulls_node within the struct.
109 #define hlist_nulls_for_each_entry_rcu(tpos, pos, head, member) \
110 for (pos = rcu_dereference_raw(hlist_nulls_first_rcu(head)); \
111 (!is_a_nulls(pos)) && \
112 ({ tpos = hlist_nulls_entry(pos, typeof(*tpos), member); 1; }); \
113 pos = rcu_dereference_raw(hlist_nulls_next_rcu(pos)))
115 #endif
116 #endif