diff options
Diffstat (limited to 'include/linux/rhashtable.h')
| -rw-r--r-- | include/linux/rhashtable.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/include/linux/rhashtable.h b/include/linux/rhashtable.h index e0337844358e..58851275fed9 100644 --- a/include/linux/rhashtable.h +++ b/include/linux/rhashtable.h | |||
| @@ -18,6 +18,7 @@ | |||
| 18 | #ifndef _LINUX_RHASHTABLE_H | 18 | #ifndef _LINUX_RHASHTABLE_H |
| 19 | #define _LINUX_RHASHTABLE_H | 19 | #define _LINUX_RHASHTABLE_H |
| 20 | 20 | ||
| 21 | #include <linux/compiler.h> | ||
| 21 | #include <linux/list_nulls.h> | 22 | #include <linux/list_nulls.h> |
| 22 | #include <linux/workqueue.h> | 23 | #include <linux/workqueue.h> |
| 23 | #include <linux/mutex.h> | 24 | #include <linux/mutex.h> |
| @@ -111,6 +112,7 @@ struct rhashtable_params { | |||
| 111 | * @p: Configuration parameters | 112 | * @p: Configuration parameters |
| 112 | * @run_work: Deferred worker to expand/shrink asynchronously | 113 | * @run_work: Deferred worker to expand/shrink asynchronously |
| 113 | * @mutex: Mutex to protect current/future table swapping | 114 | * @mutex: Mutex to protect current/future table swapping |
| 115 | * @walkers: List of active walkers | ||
| 114 | * @being_destroyed: True if table is set up for destruction | 116 | * @being_destroyed: True if table is set up for destruction |
| 115 | */ | 117 | */ |
| 116 | struct rhashtable { | 118 | struct rhashtable { |
| @@ -121,9 +123,36 @@ struct rhashtable { | |||
| 121 | struct rhashtable_params p; | 123 | struct rhashtable_params p; |
| 122 | struct work_struct run_work; | 124 | struct work_struct run_work; |
| 123 | struct mutex mutex; | 125 | struct mutex mutex; |
| 126 | struct list_head walkers; | ||
| 124 | bool being_destroyed; | 127 | bool being_destroyed; |
| 125 | }; | 128 | }; |
| 126 | 129 | ||
| 130 | /** | ||
| 131 | * struct rhashtable_walker - Hash table walker | ||
| 132 | * @list: List entry on list of walkers | ||
| 133 | * @resize: Resize event occured | ||
| 134 | */ | ||
| 135 | struct rhashtable_walker { | ||
| 136 | struct list_head list; | ||
| 137 | bool resize; | ||
| 138 | }; | ||
| 139 | |||
| 140 | /** | ||
| 141 | * struct rhashtable_iter - Hash table iterator, fits into netlink cb | ||
| 142 | * @ht: Table to iterate through | ||
| 143 | * @p: Current pointer | ||
| 144 | * @walker: Associated rhashtable walker | ||
| 145 | * @slot: Current slot | ||
| 146 | * @skip: Number of entries to skip in slot | ||
| 147 | */ | ||
| 148 | struct rhashtable_iter { | ||
| 149 | struct rhashtable *ht; | ||
| 150 | struct rhash_head *p; | ||
| 151 | struct rhashtable_walker *walker; | ||
| 152 | unsigned int slot; | ||
| 153 | unsigned int skip; | ||
| 154 | }; | ||
| 155 | |||
| 127 | static inline unsigned long rht_marker(const struct rhashtable *ht, u32 hash) | 156 | static inline unsigned long rht_marker(const struct rhashtable *ht, u32 hash) |
| 128 | { | 157 | { |
| 129 | return NULLS_MARKER(ht->p.nulls_base + hash); | 158 | return NULLS_MARKER(ht->p.nulls_base + hash); |
| @@ -179,6 +208,12 @@ bool rhashtable_lookup_compare_insert(struct rhashtable *ht, | |||
| 179 | bool (*compare)(void *, void *), | 208 | bool (*compare)(void *, void *), |
| 180 | void *arg); | 209 | void *arg); |
| 181 | 210 | ||
| 211 | int rhashtable_walk_init(struct rhashtable *ht, struct rhashtable_iter *iter); | ||
| 212 | void rhashtable_walk_exit(struct rhashtable_iter *iter); | ||
| 213 | int rhashtable_walk_start(struct rhashtable_iter *iter) __acquires(RCU); | ||
| 214 | void *rhashtable_walk_next(struct rhashtable_iter *iter); | ||
| 215 | void rhashtable_walk_stop(struct rhashtable_iter *iter) __releases(RCU); | ||
| 216 | |||
| 182 | void rhashtable_destroy(struct rhashtable *ht); | 217 | void rhashtable_destroy(struct rhashtable *ht); |
| 183 | 218 | ||
| 184 | #define rht_dereference(p, ht) \ | 219 | #define rht_dereference(p, ht) \ |
