diff options
| author | David S. Miller <davem@davemloft.net> | 2015-03-15 01:35:46 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2015-03-15 01:35:46 -0400 |
| commit | 5a2f78dd51d9d71aa40cb752af88332f45c884b7 (patch) | |
| tree | 582bc65b98879f06bc3e9f28b9adefdc90314725 /include | |
| parent | 96026d057a1fb7da1e314a24e3a1c528321ed45e (diff) | |
| parent | c4db8848af6af92f90462258603be844baeab44d (diff) | |
Merge branch 'rhashtable-next'
Herbert Xu says:
====================
rhashtable: Fixes + cleanups + preparation for multiple rehash
Patch 1 fixes the walker so that it behaves properly even during
a resize.
Patch 2-3 are cleanups.
Patch 4-6 lays some ground work for the upcoming multiple rehashing.
This revision fixes the warning coming from the bucket_table->size
downsize and improves its changelog.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/rhashtable.h | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/include/linux/rhashtable.h b/include/linux/rhashtable.h index c93ff8ac474a..1695378b3c5b 100644 --- a/include/linux/rhashtable.h +++ b/include/linux/rhashtable.h | |||
| @@ -49,18 +49,27 @@ struct rhash_head { | |||
| 49 | /** | 49 | /** |
| 50 | * struct bucket_table - Table of hash buckets | 50 | * struct bucket_table - Table of hash buckets |
| 51 | * @size: Number of hash buckets | 51 | * @size: Number of hash buckets |
| 52 | * @rehash: Current bucket being rehashed | ||
| 52 | * @hash_rnd: Random seed to fold into hash | 53 | * @hash_rnd: Random seed to fold into hash |
| 53 | * @shift: Current size (1 << shift) | 54 | * @shift: Current size (1 << shift) |
| 54 | * @locks_mask: Mask to apply before accessing locks[] | 55 | * @locks_mask: Mask to apply before accessing locks[] |
| 55 | * @locks: Array of spinlocks protecting individual buckets | 56 | * @locks: Array of spinlocks protecting individual buckets |
| 57 | * @walkers: List of active walkers | ||
| 58 | * @rcu: RCU structure for freeing the table | ||
| 59 | * @future_tbl: Table under construction during rehashing | ||
| 56 | * @buckets: size * hash buckets | 60 | * @buckets: size * hash buckets |
| 57 | */ | 61 | */ |
| 58 | struct bucket_table { | 62 | struct bucket_table { |
| 59 | size_t size; | 63 | unsigned int size; |
| 64 | unsigned int rehash; | ||
| 60 | u32 hash_rnd; | 65 | u32 hash_rnd; |
| 61 | u32 shift; | 66 | u32 shift; |
| 62 | unsigned int locks_mask; | 67 | unsigned int locks_mask; |
| 63 | spinlock_t *locks; | 68 | spinlock_t *locks; |
| 69 | struct list_head walkers; | ||
| 70 | struct rcu_head rcu; | ||
| 71 | |||
| 72 | struct bucket_table __rcu *future_tbl; | ||
| 64 | 73 | ||
| 65 | struct rhash_head __rcu *buckets[] ____cacheline_aligned_in_smp; | 74 | struct rhash_head __rcu *buckets[] ____cacheline_aligned_in_smp; |
| 66 | }; | 75 | }; |
| @@ -99,33 +108,29 @@ struct rhashtable_params { | |||
| 99 | /** | 108 | /** |
| 100 | * struct rhashtable - Hash table handle | 109 | * struct rhashtable - Hash table handle |
| 101 | * @tbl: Bucket table | 110 | * @tbl: Bucket table |
| 102 | * @future_tbl: Table under construction during expansion/shrinking | ||
| 103 | * @nelems: Number of elements in table | 111 | * @nelems: Number of elements in table |
| 104 | * @p: Configuration parameters | 112 | * @p: Configuration parameters |
| 105 | * @run_work: Deferred worker to expand/shrink asynchronously | 113 | * @run_work: Deferred worker to expand/shrink asynchronously |
| 106 | * @mutex: Mutex to protect current/future table swapping | 114 | * @mutex: Mutex to protect current/future table swapping |
| 107 | * @walkers: List of active walkers | ||
| 108 | * @being_destroyed: True if table is set up for destruction | 115 | * @being_destroyed: True if table is set up for destruction |
| 109 | */ | 116 | */ |
| 110 | struct rhashtable { | 117 | struct rhashtable { |
| 111 | struct bucket_table __rcu *tbl; | 118 | struct bucket_table __rcu *tbl; |
| 112 | struct bucket_table __rcu *future_tbl; | ||
| 113 | atomic_t nelems; | 119 | atomic_t nelems; |
| 114 | bool being_destroyed; | 120 | bool being_destroyed; |
| 115 | struct rhashtable_params p; | 121 | struct rhashtable_params p; |
| 116 | struct work_struct run_work; | 122 | struct work_struct run_work; |
| 117 | struct mutex mutex; | 123 | struct mutex mutex; |
| 118 | struct list_head walkers; | ||
| 119 | }; | 124 | }; |
| 120 | 125 | ||
| 121 | /** | 126 | /** |
| 122 | * struct rhashtable_walker - Hash table walker | 127 | * struct rhashtable_walker - Hash table walker |
| 123 | * @list: List entry on list of walkers | 128 | * @list: List entry on list of walkers |
| 124 | * @resize: Resize event occured | 129 | * @tbl: The table that we were walking over |
| 125 | */ | 130 | */ |
| 126 | struct rhashtable_walker { | 131 | struct rhashtable_walker { |
| 127 | struct list_head list; | 132 | struct list_head list; |
| 128 | bool resize; | 133 | struct bucket_table *tbl; |
| 129 | }; | 134 | }; |
| 130 | 135 | ||
| 131 | /** | 136 | /** |
