Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8f6fd83c authored by Bob Copeland's avatar Bob Copeland Committed by Johannes Berg
Browse files

rhashtable: accept GFP flags in rhashtable_walk_init



In certain cases, the 802.11 mesh pathtable code wants to
iterate over all of the entries in the forwarding table from
the receive path, which is inside an RCU read-side critical
section.  Enable walks inside atomic sections by allowing
GFP_ATOMIC allocations for the walker state.

Change all existing callsites to pass in GFP_KERNEL.

Acked-by: default avatarThomas Graf <tgraf@suug.ch>
Signed-off-by: default avatarBob Copeland <me@bobcopeland.com>
[also adjust gfs2/glock.c and rhashtable tests]
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 947c2a0e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1913,7 +1913,7 @@ static int gfs2_glocks_open(struct inode *inode, struct file *file)
		if (seq->buf)
			seq->size = GFS2_SEQ_GOODSIZE;
		gi->gl = NULL;
		ret = rhashtable_walk_init(&gl_hash_table, &gi->hti);
		ret = rhashtable_walk_init(&gl_hash_table, &gi->hti, GFP_KERNEL);
	}
	return ret;
}
@@ -1941,7 +1941,7 @@ static int gfs2_glstats_open(struct inode *inode, struct file *file)
		if (seq->buf)
			seq->size = GFS2_SEQ_GOODSIZE;
		gi->gl = NULL;
		ret = rhashtable_walk_init(&gl_hash_table, &gi->hti);
		ret = rhashtable_walk_init(&gl_hash_table, &gi->hti, GFP_KERNEL);
	}
	return ret;
}
+2 −1
Original line number Diff line number Diff line
@@ -346,7 +346,8 @@ struct bucket_table *rhashtable_insert_slow(struct rhashtable *ht,
					    struct bucket_table *old_tbl);
int rhashtable_insert_rehash(struct rhashtable *ht, struct bucket_table *tbl);

int rhashtable_walk_init(struct rhashtable *ht, struct rhashtable_iter *iter);
int rhashtable_walk_init(struct rhashtable *ht, struct rhashtable_iter *iter,
			 gfp_t gfp);
void rhashtable_walk_exit(struct rhashtable_iter *iter);
int rhashtable_walk_start(struct rhashtable_iter *iter) __acquires(RCU);
void *rhashtable_walk_next(struct rhashtable_iter *iter);
+4 −2
Original line number Diff line number Diff line
@@ -487,6 +487,7 @@ EXPORT_SYMBOL_GPL(rhashtable_insert_slow);
 * rhashtable_walk_init - Initialise an iterator
 * @ht:		Table to walk over
 * @iter:	Hash table Iterator
 * @gfp:	GFP flags for allocations
 *
 * This function prepares a hash table walk.
 *
@@ -504,14 +505,15 @@ EXPORT_SYMBOL_GPL(rhashtable_insert_slow);
 * You must call rhashtable_walk_exit if this function returns
 * successfully.
 */
int rhashtable_walk_init(struct rhashtable *ht, struct rhashtable_iter *iter)
int rhashtable_walk_init(struct rhashtable *ht, struct rhashtable_iter *iter,
			 gfp_t gfp)
{
	iter->ht = ht;
	iter->p = NULL;
	iter->slot = 0;
	iter->skip = 0;

	iter->walker = kmalloc(sizeof(*iter->walker), GFP_KERNEL);
	iter->walker = kmalloc(sizeof(*iter->walker), gfp);
	if (!iter->walker)
		return -ENOMEM;

+1 −1
Original line number Diff line number Diff line
@@ -143,7 +143,7 @@ static void test_bucket_stats(struct rhashtable *ht)
	struct rhashtable_iter hti;
	struct rhash_head *pos;

	err = rhashtable_walk_init(ht, &hti);
	err = rhashtable_walk_init(ht, &hti, GFP_KERNEL);
	if (err) {
		pr_warn("Test failed: allocation error");
		return;
+2 −1
Original line number Diff line number Diff line
@@ -501,7 +501,8 @@ static int ila_nl_dump_start(struct netlink_callback *cb)
	struct ila_net *ilan = net_generic(net, ila_net_id);
	struct ila_dump_iter *iter = (struct ila_dump_iter *)cb->args;

	return rhashtable_walk_init(&ilan->rhash_table, &iter->rhiter);
	return rhashtable_walk_init(&ilan->rhash_table, &iter->rhiter,
				    GFP_KERNEL);
}

static int ila_nl_dump_done(struct netlink_callback *cb)
Loading