Commit f7ad68bf authored by NeilBrown's avatar NeilBrown Committed by David S. Miller

rhashtable: rename rht_for_each*continue as *from.

The pattern set by list.h is that for_each..continue()
iterators start at the next entry after the given one,
while for_each..from() iterators start at the given
entry.

The rht_for_each*continue() iterators are documented as though the
start at the 'next' entry, but actually start at the given entry,
and they are used expecting that behaviour.
So fix the documentation and change the names to *from for consistency
with list.h
Acked-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Acked-by: default avatarMiguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Signed-off-by: default avatarNeilBrown <neilb@suse.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4feb7c7a
...@@ -366,14 +366,14 @@ ForEachMacros: ...@@ -366,14 +366,14 @@ ForEachMacros:
- 'rhl_for_each_entry_rcu' - 'rhl_for_each_entry_rcu'
- 'rhl_for_each_rcu' - 'rhl_for_each_rcu'
- 'rht_for_each' - 'rht_for_each'
- 'rht_for_each_continue' - 'rht_for_each_from'
- 'rht_for_each_entry' - 'rht_for_each_entry'
- 'rht_for_each_entry_continue' - 'rht_for_each_entry_from'
- 'rht_for_each_entry_rcu' - 'rht_for_each_entry_rcu'
- 'rht_for_each_entry_rcu_continue' - 'rht_for_each_entry_rcu_from'
- 'rht_for_each_entry_safe' - 'rht_for_each_entry_safe'
- 'rht_for_each_rcu' - 'rht_for_each_rcu'
- 'rht_for_each_rcu_continue' - 'rht_for_each_rcu_from'
- '__rq_for_each_bio' - '__rq_for_each_bio'
- 'rq_for_each_segment' - 'rq_for_each_segment'
- 'scsi_for_each_prot_sg' - 'scsi_for_each_prot_sg'
......
...@@ -306,13 +306,13 @@ static inline struct rhash_head __rcu **rht_bucket_insert( ...@@ -306,13 +306,13 @@ static inline struct rhash_head __rcu **rht_bucket_insert(
} }
/** /**
* rht_for_each_continue - continue iterating over hash chain * rht_for_each_from - iterate over hash chain from given head
* @pos: the &struct rhash_head to use as a loop cursor. * @pos: the &struct rhash_head to use as a loop cursor.
* @head: the previous &struct rhash_head to continue from * @head: the &struct rhash_head to start from
* @tbl: the &struct bucket_table * @tbl: the &struct bucket_table
* @hash: the hash value / bucket index * @hash: the hash value / bucket index
*/ */
#define rht_for_each_continue(pos, head, tbl, hash) \ #define rht_for_each_from(pos, head, tbl, hash) \
for (pos = rht_dereference_bucket(head, tbl, hash); \ for (pos = rht_dereference_bucket(head, tbl, hash); \
!rht_is_a_nulls(pos); \ !rht_is_a_nulls(pos); \
pos = rht_dereference_bucket((pos)->next, tbl, hash)) pos = rht_dereference_bucket((pos)->next, tbl, hash))
...@@ -324,18 +324,18 @@ static inline struct rhash_head __rcu **rht_bucket_insert( ...@@ -324,18 +324,18 @@ static inline struct rhash_head __rcu **rht_bucket_insert(
* @hash: the hash value / bucket index * @hash: the hash value / bucket index
*/ */
#define rht_for_each(pos, tbl, hash) \ #define rht_for_each(pos, tbl, hash) \
rht_for_each_continue(pos, *rht_bucket(tbl, hash), tbl, hash) rht_for_each_from(pos, *rht_bucket(tbl, hash), tbl, hash)
/** /**
* rht_for_each_entry_continue - continue iterating over hash chain * rht_for_each_entry_from - iterate over hash chain from given head
* @tpos: the type * to use as a loop cursor. * @tpos: the type * to use as a loop cursor.
* @pos: the &struct rhash_head to use as a loop cursor. * @pos: the &struct rhash_head to use as a loop cursor.
* @head: the previous &struct rhash_head to continue from * @head: the &struct rhash_head to start from
* @tbl: the &struct bucket_table * @tbl: the &struct bucket_table
* @hash: the hash value / bucket index * @hash: the hash value / bucket index
* @member: name of the &struct rhash_head within the hashable struct. * @member: name of the &struct rhash_head within the hashable struct.
*/ */
#define rht_for_each_entry_continue(tpos, pos, head, tbl, hash, member) \ #define rht_for_each_entry_from(tpos, pos, head, tbl, hash, member) \
for (pos = rht_dereference_bucket(head, tbl, hash); \ for (pos = rht_dereference_bucket(head, tbl, hash); \
(!rht_is_a_nulls(pos)) && rht_entry(tpos, pos, member); \ (!rht_is_a_nulls(pos)) && rht_entry(tpos, pos, member); \
pos = rht_dereference_bucket((pos)->next, tbl, hash)) pos = rht_dereference_bucket((pos)->next, tbl, hash))
...@@ -349,7 +349,7 @@ static inline struct rhash_head __rcu **rht_bucket_insert( ...@@ -349,7 +349,7 @@ static inline struct rhash_head __rcu **rht_bucket_insert(
* @member: name of the &struct rhash_head within the hashable struct. * @member: name of the &struct rhash_head within the hashable struct.
*/ */
#define rht_for_each_entry(tpos, pos, tbl, hash, member) \ #define rht_for_each_entry(tpos, pos, tbl, hash, member) \
rht_for_each_entry_continue(tpos, pos, *rht_bucket(tbl, hash), \ rht_for_each_entry_from(tpos, pos, *rht_bucket(tbl, hash), \
tbl, hash, member) tbl, hash, member)
/** /**
...@@ -374,9 +374,9 @@ static inline struct rhash_head __rcu **rht_bucket_insert( ...@@ -374,9 +374,9 @@ static inline struct rhash_head __rcu **rht_bucket_insert(
rht_dereference_bucket(pos->next, tbl, hash) : NULL) rht_dereference_bucket(pos->next, tbl, hash) : NULL)
/** /**
* rht_for_each_rcu_continue - continue iterating over rcu hash chain * rht_for_each_rcu_from - iterate over rcu hash chain from given head
* @pos: the &struct rhash_head to use as a loop cursor. * @pos: the &struct rhash_head to use as a loop cursor.
* @head: the previous &struct rhash_head to continue from * @head: the &struct rhash_head to start from
* @tbl: the &struct bucket_table * @tbl: the &struct bucket_table
* @hash: the hash value / bucket index * @hash: the hash value / bucket index
* *
...@@ -384,7 +384,7 @@ static inline struct rhash_head __rcu **rht_bucket_insert( ...@@ -384,7 +384,7 @@ static inline struct rhash_head __rcu **rht_bucket_insert(
* the _rcu mutation primitives such as rhashtable_insert() as long as the * the _rcu mutation primitives such as rhashtable_insert() as long as the
* traversal is guarded by rcu_read_lock(). * traversal is guarded by rcu_read_lock().
*/ */
#define rht_for_each_rcu_continue(pos, head, tbl, hash) \ #define rht_for_each_rcu_from(pos, head, tbl, hash) \
for (({barrier(); }), \ for (({barrier(); }), \
pos = rht_dereference_bucket_rcu(head, tbl, hash); \ pos = rht_dereference_bucket_rcu(head, tbl, hash); \
!rht_is_a_nulls(pos); \ !rht_is_a_nulls(pos); \
...@@ -401,13 +401,13 @@ static inline struct rhash_head __rcu **rht_bucket_insert( ...@@ -401,13 +401,13 @@ static inline struct rhash_head __rcu **rht_bucket_insert(
* traversal is guarded by rcu_read_lock(). * traversal is guarded by rcu_read_lock().
*/ */
#define rht_for_each_rcu(pos, tbl, hash) \ #define rht_for_each_rcu(pos, tbl, hash) \
rht_for_each_rcu_continue(pos, *rht_bucket(tbl, hash), tbl, hash) rht_for_each_rcu_from(pos, *rht_bucket(tbl, hash), tbl, hash)
/** /**
* rht_for_each_entry_rcu_continue - continue iterating over rcu hash chain * rht_for_each_entry_rcu_from - iterated over rcu hash chain from given head
* @tpos: the type * to use as a loop cursor. * @tpos: the type * to use as a loop cursor.
* @pos: the &struct rhash_head to use as a loop cursor. * @pos: the &struct rhash_head to use as a loop cursor.
* @head: the previous &struct rhash_head to continue from * @head: the &struct rhash_head to start from
* @tbl: the &struct bucket_table * @tbl: the &struct bucket_table
* @hash: the hash value / bucket index * @hash: the hash value / bucket index
* @member: name of the &struct rhash_head within the hashable struct. * @member: name of the &struct rhash_head within the hashable struct.
...@@ -416,7 +416,7 @@ static inline struct rhash_head __rcu **rht_bucket_insert( ...@@ -416,7 +416,7 @@ static inline struct rhash_head __rcu **rht_bucket_insert(
* the _rcu mutation primitives such as rhashtable_insert() as long as the * the _rcu mutation primitives such as rhashtable_insert() as long as the
* traversal is guarded by rcu_read_lock(). * traversal is guarded by rcu_read_lock().
*/ */
#define rht_for_each_entry_rcu_continue(tpos, pos, head, tbl, hash, member) \ #define rht_for_each_entry_rcu_from(tpos, pos, head, tbl, hash, member) \
for (({barrier(); }), \ for (({barrier(); }), \
pos = rht_dereference_bucket_rcu(head, tbl, hash); \ pos = rht_dereference_bucket_rcu(head, tbl, hash); \
(!rht_is_a_nulls(pos)) && rht_entry(tpos, pos, member); \ (!rht_is_a_nulls(pos)) && rht_entry(tpos, pos, member); \
...@@ -435,7 +435,7 @@ static inline struct rhash_head __rcu **rht_bucket_insert( ...@@ -435,7 +435,7 @@ static inline struct rhash_head __rcu **rht_bucket_insert(
* traversal is guarded by rcu_read_lock(). * traversal is guarded by rcu_read_lock().
*/ */
#define rht_for_each_entry_rcu(tpos, pos, tbl, hash, member) \ #define rht_for_each_entry_rcu(tpos, pos, tbl, hash, member) \
rht_for_each_entry_rcu_continue(tpos, pos, *rht_bucket(tbl, hash), \ rht_for_each_entry_rcu_from(tpos, pos, *rht_bucket(tbl, hash), \
tbl, hash, member) tbl, hash, member)
/** /**
...@@ -491,7 +491,7 @@ static inline struct rhash_head *__rhashtable_lookup( ...@@ -491,7 +491,7 @@ static inline struct rhash_head *__rhashtable_lookup(
hash = rht_key_hashfn(ht, tbl, key, params); hash = rht_key_hashfn(ht, tbl, key, params);
head = rht_bucket(tbl, hash); head = rht_bucket(tbl, hash);
do { do {
rht_for_each_rcu_continue(he, *head, tbl, hash) { rht_for_each_rcu_from(he, *head, tbl, hash) {
if (params.obj_cmpfn ? if (params.obj_cmpfn ?
params.obj_cmpfn(&arg, rht_obj(ht, he)) : params.obj_cmpfn(&arg, rht_obj(ht, he)) :
rhashtable_compare(&arg, rht_obj(ht, he))) rhashtable_compare(&arg, rht_obj(ht, he)))
...@@ -625,7 +625,7 @@ static inline void *__rhashtable_insert_fast( ...@@ -625,7 +625,7 @@ static inline void *__rhashtable_insert_fast(
if (!pprev) if (!pprev)
goto out; goto out;
rht_for_each_continue(head, *pprev, tbl, hash) { rht_for_each_from(head, *pprev, tbl, hash) {
struct rhlist_head *plist; struct rhlist_head *plist;
struct rhlist_head *list; struct rhlist_head *list;
...@@ -890,7 +890,7 @@ static inline int __rhashtable_remove_fast_one( ...@@ -890,7 +890,7 @@ static inline int __rhashtable_remove_fast_one(
spin_lock_bh(lock); spin_lock_bh(lock);
pprev = rht_bucket_var(tbl, hash); pprev = rht_bucket_var(tbl, hash);
rht_for_each_continue(he, *pprev, tbl, hash) { rht_for_each_from(he, *pprev, tbl, hash) {
struct rhlist_head *list; struct rhlist_head *list;
list = container_of(he, struct rhlist_head, rhead); list = container_of(he, struct rhlist_head, rhead);
...@@ -1042,7 +1042,7 @@ static inline int __rhashtable_replace_fast( ...@@ -1042,7 +1042,7 @@ static inline int __rhashtable_replace_fast(
spin_lock_bh(lock); spin_lock_bh(lock);
pprev = rht_bucket_var(tbl, hash); pprev = rht_bucket_var(tbl, hash);
rht_for_each_continue(he, *pprev, tbl, hash) { rht_for_each_from(he, *pprev, tbl, hash) {
if (he != obj_old) { if (he != obj_old) {
pprev = &he->next; pprev = &he->next;
continue; continue;
......
...@@ -490,7 +490,7 @@ static void *rhashtable_lookup_one(struct rhashtable *ht, ...@@ -490,7 +490,7 @@ static void *rhashtable_lookup_one(struct rhashtable *ht,
elasticity = RHT_ELASTICITY; elasticity = RHT_ELASTICITY;
pprev = rht_bucket_var(tbl, hash); pprev = rht_bucket_var(tbl, hash);
rht_for_each_continue(head, *pprev, tbl, hash) { rht_for_each_from(head, *pprev, tbl, hash) {
struct rhlist_head *list; struct rhlist_head *list;
struct rhlist_head *plist; struct rhlist_head *plist;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment